Author: melifaro Date: Fri Jan 10 08:54:46 2020 New Revision: 356596 URL: https://svnweb.freebsd.org/changeset/base/356596
Log: Include human-readable list of rtm flags along with bitmask in error messages for rtsock tests. MFC after: 2 weeks Modified: head/tests/sys/net/routing/rtsock_print.h head/tests/sys/net/routing/test_rtsock_l3.c Modified: head/tests/sys/net/routing/rtsock_print.h ============================================================================== --- head/tests/sys/net/routing/rtsock_print.h Fri Jan 10 04:13:16 2020 (r356595) +++ head/tests/sys/net/routing/rtsock_print.h Fri Jan 10 08:54:46 2020 (r356596) @@ -132,7 +132,15 @@ rtsock_print_cmdtype(int cmd) return (msgtypes[cmd]); } +char * +rtsock_print_rtm_flags(char *buf, int buflen, int rtm_flags) +{ + _printb(buf, buflen, rtm_flags, routeflags); + return (buf); +} + + #define _PRINTX(fmt, ...) do { \ one_len = snprintf(ptr, rem_len, fmt, __VA_ARGS__); \ ptr += one_len; \ @@ -262,7 +270,7 @@ rtsock_print_rtm(struct rt_msghdr *rtm) printf("Got message of size %hu on %s\n", rtm->rtm_msglen, buf); char flags_buf[256]; - _printb(flags_buf, sizeof(flags_buf), rtm->rtm_flags, routeflags); + rtsock_print_rtm_flags(flags_buf, sizeof(flags_buf), rtm->rtm_flags); printf("%s: len %hu, pid: %d, seq %d, errno %d, flags: %s\n", msgtypes[rtm->rtm_type], rtm->rtm_msglen, rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno, flags_buf); Modified: head/tests/sys/net/routing/test_rtsock_l3.c ============================================================================== --- head/tests/sys/net/routing/test_rtsock_l3.c Fri Jan 10 04:13:16 2020 (r356595) +++ head/tests/sys/net/routing/test_rtsock_l3.c Fri Jan 10 08:54:46 2020 (r356596) @@ -196,8 +196,18 @@ verify_route_message_extra(struct rt_msghdr *rtm, int RTSOCK_ATF_REQUIRE_MSG(rtm, rtm->rtm_index == ifindex, "expected ifindex %d, got %d", ifindex, rtm->rtm_index); - RTSOCK_ATF_REQUIRE_MSG(rtm, rtm->rtm_flags == rtm_flags, - "expected flags: 0x%X, got 0x%X", rtm_flags, rtm->rtm_flags); + if (rtm->rtm_flags != rtm_flags) { + char got_flags[64], expected_flags[64]; + rtsock_print_rtm_flags(got_flags, sizeof(got_flags), + rtm->rtm_flags); + rtsock_print_rtm_flags(expected_flags, sizeof(expected_flags), + rtm_flags); + + RTSOCK_ATF_REQUIRE_MSG(rtm, rtm->rtm_flags == rtm_flags, + "expected flags: 0x%X %s, got 0x%X %s", + rtm_flags, expected_flags, + rtm->rtm_flags, got_flags); + } } static void _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"