diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-15 09:11:22 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-15 09:11:22 +0100 |
commit | c04f4febfe97fb728eea850b35771c64da1be92f (patch) | |
tree | 9343386c8e483ad889338f2081fa0f411b642c09 | |
parent | d8493662300f40c350bdc85b6fad924dd28eb049 (diff) | |
download | NetworkManager-c04f4febfe97fb728eea850b35771c64da1be92f.tar.gz |
src/tests: split test code in test_nm_utils_kill_child()
Move the actual tests to a separate function. The remaingin parts currently
setup and kill a process group, but that needs adjustment.
-rw-r--r-- | src/tests/test-general-with-expect.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index 5bbe5a25c5..3e6881ee26 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -219,9 +219,8 @@ test_nm_utils_kill_child_create_and_join_pgroup (void) #define TEST_TOKEN "nm_test_kill_child_process" static void -test_nm_utils_kill_child (void) +do_test_nm_utils_kill_child (void) { - int err; GLogLevelFlags fatal_mask; char *argv_watchdog[] = { "bash", @@ -255,7 +254,6 @@ test_nm_utils_kill_child (void) "trap \"while true; do :; done\" TERM; while true; do :; done; #" TEST_TOKEN, NULL, }; - pid_t gpid; pid_t pid1a_1, pid1a_2, pid1a_3, pid2a, pid3a, pid4a; pid_t pid1s_1, pid1s_2, pid1s_3, pid2s, pid3s, pid4s; @@ -263,8 +261,6 @@ test_nm_utils_kill_child (void) const int expected_signal_TERM = SIGTERM; const int expected_signal_KILL = SIGKILL; - gpid = test_nm_utils_kill_child_create_and_join_pgroup (); - test_nm_utils_kill_child_spawn (argv_watchdog, FALSE); pid1s_1 = test_nm_utils_kill_child_spawn (argv1, TRUE); @@ -360,14 +356,25 @@ test_nm_utils_kill_child (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_DEBUG, "*kill child process 'test-a-4' (*): terminated by signal 9 (* usec elapsed)"); test_nm_utils_kill_child_async_do ("test-a-4", pid4a, SIGTERM, 1, TRUE, &expected_signal_KILL); + g_log_set_always_fatal (fatal_mask); + + g_test_assert_expected_messages (); +} + +static void +test_nm_utils_kill_child (void) +{ + int err; + pid_t gpid; + + gpid = test_nm_utils_kill_child_create_and_join_pgroup (); + + do_test_nm_utils_kill_child (); + err = setpgid (0, 0); g_assert (err == 0); kill (-gpid, SIGKILL); - - g_log_set_always_fatal (fatal_mask); - - g_test_assert_expected_messages (); } /*****************************************************************************/ |