]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-compress*: silence warning about unused definitions when w/o both xz and lz4
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Apr 2017 13:28:50 +0000 (09:28 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 19 Apr 2017 23:27:01 +0000 (19:27 -0400)
I think it's nice to mark the test as skipped instead of omitting
it entirely, hence #ifdefs in the code instead of excluding the test
in Makefile.am/meson.build.

src/journal/test-compress-benchmark.c
src/journal/test-compress.c

index 6f6d71435d21419d51e7a29f1ba8b18ec6a6ff4f..4fb93ded73ef32b1156c2185243b8367434e6a3e 100644 (file)
@@ -30,6 +30,8 @@ typedef int (compress_t)(const void *src, uint64_t src_size, void *dst,
 typedef int (decompress_t)(const void *src, uint64_t src_size,
                            void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max);
 
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
+
 static usec_t arg_duration = 2 * USEC_PER_SEC;
 static size_t arg_start;
 
@@ -151,8 +153,10 @@ static void test_compress_decompress(const char* label, const char* type,
                  100 - compressed * 100. / total,
                  skipped);
 }
+#endif
 
 int main(int argc, char *argv[]) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
         const char *i;
 
         log_set_max_level(LOG_INFO);
@@ -177,4 +181,7 @@ int main(int argc, char *argv[]) {
 #endif
         }
         return 0;
+#else
+        return EXIT_TEST_SKIP;
+#endif
 }
index 44a2cf5217315b6c87e3d3b384e9835bcec82acd..92108a84b3f13af2ed084b934b5b34927c73afe5 100644 (file)
@@ -54,6 +54,7 @@ typedef int (decompress_sw_t)(const void *src, uint64_t src_size,
 typedef int (compress_stream_t)(int fdf, int fdt, uint64_t max_bytes);
 typedef int (decompress_stream_t)(int fdf, int fdt, uint64_t max_size);
 
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
 static void test_compress_decompress(int compression,
                                      compress_blob_t compress,
                                      decompress_blob_t decompress,
@@ -203,6 +204,7 @@ static void test_compress_stream(int compression,
         assert_se(unlink(pattern) == 0);
         assert_se(unlink(pattern2) == 0);
 }
+#endif
 
 #ifdef HAVE_LZ4
 static void test_lz4_decompress_partial(void) {
@@ -247,6 +249,7 @@ static void test_lz4_decompress_partial(void) {
 #endif
 
 int main(int argc, char *argv[]) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
         const char text[] =
                 "text\0foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"
                 "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF";
@@ -312,4 +315,7 @@ int main(int argc, char *argv[]) {
 #endif
 
         return 0;
+#else
+        return EXIT_TEST_SKIP;
+#endif
 }