summaryrefslogtreecommitdiffstats
path: root/path_utils
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2012-12-23 16:13:14 -0500
committerOndrej Kos <okos@redhat.com>2013-01-07 09:24:26 +0100
commit75fb29de5f180ff7a672865629c83367c10ae5ee (patch)
treefc807fdb512b4dbc74db461c320efc3787e5ef19 /path_utils
parente984e914b6aced5dabe250ad769c63186f21f8b8 (diff)
downloadding-libs2-75fb29de5f180ff7a672865629c83367c10ae5ee.tar.gz
ding-libs2-75fb29de5f180ff7a672865629c83367c10ae5ee.tar.xz
ding-libs2-75fb29de5f180ff7a672865629c83367c10ae5ee.zip
Fix CLANG errors in unit test
Diffstat (limited to 'path_utils')
-rw-r--r--path_utils/path_utils_ut.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/path_utils/path_utils_ut.c b/path_utils/path_utils_ut.c
index aadd89b..174e02d 100644
--- a/path_utils/path_utils_ut.c
+++ b/path_utils/path_utils_ut.c
@@ -380,53 +380,67 @@ START_TEST(test_split_path)
array = split_path("/foo/bar", &n);
fail_if(array == NULL);
fail_unless(n == 3);
- fail_unless_str_equal(array[0], "/");
- fail_unless_str_equal(array[1], "foo");
- fail_unless_str_equal(array[2], "bar");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], "/");
+ fail_unless_str_equal(array[1], "foo");
+ fail_unless_str_equal(array[2], "bar");
+ free(array);
+ }
array = split_path("/foo/../bar", &n);
fail_if(array == NULL);
fail_unless(n == 4);
- fail_unless_str_equal(array[0], "/");
- fail_unless_str_equal(array[1], "foo");
- fail_unless_str_equal(array[2], "..");
- fail_unless_str_equal(array[3], "bar");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], "/");
+ fail_unless_str_equal(array[1], "foo");
+ fail_unless_str_equal(array[2], "..");
+ fail_unless_str_equal(array[3], "bar");
+ free(array);
+ }
array = split_path("/foo/bar", NULL);
fail_if(array == NULL);
- fail_unless_str_equal(array[0], "/");
- fail_unless_str_equal(array[1], "foo");
- fail_unless_str_equal(array[2], "bar");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], "/");
+ fail_unless_str_equal(array[1], "foo");
+ fail_unless_str_equal(array[2], "bar");
+ free(array);
+ }
array = split_path("foo/bar", &n);
fail_if(array == NULL);
fail_unless(n == 2);
- fail_unless_str_equal(array[0], "foo");
- fail_unless_str_equal(array[1], "bar");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], "foo");
+ fail_unless_str_equal(array[1], "bar");
+ free(array);
+ }
array = split_path(".", &n);
fail_if(array == NULL);
fail_unless(n == 1);
- fail_unless_str_equal(array[0], ".");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], ".");
+ free(array);
+ }
array = split_path("foo", &n);
fail_if(array == NULL);
fail_unless(n == 1);
- fail_unless_str_equal(array[0], "foo");
- free(array);
+ if (array) {
+ fail_unless_str_equal(array[0], "foo");
+ free(array);
+ }
/* one might expect { "" } or outright NULL, but we agreed not to
* do changes beyond bugfixes at this point */
array = split_path("", &n);
fail_if(array == NULL);
fail_unless(n == 0);
- fail_unless(array[0] == NULL);
- free(array);
+ if (array) {
+ fail_unless(array[0] == NULL);
+ free(array);
+ }
}
END_TEST
@@ -573,6 +587,7 @@ void setup_directory_list(void)
s = strdup(DIR_TEMPLATE);
fail_unless(s != NULL, "strdup failed\n");
+ if (!s) return;
dlist_dir = mkdtemp(s);
fail_unless(dlist_dir != NULL, "mkstemp failed [%d][%s]", errno, strerror(errno));