Skip to content

Commit 528091f

Browse files
avoid crashing when executing fw tests
Found while debugging an issue with several Verdict errors on kernel 6.17.x. Something has changed.
1 parent 4729e6d commit 528091f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

daemon/firewall/nftables/exprs/log_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestExprLog(t *testing.T) {
133133
r, _ := nftest.AddTestRule(t, conn, logExpr)
134134
if r == nil {
135135
t.Error("Error adding rule with log expression")
136+
return
136137
}
137138

138139
if !nftest.AreExprsValid(t, &test.TestsT, r) {

daemon/firewall/nftables/exprs/port_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,23 @@ func TestExprPort(t *testing.T) {
4747
r, _ := nftest.AddTestRule(t, conn, portExpr)
4848
if r == nil {
4949
t.Errorf("Error adding rule with port (%s) expression", test.port)
50+
return
5051
}
5152
e := r.Exprs[0]
5253
cmp, ok := e.(*expr.Cmp)
5354
if !ok {
5455
t.Errorf("%s - invalid port expr: %T", test.port, e)
56+
return
5557
}
5658
//fmt.Printf("%s, %+v\n", reflect.TypeOf(e).String(), e)
5759
if reflect.TypeOf(e).String() != "*expr.Cmp" {
5860
t.Errorf("%s - first expression should be *expr.Cmp, instead of: %s", test.port, reflect.TypeOf(e))
61+
return
5962
}
6063
portVal := binaryutil.BigEndian.PutUint16(uint16(test.portVal))
6164
if !bytes.Equal(cmp.Data, portVal) {
6265
t.Errorf("%s - invalid port in expr.Cmp: %d", test.port, cmp.Data)
66+
return
6367
}
6468

6569
})
@@ -94,11 +98,13 @@ func TestExprPortRange(t *testing.T) {
9498
r, _ := nftest.AddTestRule(t, conn, portExpr)
9599
if r == nil {
96100
t.Errorf("Error adding rule with port range (%s) expression", test.port)
101+
return
97102
}
98103
e := r.Exprs[0]
99104
_, ok := e.(*expr.Range)
100105
if !ok {
101106
t.Errorf("%s - invalid port range expr: %T", test.port, e)
107+
return
102108
}
103109
fmt.Printf("%s, %+v\n", reflect.TypeOf(e).String(), e)
104110
if reflect.TypeOf(e).String() != "*expr.Range" {

daemon/firewall/nftables/exprs/quota_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func TestExprQuota(t *testing.T) {
228228
r, _ := nftest.AddTestRule(t, conn, quotaExpr)
229229
if r == nil && !test.ExpectedFail {
230230
t.Error("Error adding rule with Quota expression")
231+
return
231232
}
232233

233234
if !nftest.AreExprsValid(t, &test, r) {

0 commit comments

Comments
 (0)