]> wimlib.net Git - wimlib/blobdiff - tests/test-imagex-update_and_extract
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / tests / test-imagex-update_and_extract
index 745c98f6a7196c508a9b37baf6e80e8adf5c9435..721954df10584d1fd057af21505516431e8d8186 100755 (executable)
@@ -6,7 +6,7 @@ set -e
 cd tests
 srcdir="${srcdir:-.}/.."
 srcdir="$(cd $srcdir; pwd)"
-. "$srcdir/tests/tests-common.sh"
+. "$srcdir/tests/test_utils.sh"
 
 TEST_SUBDIR=tmpdir_test-imagex-update_and_extract
 
@@ -24,7 +24,7 @@ fail() {
        msg "TEST FAILED (See above)"
 }
 
-trap fail exit
+trap fail EXIT
 
 prepare_empty_wim() {
        rm -rf in.dir
@@ -116,7 +116,28 @@ wimupdate test.wim << EOF
 rename file newname
 EOF
 do_apply
-../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
+../tree-cmp file out.dir/newname
+[ ! -e out.dir/file ]
+
+prepare_empty_wim
+msg "Testing UTF-16LE-NOBOM command update file"
+echo -ne 'a\0d\0d\0 \0f\0i\0l\0e\0 \0/\0f\0i\0l\0e\0\n\0' \
+       | wimupdate test.wim
+do_apply
+../tree-cmp file out.dir/file
+
+prepare_empty_wim
+msg "Testing UTF-16LE-BOM command update file"
+echo -ne '\xff\xfea\0d\0d\0 \0f\0i\0l\0e\0 \0/\0f\0i\0l\0e\0\n\0' \
+       | wimupdate test.wim
+do_apply
+../tree-cmp file out.dir/file
+
+prepare_empty_wim
+msg "Testing UTF-8-BOM command update file"
+echo -ne '\xef\xbb\xbfadd file /file' | wimupdate test.wim
+do_apply
+../tree-cmp file out.dir/file
 
 prepare_empty_wim
 msg "Testing adding, then renaming file in WIM image in one command"
@@ -125,7 +146,8 @@ add file /file
 rename /file /newname
 EOF
 do_apply
-../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
+../tree-cmp file out.dir/newname
+[ ! -e out.dir/file ]
 
 msg "Testing adding additional file to WIM image"
 prepare_empty_wim
@@ -136,21 +158,28 @@ wimupdate test.wim << EOF
 add file /file
 EOF
 do_apply
-[ -e out.dir/1 ] && [ -e out.dir/file ]
+[ -e out.dir/1 ]
+[ -e out.dir/file ]
 
 msg "Testing extracting file from WIM image"
-rm -rf out.dir && mkdir out.dir
+rm -rf out.dir
+mkdir out.dir
 wimextract test.wim 1 /file --dest-dir=out.dir
-../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
+../tree-cmp file out.dir/file
+[ ! -e out.dir/1 ]
 
 msg "Testing extracting file from WIM image to stdout"
-rm -rf out.dir && mkdir out.dir
+rm -rf out.dir
+mkdir out.dir
 wimlib_imagex extract test.wim 1 /file --to-stdout > out.dir/file
-../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
+cmp file out.dir/file
+[ ! -e out.dir/1 ]
 
 msg "Testing adding directories and files to WIM image"
-rm -rf dir1 && mkdir dir1
-rm -rf dir2 && mkdir dir2
+rm -rf dir1
+mkdir dir1
+rm -rf dir2
+mkdir dir2
 echo 5 > dir1/5
 echo 6 > dir2/6.1
 echo 6 > dir2/6
@@ -164,23 +193,26 @@ wimupdate test.wim 1 << EOF
 add dir1 /dir1
 add dir2 /prefix/dir2
 EOF
-rm -rf out.dir && mkdir out.dir
+rm -rf out.dir
+mkdir out.dir
 wimextract test.wim 1 dir1 --dest-dir=out.dir
 wimextract test.wim 1 prefix/dir2 --dest-dir=out.dir
 ../tree-cmp dir1 out.dir/dir1
 ../tree-cmp dir2 out.dir/dir2
 
 msg "Testing adding files to WIM image"
-rm -rf in.dir && mkdir in.dir
+rm -rf in.dir
+mkdir in.dir
 wimappend in.dir test.wim "2"
 cp $srcdir/src/*.c in.dir
 wimupdate test.wim 2 << EOF
 add in.dir /
 add file /file
 EOF
-cp file in.dir/file
+cp -a file in.dir/file
 rm -rf out.dir
 wimapply test.wim 2 out.dir
+touch -r in.dir out.dir
 ../tree-cmp in.dir out.dir
 
 msg "Testing adding file with space in it"
@@ -213,6 +245,16 @@ wimextract test.wim 1 @pathlist --dest-dir=out.dir
 ../tree-cmp hello2 out.dir/hello2
 [ ! -e out.dir/otherfile ]
 
+msg "Testing path list extract (stdin)"
+rm -rf out.dir
+wimextract test.wim 1 @- --dest-dir=out.dir << EOF
+hello1
+hello2
+EOF
+../tree-cmp hello1 out.dir/hello1
+../tree-cmp hello2 out.dir/hello2
+[ ! -e out.dir/otherfile ]
+
 msg "Testing path list extract (w/ wildcard)"
 cat > pathlist << EOF
 hello*
@@ -285,7 +327,7 @@ WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir -
 echo "**********************************************************"
 echo "          wimupdate/extract tests passed              "
 echo "**********************************************************"
-trap exit
+trap EXIT
 
 cd ..
 default_cleanup