Allow clean use of g_test_trap_subprocess() for multiple subtests
Submitted by Yeti
Link to original bug (#725495)
Description
The patch in bug 720236 enabled a simple use of g_test_trap_subprocess() when the test case runs exactly one subprocess. But it did not simplify things for test cases with multiple subprocess subtests because passing NULL path is of no use there (and there is no get-current-test-name function). It is still necessary to know and explicitly specify the full paths in the test function.
The documentation specifies the following convention
...test_path will normally be the name of the parent test, followed by "/subprocess/" and then a name for the specific subtest...
So there should be a function such as
void g_test_case_trap_subprocess (const char *test_case, guint64 usec_timeout, GTestSubprocessFlags test_flags) { gchar *path = g_strconcat (test_run_name, "/subprocess", test_case, NULL); g_test_trap_subprocess (path, usec_timeout, test_flags); g_free (path); }
that takes into account this convention and allows specifying only the subtest paths, i.e.
g_test_case_trap_subprocess("/1", 0, 0); ... g_test_case_trap_subprocess("/2", 0, 0); ...
etc., instead of
g_test_trap_subprocess("/suite/path/to/the/test/case/subprocess/1", 0, 0); ... g_test_trap_subprocess("/suite/path/to/the/test/case/subprocess/2", 0, 0); ...
etc. Of course, this would also cover the 1:1 case for which g_test_trap_subprocess() has now special code, but it is already too late changing that.
Version: 2.38.x