From 657d18fdbba4de3778d5a85fbe80852bcd60e719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 25 Jan 2021 14:43:00 +0100 Subject: gtestutils: Add g_test_get_path() API I found myself wanting to know the test that is currently being run, where e.g. __func__ would be inconvenient to use, because e.g. the place the string was needed was not in the test case function. Using __func__ also relies on the test function itself containing the whole path, while loosing the "/" information that is part of the test path. --- glib/tests/testing.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'glib/tests/testing.c') diff --git a/glib/tests/testing.c b/glib/tests/testing.c index 29551b9d2..7faa7b5ec 100644 --- a/glib/tests/testing.c +++ b/glib/tests/testing.c @@ -843,6 +843,18 @@ test_subprocess_timed_out (void) g_assert_true (g_test_trap_reached_timeout ()); } +static void +test_path_first (void) +{ + g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/first"); +} + +static void +test_path_second (void) +{ + g_assert_cmpstr (g_test_get_path (), ==, "/misc/path/second"); +} + static const char *argv0; static void @@ -1595,6 +1607,9 @@ main (int argc, g_test_add_func ("/misc/incomplete", test_incomplete); g_test_add_func ("/misc/timeout", test_subprocess_timed_out); + g_test_add_func ("/misc/path/first", test_path_first); + g_test_add_func ("/misc/path/second", test_path_second); + g_test_add_func ("/tap", test_tap); g_test_add_func ("/tap/summary", test_tap_summary); -- cgit v1.2.1