summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-03-10 14:32:16 +0100
committerThomas Haller <thaller@redhat.com>2015-03-12 18:12:25 +0100
commitcbfa00219e77a0cbe9afa7aae548905f188bf6cf (patch)
treeded230095296e4dcf44646926a82ac488889de1a
parentad4e6f7fad77d4e877f87c9763771889b410f395 (diff)
downloadNetworkManager-cbfa00219e77a0cbe9afa7aae548905f188bf6cf.tar.gz
test: add nmtst_assert_resolve_relative_path_equals() function
-rw-r--r--include/nm-test-utils.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h
index 7961b03891..33b8fa51a7 100644
--- a/include/nm-test-utils.h
+++ b/include/nm-test-utils.h
@@ -576,6 +576,39 @@ __nmtst_spawn_sync (const char *working_directory, char **standard_out, char **s
/*******************************************************************************/
+inline static char *
+nmtst_file_resolve_relative_path (const char *rel, const char *cwd)
+{
+ gs_free char *cwd_free = NULL;
+
+ g_assert (rel && *rel);
+
+ if (g_path_is_absolute (rel))
+ return g_strdup (rel);
+
+ if (!cwd)
+ cwd = cwd_free = g_get_current_dir ();
+ return g_build_filename (cwd, rel, NULL);
+}
+
+inline static void
+_nmtst_assert_resolve_relative_path_equals (const char *f1, const char *f2, const char *file, int line)
+{
+ gs_free char *p1 = NULL, *p2 = NULL;
+
+ p1 = nmtst_file_resolve_relative_path (f1, NULL);
+ p2 = nmtst_file_resolve_relative_path (f2, NULL);
+ g_assert (p1 && *p1);
+
+ /* Fixme: later we might need to coalesce repeated '/', "./", and "../".
+ * For now, it's good enough. */
+ if (g_strcmp0 (p1, p2) != 0)
+ g_error ("%s:%d : filenames don't match \"%s\" vs. \"%s\" // \"%s\" - \"%s\"", file, line, f1, f2, p1, p2);
+}
+#define nmtst_assert_resolve_relative_path_equals(f1, f2) _nmtst_assert_resolve_relative_path_equals (f1, f2, __FILE__, __LINE__);
+
+/*******************************************************************************/
+
#ifdef __NETWORKMANAGER_PLATFORM_H__
inline static NMPlatformIP6Address *