Skip to content

Commit 9f3466d

Browse files
committed
testsuite: cover flux_msg_fprint() rolemask string
Problem: changes to the rendering of the rolemask string in flux_msg_fprint() have no test coverage. Add unit test.
1 parent 3b4c742 commit 9f3466d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/common/libflux/test/message.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,29 @@ void check_print (void)
11611161
fclose (f);
11621162
}
11631163

1164+
void check_print_rolemask (void)
1165+
{
1166+
flux_msg_t *msg;
1167+
FILE *fp;
1168+
uint32_t rolemask;
1169+
char *buf = NULL;
1170+
size_t size = 0;
1171+
1172+
rolemask = FLUX_ROLE_LOCAL | FLUX_ROLE_USER | 0x10;
1173+
if (!(msg = flux_msg_create (FLUX_MSGTYPE_REQUEST))
1174+
|| flux_msg_set_rolemask (msg, rolemask) < 0)
1175+
BAIL_OUT ("failed to create test request");
1176+
if (!(fp = open_memstream (&buf, &size)))
1177+
BAIL_OUT ("open_memstream failed");
1178+
flux_msg_fprint (fp, msg);
1179+
fclose (fp); // close flushes content
1180+
diag ("%s", buf);
1181+
ok (buf && strstr (buf, "rolemask=user,local,0x10") != NULL,
1182+
"flux_msg_fprint() rolemask string is correct");
1183+
free (buf);
1184+
flux_msg_destroy (msg);
1185+
}
1186+
11641187
void check_flags (void)
11651188
{
11661189
flux_msg_t *msg;
@@ -1404,6 +1427,7 @@ int main (int argc, char *argv[])
14041427
check_refcount();
14051428

14061429
check_print ();
1430+
check_print_rolemask ();
14071431

14081432
check_proto_internal ();
14091433

0 commit comments

Comments
 (0)