Skip to content

Commit

Permalink
chore: document more testcases
Browse files Browse the repository at this point in the history
Signed-off-by: Robin H. Johnson <[email protected]>
  • Loading branch information
robbat2 committed Dec 30, 2024
1 parent b9f5e80 commit d7b8377
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ START_TEST(test_add_ra_options_prefix)
snprint_safe_buffer(buf, 4096, &sb);
ck_assert_msg(0, "\n%s", (char*)&buf);
#else
// https://www.rfc-editor.org/rfc/rfc4861.html#section-4.6.2
unsigned char expected[] = {
// prefix fe80:1::/64
0x03, 0x04, 0x40, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0xfe, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// prefix fe80:2::/48
0x03, 0x04, 0x30, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00,
0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// prefix fe80:2::/64
0x03, 0x04, 0x40, 0xc0, 0x00, 0x01, 0x51, 0x80, 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00,
0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Expand Down Expand Up @@ -169,10 +173,15 @@ START_TEST(test_add_ra_options_route)
snprint_safe_buffer(buf, 4096, &sb);
ck_assert_msg(0, "\n%s", (char*)&buf);
#else
// https://www.rfc-editor.org/rfc/rfc4191.html#section-2.3
unsigned char expected[] = {
// fe80:f:1::/48
0x18, 0x02, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00,
// fe80:f:2::/40
0x18, 0x02, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
// fe80:f:2::/32
0x18, 0x02, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
// fe80:f:2::/128
0x18, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Expand Down Expand Up @@ -690,6 +699,7 @@ START_TEST(test_add_ra_option_mtu)
snprint_safe_buffer(buf, 4096, &sb);
ck_assert_msg(0, "\n%s", (char*)&buf);
#else
// https://www.rfc-editor.org/rfc/rfc4861.html#section-4.6.4
unsigned char expected[] = {
0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2,
};
Expand All @@ -702,7 +712,7 @@ START_TEST(test_add_ra_option_mtu)
}
END_TEST

START_TEST(test_add_ra_option_sllao)
START_TEST(test_add_ra_option_sllao48)
{
struct sllao sllao48 = {
{1, 2, 3, 4, 5, 6, 7, 8}, 48, 64, 1500,
Expand All @@ -725,12 +735,17 @@ START_TEST(test_add_ra_option_sllao)
#endif

safe_buffer_free(&sb);
}
END_TEST

START_TEST(test_add_ra_option_sllao64)
{

struct sllao sllao64 = {
{1, 2, 3, 4, 5, 6, 7, 8}, 64, 64, 1500,
};

sb = SAFE_BUFFER_INIT;
struct safe_buffer sb = SAFE_BUFFER_INIT;
add_ra_option_sllao(&sb, &sllao64);

#ifdef PRINT_SAFE_BUFFER
Expand Down Expand Up @@ -820,7 +835,8 @@ Suite *send_suite(void)
tcase_add_test(tc_build, test_add_ra_options_dnssl5);
tcase_add_test(tc_build, test_add_ra_options_dnssl6);
tcase_add_test(tc_build, test_add_ra_option_mtu);
tcase_add_test(tc_build, test_add_ra_option_sllao);
tcase_add_test(tc_build, test_add_ra_option_sllao48);
tcase_add_test(tc_build, test_add_ra_option_sllao64);
tcase_add_test(tc_build, test_add_ra_option_lowpanco);
tcase_add_test(tc_build, test_add_ra_option_abro);

Expand Down

0 comments on commit d7b8377

Please sign in to comment.