diff options
author | Alexander Krutwig <alexander.krutwig@embedded-brains.de> | 2016-07-25 15:34:43 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-07-26 10:00:04 +0200 |
commit | 6a174c024aa878e72386f811f28d880449fc264d (patch) | |
tree | 908ac8a0d007430611dd14a84754d94e6885fcce /testsuites | |
parent | Add Untar_FromChunk_Print() + Test (diff) | |
download | rtems-6a174c024aa878e72386f811f28d880449fc264d.tar.bz2 |
Add Untar_FromGzChunk_Print() + Test
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/libtests/configure.ac | 3 | ||||
-rw-r--r-- | testsuites/libtests/tar01/Makefile.am | 32 | ||||
-rw-r--r-- | testsuites/libtests/tar01/init.c | 45 | ||||
-rw-r--r-- | testsuites/libtests/tar01/tar01.doc | 1 | ||||
-rw-r--r-- | testsuites/libtests/tar01/tar01.scn | 11 |
5 files changed, 87 insertions, 5 deletions
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac index a136749c8a..82f2d80a5b 100644 --- a/testsuites/libtests/configure.ac +++ b/testsuites/libtests/configure.ac @@ -31,6 +31,7 @@ RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API]) AC_PROG_LN_S AC_PATH_PROG([PAX],[pax],no) +AC_PATH_PROG([GZIP],[gzip],no) AS_IF([test "x$PAX" = "xno"],[ AC_MSG_ERROR([pax is missing.]) @@ -38,7 +39,7 @@ AS_IF([test "x$PAX" = "xno"],[ AC_CHECK_HEADERS([complex.h]) -AM_CONDITIONAL(TARTESTS,test "$as_ln_s" = "ln -s" && test -n "$PAX") +AM_CONDITIONAL(TARTESTS,test "$as_ln_s" = "ln -s" && test -n "$PAX" && test -n "$GZIP") 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 6bcb4f26cd..d7257bc69f 100644 --- a/testsuites/libtests/tar01/Makefile.am +++ b/testsuites/libtests/tar01/Makefile.am @@ -1,9 +1,20 @@ if TARTESTS rtems_tests_PROGRAMS = tar01 -tar01_SOURCES = init.c ../../psxtests/psxfile01/test_cat.c \ - initial_filesystem_tar.c initial_filesystem_tar.h +tar01_SOURCES = +tar01_SOURCES += init.c +tar01_SOURCES += ../../psxtests/psxfile01/test_cat.c +tar01_SOURCES += initial_filesystem_tar.c +tar01_SOURCES += initial_filesystem_tar.h +tar01_SOURCES += initial_filesystem_tar_gz.c +tar01_SOURCES += initial_filesystem_tar_gz.h + +tar01_LDADD = -lrtemscpu -lz -BUILT_SOURCES = initial_filesystem_tar.c initial_filesystem_tar.h +BUILT_SOURCES = +BUILT_SOURCES += initial_filesystem_tar.c +BUILT_SOURCES += initial_filesystem_tar.h +BUILT_SOURCES += initial_filesystem_tar_gz.c +BUILT_SOURCES += initial_filesystem_tar_gz.h dist_rtems_tests_DATA = tar01.scn dist_rtems_tests_DATA += tar01.doc @@ -18,7 +29,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/include AM_CPPFLAGS += -I$(top_srcdir)/../support/include AM_CPPFLAGS += -I$(top_srcdir)/../psxtests/include -LINK_OBJS = $(tar01_OBJECTS) +LINK_OBJS = $(tar01_OBJECTS) $(tar01_LDADD) LINK_LIBS = $(tar01_LDLIBS) tar01$(EXEEXT): $(tar01_OBJECTS) $(tar01_DEPENDENCIES) @@ -33,6 +44,14 @@ initial_filesystem_tar.h: initial_filesystem.tar $(BIN2C) -H initial_filesystem.tar initial_filesystem_tar 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 + +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: rm -rf initial_fs $(MKDIR_P) initial_fs/home @@ -42,6 +61,11 @@ initial_filesystem.tar: $(LN_S) home/test_file symlink; \ $(PAX) -w -f ../initial_filesystem.tar home symlink) CLEANFILES += initial_filesystem.tar + +initial_filesystem.tar.gz: initial_filesystem.tar + $(GZIP) < initial_filesystem.tar > initial_filesystem.tar.gz +CLEANFILES += initial_filesystem.tar.gz + endif TARTESTS clean-local: diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c index 285c767280..4bfa29c636 100644 --- a/testsuites/libtests/tar01/init.c +++ b/testsuites/libtests/tar01/init.c @@ -24,6 +24,7 @@ #include <unistd.h> #include "initial_filesystem_tar.h" +#include "initial_filesystem_tar_gz.h" const char rtems_test_name[] = "TAR 1"; @@ -32,9 +33,12 @@ rtems_task Init(rtems_task_argument argument); 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); #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 void test_cat( char *file, @@ -145,6 +149,45 @@ void test_untar_chunks_from_memory(void) } +void test_untar_unzip_tgz(void) +{ + int status; + rtems_printer printer; + int rv; + Untar_GzChunkContext ctx; + size_t i = 0; + char *buffer = (char *)TARFILE_GZ_START; + size_t buflen = TARFILE_GZ_SIZE; + char inflate_buffer; + + rtems_print_printer_printf(&printer); + + /* make a directory to untar it into */ + rv = mkdir( "/dest3", 0777 ); + rtems_test_assert( rv == 0 ); + + rv = chdir( "/dest3" ); + rtems_test_assert( rv == 0 ); + + printf( "Untaring chunks from tgz - " ); + + status = Untar_GzChunkContext_Init(&ctx, &inflate_buffer, 1); + rtems_test_assert(status == UNTAR_SUCCESSFUL); + for(i = 0; i < buflen; i++) { + status = Untar_FromGzChunk_Print(&ctx, &buffer[i], 1, &printer); + rtems_test_assert(status == UNTAR_SUCCESSFUL); + } + printf( "successful\n" ); + + /******************/ + printf( "========= /dest3/home/test_file =========\n" ); + test_cat( "/dest3/home/test_file", 0, 0 ); + + /******************/ + printf( "========= /dest3/symlink =========\n" ); + test_cat( "/dest3/symlink", 0, 0 ); +} + rtems_task Init( rtems_task_argument ignored ) @@ -156,6 +199,8 @@ rtems_task Init( test_untar_from_file(); puts( "" ); test_untar_chunks_from_memory(); + puts( "" ); + test_untar_unzip_tgz(); TEST_END(); exit( 0 ); diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc index 1a8151c5f2..060f98a813 100644 --- a/testsuites/libtests/tar01/tar01.doc +++ b/testsuites/libtests/tar01/tar01.doc @@ -15,6 +15,7 @@ directives: + Untar_FromMemory + Untar_FromFile + Untar_ChunksFromMemory + + Untar_UnzipTgz concepts: diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn index 078cedffca..68fa951881 100644 --- a/testsuites/libtests/tar01/tar01.scn +++ b/testsuites/libtests/tar01/tar01.scn @@ -31,4 +31,15 @@ initial tar image. (0)This is a test of loading an RTEMS filesystem from an initial tar image. + +Untaring chunks from tgz- untar: dir: home +untar: file: home/test_file (73) +successful +========= /dest3/home/test_file ========= +(0)This is a test of loading an RTEMS filesystem from an +initial tar image. + +========= /dest3/symlink ========= +(0)This is a test of loading an RTEMS filesystem from an +initial tar image. *** END OF TAR01 TEST *** |