test: handle gracefully if decompressor tools are not installed (#7455)
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Nov 2017 13:08:51 +0000 (14:08 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 24 Nov 2017 13:08:51 +0000 (14:08 +0100)
Fixes: #7441

src/journal/test-compress.c

index 1b9b186..ea1ffcc 100644 (file)
@@ -27,6 +27,7 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "macro.h"
+#include "path-util.h"
 #include "random-util.h"
 #include "util.h"
 
@@ -157,9 +158,15 @@ static void test_compress_stream(int compression,
         char pattern[] = "/tmp/systemd-test.compressed.XXXXXX",
              pattern2[] = "/tmp/systemd-test.compressed.XXXXXX";
         int r;
-        _cleanup_free_ char *cmd = NULL, *cmd2;
+        _cleanup_free_ char *cmd = NULL, *cmd2 = NULL;
         struct stat st = {};
 
+        r = find_binary(cat, NULL);
+        if (r < 0) {
+                log_error_errno(r, "Skipping %s, could not find %s binary: %m", __func__, cat);
+                return;
+        }
+
         log_debug("/* testing %s compression */",
                   object_compressed_to_string(compression));