chiark / gitweb /
path-util: also check for existence of binary when given absolute path
[elogind.git] / src / test / test-path-util.c
index bec2a836112693836f3851165d30171850f8901d..527b27565693959b89405da5c3d36115aed9b577 100644 (file)
@@ -104,6 +104,8 @@ static void test_find_binary(void) {
         free(p);
 
         assert(find_binary("xxxx-xxxx", &p) == -ENOENT);
+
+        assert(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
 }
 
 static void test_prefixes(void) {
@@ -158,9 +160,20 @@ static void test_prefixes(void) {
         }
 }
 
+static void test_fsck_exists(void) {
+        /* Ensure we use a sane default for PATH. */
+        unsetenv("PATH");
+
+        /* fsck.minix is provided by util-linux and will probably exist. */
+        assert_se(fsck_exists("minix") == 0);
+
+        assert_se(fsck_exists("AbCdE") == -ENOENT);
+}
+
 int main(void) {
         test_path();
         test_find_binary();
         test_prefixes();
+        test_fsck_exists();
         return 0;
 }