[tracker: 1/2] libtracker-common: improve test_path_evaluate_name environment handling
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 1/2] libtracker-common: improve test_path_evaluate_name environment handling
- Date: Sun, 17 Feb 2019 14:29:57 +0000 (UTC)
commit b9c2b6827981dd32041f59d89f74c7f4537697f0
Author: Mart Raudsepp <leio gentoo org>
Date: Wed Feb 13 20:09:45 2019 +0200
libtracker-common: improve test_path_evaluate_name environment handling
Under some environments $PWD might not point where we expect, so simply
use g_get_current_dir() instead.
g_getenv() is documented to return a pointer that may get overwritten
by subsequent calls to g_getenv, g_setenv of g_unsetenv. As even after
removing the second g_getenv, there's still g_setenv calls, take a copy.
tests/libtracker-common/tracker-file-utils-test.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/tests/libtracker-common/tracker-file-utils-test.c
b/tests/libtracker-common/tracker-file-utils-test.c
index 93a409b37..5bf1c9ed4 100644
--- a/tests/libtracker-common/tracker-file-utils-test.c
+++ b/tests/libtracker-common/tracker-file-utils-test.c
@@ -131,14 +131,14 @@ test_path_list_filter_duplicates_with_exceptions ()
static void
test_path_evaluate_name (void)
{
- gchar *result, *expected;
+ gchar *result, *expected, *pwd, *home;
- const gchar *home = g_getenv ("HOME");
- const gchar *pwd = g_getenv ("PWD");
const gchar *test = "/one/two";
gchar *parent_dir;
+ home = g_strdup (g_getenv ("HOME"));
+ pwd = g_get_current_dir ();
g_setenv ("TEST_TRACKER_DIR", test, TRUE);
@@ -216,6 +216,8 @@ test_path_evaluate_name (void)
result = tracker_path_evaluate_name (tracker_test_helpers_get_nonutf8 ());
g_assert_cmpstr (result, ==, tracker_test_helpers_get_nonutf8 ());
+ g_free (home);
+ g_free (pwd);
g_unsetenv ("TEST_TRACKER_DIR");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]