Skip to content

Commit fbaff6d

Browse files
committed
testsuite: fix subprocess fd leak check
Problem: several subprocess unit tests check for file descriptor leaks but don't account for file descriptors opened by the reactor itself at runtime, such as for signalfd(2). Move fd sampling period to enclose reactor creation/destruction.
1 parent 02ad07c commit fbaff6d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/common/libsubprocess/test/channel.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,12 @@ int main (int argc, char *argv[])
475475

476476
plan (NO_PLAN);
477477

478+
start_fdcount = fdcount ();
479+
478480
// Create shared reactor for all tests
479481
ok ((r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)) != NULL,
480482
"flux_reactor_create");
481483

482-
start_fdcount = fdcount ();
483-
484484
diag ("channel_fd_env");
485485
test_channel_fd_env (r);
486486
diag ("channel_fd_in");
@@ -494,12 +494,13 @@ int main (int argc, char *argv[])
494494
diag ("bufsize_error");
495495
test_bufsize_error (r);
496496

497+
flux_reactor_destroy (r);
498+
497499
end_fdcount = fdcount ();
498500

499501
ok (start_fdcount == end_fdcount,
500502
"no file descriptors leaked");
501503

502-
flux_reactor_destroy (r);
503504
done_testing ();
504505
return 0;
505506
}

src/common/libsubprocess/test/stdio.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,12 @@ int main (int argc, char *argv[])
15961596

15971597
plan (NO_PLAN);
15981598

1599+
start_fdcount = fdcount ();
1600+
15991601
// Create shared reactor for all tests
16001602
ok ((r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)) != NULL,
16011603
"flux_reactor_create");
16021604

1603-
start_fdcount = fdcount ();
1604-
16051605
diag ("basic_stdout");
16061606
test_basic_stdout (r);
16071607
diag ("basic_stdout_no_readline");
@@ -1655,12 +1655,13 @@ int main (int argc, char *argv[])
16551655
diag ("on_credit_borrow_credits");
16561656
test_on_credit_borrow_credits (r);
16571657

1658+
flux_reactor_destroy (r);
1659+
16581660
end_fdcount = fdcount ();
16591661

16601662
ok (start_fdcount == end_fdcount,
16611663
"no file descriptors leaked");
16621664

1663-
flux_reactor_destroy (r);
16641665
done_testing ();
16651666
return 0;
16661667
}

src/common/libsubprocess/test/subprocess.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,12 +1142,12 @@ int main (int argc, char *argv[])
11421142

11431143
plan (NO_PLAN);
11441144

1145+
start_fdcount = fdcount ();
1146+
11451147
// Create shared reactor for all tests
11461148
ok ((r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)) != NULL,
11471149
"flux_reactor_create");
11481150

1149-
start_fdcount = fdcount ();
1150-
11511151
diag ("corner_cases");
11521152
test_corner_cases (r);
11531153
diag ("post_exec_errors");
@@ -1196,12 +1196,13 @@ int main (int argc, char *argv[])
11961196
diag ("test_fdcleanup posix-spawn");
11971197
test_fdcleanup (r, "posix-spawn", 0, 3);
11981198

1199+
flux_reactor_destroy (r);
1200+
11991201
end_fdcount = fdcount ();
12001202

12011203
ok (start_fdcount == end_fdcount,
12021204
"no file descriptors leaked");
12031205

1204-
flux_reactor_destroy (r);
12051206
done_testing ();
12061207
return 0;
12071208
}

0 commit comments

Comments
 (0)