Skip to content

Commit 4f4ea31

Browse files
committed
libsubprocess/test: fix racy credit test output
Problem: Credit based output tests send data to the 'test_echo' command in small chunks. If the system is slow, this data could be read by 'test_echo' in multiple chunks, therefore leading to errant newlines in the output. Solution: Update credit based tests to not output newlines. Fixes #7311
1 parent 54ed026 commit 4f4ea31

File tree

1 file changed

+7
-7
lines changed
  • src/common/libsubprocess/test

1 file changed

+7
-7
lines changed

src/common/libsubprocess/test/stdio.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,11 +1442,11 @@ void credit_output_cb (flux_subprocess_t *p, const char *stream)
14421442
ok (flux_subprocess_read_stream_closed (p, stream),
14431443
"flux_subprocess_read_stream_closed saw EOF on %s", stream);
14441444

1445-
sprintf (cmpbuf, "abcdefghijklmnopqrstuvwxyz0123456789\n");
1445+
sprintf (cmpbuf, "abcdefghijklmnopqrstuvwxyz0123456789");
14461446
ok (streq (outputbuf, cmpbuf),
14471447
"flux_subprocess_read returned correct data: %s", outputbuf);
1448-
/* 26 (ABCs) + 10 (1-10) + 1 for `\n' */
1449-
ok (outputbuf_len == (26 + 10 + 1),
1448+
/* 26 (ABCs) + 10 (1-10) */
1449+
ok (outputbuf_len == (26 + 10),
14501450
"flux_subprocess_read returned correct amount of data: %d",
14511451
outputbuf_len);
14521452
}
@@ -1493,13 +1493,13 @@ void credit_cb (flux_subprocess_t *p, const char *stream, int bytes)
14931493

14941494
void test_on_credit (flux_reactor_t *r)
14951495
{
1496-
char *av[] = { TEST_SUBPROCESS_DIR "test_echo", "-O", NULL };
1496+
char *av[] = { TEST_SUBPROCESS_DIR "test_echo", "-O", "-n", NULL };
14971497
flux_cmd_t *cmd;
14981498
flux_subprocess_t *p = NULL;
14991499
int credits = 0;
15001500
int ret;
15011501

1502-
ok ((cmd = flux_cmd_create (2, av, environ)) != NULL, "flux_cmd_create");
1502+
ok ((cmd = flux_cmd_create (3, av, environ)) != NULL, "flux_cmd_create");
15031503
ok (flux_cmd_setopt (cmd, "stdin_BUFSIZE", "8") == 0,
15041504
"set stdin buffer size to 8 bytes");
15051505

@@ -1543,13 +1543,13 @@ void test_on_credit (flux_reactor_t *r)
15431543
*/
15441544
void test_on_credit_borrow_credits (flux_reactor_t *r)
15451545
{
1546-
char *av[] = { TEST_SUBPROCESS_DIR "test_echo", "-O", NULL };
1546+
char *av[] = { TEST_SUBPROCESS_DIR "test_echo", "-O", "-n", NULL };
15471547
flux_cmd_t *cmd;
15481548
flux_subprocess_t *p = NULL;
15491549
int credits = 0;
15501550
int ret;
15511551

1552-
ok ((cmd = flux_cmd_create (2, av, environ)) != NULL, "flux_cmd_create");
1552+
ok ((cmd = flux_cmd_create (3, av, environ)) != NULL, "flux_cmd_create");
15531553
ok (flux_cmd_setopt (cmd, "stdin_BUFSIZE", "8") == 0,
15541554
"set stdin buffer size to 8 bytes");
15551555

0 commit comments

Comments
 (0)