summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-10-12 09:15:23 +1100
committerChris Johns <chrisj@rtems.org>2016-10-13 13:11:40 +1100
commit826f3afaf3e4682c3ab7110648327217b0cd9e44 (patch)
treeb378ea695ba466a14220a6274ec5570a66e9457d /testsuites
parentscore: More robust linker sets (diff)
downloadrtems-826f3afaf3e4682c3ab7110648327217b0cd9e44.tar.bz2
libmisc/xz: Add xz decompression.
Add support to untar XZ compressed files.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/libtests/configure.ac2
-rw-r--r--testsuites/libtests/tar01/Makefile.am26
-rw-r--r--testsuites/libtests/tar01/init.c74
3 files changed, 98 insertions, 4 deletions
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 77b92e0fdb..430c509640 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -32,6 +32,7 @@ RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API])
AC_PROG_LN_S
AC_PATH_PROG([PAX],[pax],no)
AC_PATH_PROG([GZIP],[gzip],no)
+AC_PATH_PROG([XZ],[xz],no)
AS_IF([test "x$PAX" = "xno"],[
AC_MSG_ERROR([pax is missing.])
@@ -40,6 +41,7 @@ AS_IF([test "x$PAX" = "xno"],[
AC_CHECK_HEADERS([complex.h])
AM_CONDITIONAL(TARTESTS,test "$as_ln_s" = "ln -s" && test -n "$PAX" && test -n "$GZIP")
+AM_CONDITIONAL(TARTEST_XZ,test -n "$XZ")
AM_CONDITIONAL(HAS_CXX,test "$rtems_cv_HAS_CPLUSPLUS" = "yes")
AM_CONDITIONAL([HAS_COMPLEX],[test "$ac_cv_header_complex_h" = yes])
diff --git a/testsuites/libtests/tar01/Makefile.am b/testsuites/libtests/tar01/Makefile.am
index 8b03e59c2d..d64d2c69df 100644
--- a/testsuites/libtests/tar01/Makefile.am
+++ b/testsuites/libtests/tar01/Makefile.am
@@ -16,6 +16,14 @@ BUILT_SOURCES += initial_filesystem_tar.h
BUILT_SOURCES += initial_filesystem_tar_gz.c
BUILT_SOURCES += initial_filesystem_tar_gz.h
+if TARTEST_XZ
+tar01_SOURCES += initial_filesystem_tar_xz.c
+tar01_SOURCES += initial_filesystem_tar_xz.h
+
+BUILT_SOURCES += initial_filesystem_tar_xz.c
+BUILT_SOURCES += initial_filesystem_tar_xz.h
+endif TARTEST_XZ
+
dist_rtems_tests_DATA = tar01.scn
dist_rtems_tests_DATA += tar01.doc
endif TARTESTS
@@ -29,6 +37,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/include
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include
+if TARTEST_XZ
+AM_CFLAGS += -DHAVE_XZ=1
+endif TARTEST_XZ
+
LINK_OBJS = $(tar01_OBJECTS) $(tar01_LDADD)
LINK_LIBS = $(tar01_LDLIBS)
@@ -46,12 +58,20 @@ CLEANFILES += initial_filesystem_tar.h
initial_filesystem_tar_gz.c: initial_filesystem.tar.gz
$(BIN2C) -C initial_filesystem.tar.gz initial_filesystem_tar_gz
-CLEANFILES += initial_filesystem_tar_gz.h
+CLEANFILES += initial_filesystem_tar_gz.c
initial_filesystem_tar_gz.h: initial_filesystem.tar.gz
$(BIN2C) -H initial_filesystem.tar.gz initial_filesystem_tar_gz
CLEANFILES += initial_filesystem_tar_gz.h
+initial_filesystem_tar_xz.c: initial_filesystem.tar.xz
+ $(BIN2C) -C initial_filesystem.tar.xz initial_filesystem_tar_xz
+CLEANFILES += initial_filesystem_tar_xz.c
+
+initial_filesystem_tar_xz.h: initial_filesystem.tar.xz
+ $(BIN2C) -H initial_filesystem.tar.xz initial_filesystem_tar_xz
+CLEANFILES += initial_filesystem_tar_xz.h
+
initial_filesystem.tar:
rm -rf initial_fs
$(MKDIR_P) initial_fs/home
@@ -69,6 +89,10 @@ initial_filesystem.tar.gz: initial_filesystem.tar
$(GZIP) < initial_filesystem.tar > initial_filesystem.tar.gz
CLEANFILES += initial_filesystem.tar.gz
+initial_filesystem.tar.xz: initial_filesystem.tar
+ $(XZ) --lzma2=dict=8192 < initial_filesystem.tar > initial_filesystem.tar.xz
+CLEANFILES += initial_filesystem.tar.xz
+
endif TARTESTS
clean-local:
diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c
index 7d4f1b9a2a..f8f26c9a07 100644
--- a/testsuites/libtests/tar01/init.c
+++ b/testsuites/libtests/tar01/init.c
@@ -25,6 +25,9 @@
#include "initial_filesystem_tar.h"
#include "initial_filesystem_tar_gz.h"
+#if HAVE_XZ
+#include "initial_filesystem_tar_xz.h"
+#endif
const char rtems_test_name[] = "TAR 1";
@@ -34,11 +37,16 @@ void test_untar_from_memory(void);
void test_untar_from_file(void);
void test_untar_chunks_from_memory(void);
void test_untar_unzip_tgz(void);
+void test_untar_unzip_txz(void);
#define TARFILE_START initial_filesystem_tar
#define TARFILE_SIZE initial_filesystem_tar_size
#define TARFILE_GZ_START initial_filesystem_tar_gz
#define TARFILE_GZ_SIZE initial_filesystem_tar_gz_size
+#if HAVE_XZ
+#define TARFILE_XZ_START initial_filesystem_tar_xz
+#define TARFILE_XZ_SIZE initial_filesystem_tar_xz_size
+#endif
void test_cat(
char *file,
@@ -92,6 +100,8 @@ void test_untar_from_file(void)
int rv;
ssize_t n;
+ puts( "" );
+
puts( "Copy tar image to test.tar" );
/* Copy tar image from object to file in IMFS */
fd = open( "/test.tar", O_CREAT|O_TRUNC|O_WRONLY, 0777 );
@@ -141,6 +151,8 @@ void test_untar_chunks_from_memory(void)
char *buffer = (char *)TARFILE_START;
size_t buflen = TARFILE_SIZE;
+ puts( "" );
+
rtems_print_printer_printf(&printer);
/* make a directory to untar it into */
@@ -185,6 +197,10 @@ void test_untar_unzip_tgz(void)
size_t buflen = TARFILE_GZ_SIZE;
char inflate_buffer;
+ puts( "" );
+
+ rtems_test_assert( buflen != 0 );
+
rtems_print_printer_printf(&printer);
/* make a directory to untar it into */
@@ -218,6 +234,60 @@ void test_untar_unzip_tgz(void)
test_cat( "/dest3/symlink", 0, 0 );
}
+void test_untar_unzip_txz(void)
+{
+#if HAVE_XZ
+ int status;
+ rtems_printer printer;
+ int rv;
+ Untar_XzChunkContext ctx;
+ size_t i = 0;
+ char *buffer = (char *)TARFILE_XZ_START;
+ size_t buflen = TARFILE_XZ_SIZE;
+ char inflate_buffer;
+
+ puts( "" );
+
+ rtems_test_assert( buflen != 0 );
+
+ rtems_print_printer_printf(&printer);
+
+ /* make a directory to untar it into */
+ rv = mkdir( "/dest4", 0777 );
+ rtems_test_assert( rv == 0 );
+
+ rv = chdir( "/dest4" );
+ rtems_test_assert( rv == 0 );
+
+ printf( "Untaring chunks from txz - " );
+
+ /*
+ * Use 8K dict, this is set on the command line of xz when compressing.
+ */
+ status = Untar_XzChunkContext_Init(&ctx, XZ_DYNALLOC,
+ 8 * 1024, &inflate_buffer, 1);
+ rtems_test_assert(status == UNTAR_SUCCESSFUL);
+ for(i = 0; i < buflen; i++) {
+ status = Untar_FromXzChunk_Print(&ctx, &buffer[i], 1, &printer);
+ rtems_test_assert(status == UNTAR_SUCCESSFUL);
+ }
+ printf( "successful\n" );
+
+ /******************/
+ printf( "========= /dest4/home/test_file =========\n" );
+ test_cat( "/dest4/home/test_file", 0, 0 );
+
+ /******************/
+ printf( "========= /dest4/home/test_script =========\n" );
+ test_cat( "/dest4/home/test_script", 0, 0 );
+ test_untar_check_mode("/dest4/home/test_script", 0755);
+
+ /******************/
+ printf( "========= /dest4/symlink =========\n" );
+ test_cat( "/dest4/symlink", 0, 0 );
+#endif
+}
+
rtems_task Init(
rtems_task_argument ignored
)
@@ -225,12 +295,10 @@ rtems_task Init(
TEST_BEGIN();
test_untar_from_memory();
- puts( "" );
test_untar_from_file();
- puts( "" );
test_untar_chunks_from_memory();
- puts( "" );
test_untar_unzip_tgz();
+ test_untar_unzip_txz();
TEST_END();
exit( 0 );