aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar/test
diff options
context:
space:
mode:
authorGravatar Rumou Duan <rduan@google.com>2016-05-12 15:31:07 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-05-12 15:50:07 +0000
commit7942bdc68896116ecdef6180a771095f7fe66a5e (patch)
treeb872726d7b266eb898541f181277c126e4099998 /third_party/ijar/test
parent438ff1677d3f7e5ebe89bf6281c86cd215466eef (diff)
Improvements to zipper extraction support (x option):
1. Add ability to specify relative output directory through -d option. 2. Add ability to specify a list of archive entries to extract from the zip file. Fixes #630. -- MOS_MIGRATED_REVID=122159723
Diffstat (limited to 'third_party/ijar/test')
-rwxr-xr-xthird_party/ijar/test/zip_test.sh36
1 files changed, 34 insertions, 2 deletions
diff --git a/third_party/ijar/test/zip_test.sh b/third_party/ijar/test/zip_test.sh
index 379f9b7891..719f70a908 100755
--- a/third_party/ijar/test/zip_test.sh
+++ b/third_party/ijar/test/zip_test.sh
@@ -32,8 +32,10 @@ source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
function assert_unzip_same_as_zipper() {
local folder1=$(mktemp -d ${TEST_TMPDIR}/output.XXXXXXXX)
local folder2=$(mktemp -d ${TEST_TMPDIR}/output.XXXXXXXX)
- (cd $folder1 && $UNZIP -q $1 || true) # ignore CRC32 errors
- (cd $folder2 && $ZIPPER x $1)
+ local zipfile=$1
+ shift
+ (cd $folder1 && $UNZIP -q $zipfile $@ || true) # ignore CRC32 errors
+ (cd $folder2 && $ZIPPER x $zipfile $@)
diff -r $folder1 $folder2 &> $TEST_log \
|| fail "Unzip and Zipper resulted in different output"
}
@@ -93,6 +95,36 @@ function test_zipper() {
expect_not_log "path"
}
+function test_zipper_unzip_selective_files() {
+ mkdir -p ${TEST_TMPDIR}/test/path/to/some
+ mkdir -p ${TEST_TMPDIR}/test/some/other/path
+ touch ${TEST_TMPDIR}/test/path/to/some/empty_file
+ echo "toto" > ${TEST_TMPDIR}/test/path/to/some/file
+ echo "titi" > ${TEST_TMPDIR}/test/path/to/some/other_file
+ chmod +x ${TEST_TMPDIR}/test/path/to/some/other_file
+ echo "tata" > ${TEST_TMPDIR}/test/file
+ filelist="$(cd ${TEST_TMPDIR}/test && find . | sed 's|^./||' | grep -v '^.$')"
+
+ assert_zipper_same_after_unzip ${TEST_TMPDIR}/test ${filelist}
+ assert_unzip_same_as_zipper ${TEST_TMPDIR}/output.zip \
+ path/to/some/empty_file path/to/some/other_file
+}
+
+function test_zipper_unzip_to_optional_dir() {
+ mkdir -p ${TEST_TMPDIR}/test/path/to/some
+ mkdir -p ${TEST_TMPDIR}/test/some/other/path
+ touch ${TEST_TMPDIR}/test/path/to/some/empty_file
+ echo "toto" > ${TEST_TMPDIR}/test/path/to/some/file
+ echo "titi" > ${TEST_TMPDIR}/test/path/to/some/other_file
+ chmod +x ${TEST_TMPDIR}/test/path/to/some/other_file
+ echo "tata" > ${TEST_TMPDIR}/test/file
+ filelist="$(cd ${TEST_TMPDIR}/test && find . | sed 's|^./||' | grep -v '^.$')"
+
+ assert_zipper_same_after_unzip ${TEST_TMPDIR}/test ${filelist}
+ assert_unzip_same_as_zipper ${TEST_TMPDIR}/output.zip -d output_dir2 \
+ path/to/some/empty_file path/to/some/other_file
+}
+
function test_zipper_compression() {
echo -n > ${TEST_TMPDIR}/a
for i in $(seq 1 1000); do