From: Michihiro NAKAJIMA Date: Mon, 18 Aug 2014 13:07:48 +0000 (+0900) Subject: Add lz4 test for bsdcat. X-Git-Tag: v3.1.900a~241 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6b202b6e70cff11f6f611ff56c1ab5584914bb5;p=thirdparty%2Flibarchive.git Add lz4 test for bsdcat. - add test utility function canLz4() - fix test_write_filter_lz4 to use canLz4() --- diff --git a/Makefile.am b/Makefile.am index 0b4c27c98..35f9e867e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1142,6 +1142,7 @@ bsdcat_test_SOURCES= \ cat/test/test.h \ cat/test/test_0.c \ cat/test/test_empty_gz.c \ + cat/test/test_empty_lz4.c \ cat/test/test_empty_xz.c \ cat/test/test_error.c \ cat/test/test_error_mixed.c \ @@ -1175,6 +1176,7 @@ endif bsdcat_test_EXTRA_DIST= \ cat/test/list.h \ cat/test/test_empty.gz.uu \ + cat/test/test_empty.lz4.uu \ cat/test/test_empty.xz.uu \ cat/test/test_expand.Z.uu \ cat/test/test_expand.bz2.uu \ diff --git a/cat/test/CMakeLists.txt b/cat/test/CMakeLists.txt index f86c7bf39..86ae69275 100644 --- a/cat/test/CMakeLists.txt +++ b/cat/test/CMakeLists.txt @@ -10,6 +10,7 @@ IF(ENABLE_CAT AND ENABLE_TEST) test.h test_0.c test_empty_gz.c + test_empty_lz4.c test_empty_xz.c test_error.c test_error_mixed.c diff --git a/cat/test/main.c b/cat/test/main.c index 649e00992..22d211f92 100644 --- a/cat/test/main.c +++ b/cat/test/main.c @@ -1931,6 +1931,21 @@ canLrzip(void) return (value); } +/* + * Can this platform run the lz4 program? + */ +int +canLz4(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lz4 -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + /* * Can this platform run the lzip program? */ diff --git a/cat/test/test.h b/cat/test/test.h index fa3e9c57e..68473851c 100644 --- a/cat/test/test.h +++ b/cat/test/test.h @@ -281,6 +281,9 @@ int canGzip(void); /* Return true if this platform can run the "lrzip" program. */ int canLrzip(void); +/* Return true if this platform can run the "lz4" program. */ +int canLz4(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void); diff --git a/cat/test/test_empty.lz4.uu b/cat/test/test_empty.lz4.uu new file mode 100644 index 000000000..8491afbd8 --- /dev/null +++ b/cat/test/test_empty.lz4.uu @@ -0,0 +1,4 @@ +begin 644 test_empty.lz4 +/!")-&&1PN0`````%7test.out 2>test.err", testprog, reffile); + if (f == 0 || canLz4()) { + assertEqualInt(0, f); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems lz4 is not supported on this platform"); + } +} diff --git a/cpio/test/main.c b/cpio/test/main.c index 2b5ab0cc8..d4ed509a9 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -1931,6 +1931,21 @@ canLrzip(void) return (value); } +/* + * Can this platform run the lz4 program? + */ +int +canLz4(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lz4 -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + /* * Can this platform run the lzip program? */ diff --git a/cpio/test/test.h b/cpio/test/test.h index d645cad86..9898be65c 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -279,6 +279,9 @@ int canGzip(void); /* Return true if this platform can run the "lrzip" program. */ int canLrzip(void); +/* Return true if this platform can run the "lz4" program. */ +int canLz4(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void); diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 28afb9d6e..99c593399 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -1937,6 +1937,21 @@ canLrzip(void) return (value); } +/* + * Can this platform run the lz4 program? + */ +int +canLz4(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lz4 -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + /* * Can this platform run the lzip program? */ diff --git a/libarchive/test/test.h b/libarchive/test/test.h index aa1df32f1..73e16eaf9 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -281,6 +281,9 @@ int canRunCommand(const char *); /* Return true if this platform can run the "lrzip" program. */ int canLrzip(void); +/* Return true if this platform can run the "lz4" program. */ +int canLz4(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void); diff --git a/libarchive/test/test_write_filter_lz4.c b/libarchive/test/test_write_filter_lz4.c index 2c20b0d7a..ae4fc67f3 100644 --- a/libarchive/test/test_write_filter_lz4.c +++ b/libarchive/test/test_write_filter_lz4.c @@ -44,7 +44,7 @@ DEFINE_TEST(test_write_filter_lz4) assert((a = archive_write_new()) != NULL); r = archive_write_add_filter_lz4(a); if (r != ARCHIVE_OK) { - if (canLzop() && r == ARCHIVE_WARN) + if (canLz4() && r == ARCHIVE_WARN) use_prog = 1; else { skipping("lz4 writing not supported on this platform"); @@ -281,7 +281,7 @@ test_options(const char *options) assert((a = archive_write_new()) != NULL); r = archive_write_add_filter_lz4(a); if (r != ARCHIVE_OK) { - if (canLzop() && r == ARCHIVE_WARN) + if (canLz4() && r == ARCHIVE_WARN) use_prog = 1; else { skipping("lz4 writing not supported on this platform"); diff --git a/tar/test/main.c b/tar/test/main.c index 455921ba2..bef18f252 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -1932,6 +1932,21 @@ canLrzip(void) return (value); } +/* + * Can this platform run the lz4 program? + */ +int +canLz4(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("lz4 -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + /* * Can this platform run the lzip program? */ diff --git a/tar/test/test.h b/tar/test/test.h index fa3e9c57e..68473851c 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -281,6 +281,9 @@ int canGzip(void); /* Return true if this platform can run the "lrzip" program. */ int canLrzip(void); +/* Return true if this platform can run the "lz4" program. */ +int canLz4(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void);