Skip to content

Commit f164b29

Browse files
groeckkuba-moo
authored andcommitted
net: microchip: vcap: Add typegroup table terminators in kunit tests
VCAP API unit tests fail randomly with errors such as # vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:387 Expected 134 + 7 == iter.offset, but 134 + 7 == 141 (0x8d) iter.offset == 17214 (0x433e) # vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:388 Expected 5 == iter.reg_idx, but iter.reg_idx == 702 (0x2be) # vcap_api_iterator_init_test: EXPECTATION FAILED at drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:389 Expected 11 == iter.reg_bitpos, but iter.reg_bitpos == 15 (0xf) # vcap_api_iterator_init_test: pass:0 fail:1 skip:0 total:1 Comments in the code state that "A typegroup table ends with an all-zero terminator". Add the missing terminators. Some of the typegroups did have a terminator of ".offset = 0, .width = 0, .value = 0,". Replace those terminators with "{ }" (no trailing ',') for consistency and to excplicitly state "this is a terminator". Fixes: 67d6375 ("net: microchip: sparx5: Adding KUNIT test for the VCAP API") Cc: Steen Hegelund <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Reviewed-by: Daniel Machon <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e863ff8 commit f164b29

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,13 @@ static void vcap_api_iterator_init_test(struct kunit *test)
366366
struct vcap_typegroup typegroups[] = {
367367
{ .offset = 0, .width = 2, .value = 2, },
368368
{ .offset = 156, .width = 1, .value = 0, },
369-
{ .offset = 0, .width = 0, .value = 0, },
369+
{ }
370370
};
371371
struct vcap_typegroup typegroups2[] = {
372372
{ .offset = 0, .width = 3, .value = 4, },
373373
{ .offset = 49, .width = 2, .value = 0, },
374374
{ .offset = 98, .width = 2, .value = 0, },
375+
{ }
375376
};
376377

377378
vcap_iter_init(&iter, 52, typegroups, 86);
@@ -399,6 +400,7 @@ static void vcap_api_iterator_next_test(struct kunit *test)
399400
{ .offset = 147, .width = 3, .value = 0, },
400401
{ .offset = 196, .width = 2, .value = 0, },
401402
{ .offset = 245, .width = 1, .value = 0, },
403+
{ }
402404
};
403405
int idx;
404406

@@ -433,7 +435,7 @@ static void vcap_api_encode_typegroups_test(struct kunit *test)
433435
{ .offset = 147, .width = 3, .value = 5, },
434436
{ .offset = 196, .width = 2, .value = 2, },
435437
{ .offset = 245, .width = 5, .value = 27, },
436-
{ .offset = 0, .width = 0, .value = 0, },
438+
{ }
437439
};
438440

439441
vcap_encode_typegroups(stream, 49, typegroups, false);
@@ -463,6 +465,7 @@ static void vcap_api_encode_bit_test(struct kunit *test)
463465
{ .offset = 147, .width = 3, .value = 5, },
464466
{ .offset = 196, .width = 2, .value = 2, },
465467
{ .offset = 245, .width = 1, .value = 0, },
468+
{ }
466469
};
467470

468471
vcap_iter_init(&iter, 49, typegroups, 44);
@@ -489,7 +492,7 @@ static void vcap_api_encode_field_test(struct kunit *test)
489492
{ .offset = 147, .width = 3, .value = 5, },
490493
{ .offset = 196, .width = 2, .value = 2, },
491494
{ .offset = 245, .width = 5, .value = 27, },
492-
{ .offset = 0, .width = 0, .value = 0, },
495+
{ }
493496
};
494497
struct vcap_field rf = {
495498
.type = VCAP_FIELD_U32,
@@ -538,7 +541,7 @@ static void vcap_api_encode_short_field_test(struct kunit *test)
538541
{ .offset = 0, .width = 3, .value = 7, },
539542
{ .offset = 21, .width = 2, .value = 3, },
540543
{ .offset = 42, .width = 1, .value = 1, },
541-
{ .offset = 0, .width = 0, .value = 0, },
544+
{ }
542545
};
543546
struct vcap_field rf = {
544547
.type = VCAP_FIELD_U32,
@@ -608,7 +611,7 @@ static void vcap_api_encode_keyfield_test(struct kunit *test)
608611
struct vcap_typegroup tgt[] = {
609612
{ .offset = 0, .width = 2, .value = 2, },
610613
{ .offset = 156, .width = 1, .value = 1, },
611-
{ .offset = 0, .width = 0, .value = 0, },
614+
{ }
612615
};
613616

614617
vcap_test_api_init(&admin);
@@ -671,7 +674,7 @@ static void vcap_api_encode_max_keyfield_test(struct kunit *test)
671674
struct vcap_typegroup tgt[] = {
672675
{ .offset = 0, .width = 2, .value = 2, },
673676
{ .offset = 156, .width = 1, .value = 1, },
674-
{ .offset = 0, .width = 0, .value = 0, },
677+
{ }
675678
};
676679
u32 keyres[] = {
677680
0x928e8a84,
@@ -732,7 +735,7 @@ static void vcap_api_encode_actionfield_test(struct kunit *test)
732735
{ .offset = 0, .width = 2, .value = 2, },
733736
{ .offset = 21, .width = 1, .value = 1, },
734737
{ .offset = 42, .width = 1, .value = 0, },
735-
{ .offset = 0, .width = 0, .value = 0, },
738+
{ }
736739
};
737740

738741
vcap_encode_actionfield(&rule, &caf, &rf, tgt);

0 commit comments

Comments
 (0)