]> wimlib.net Git - wimlib/commitdiff
tests: test capturing+applying file with negative UNIX timestamp
authorEric Biggers <ebiggers3@gmail.com>
Wed, 19 Apr 2017 06:58:03 +0000 (23:58 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 19 Apr 2017 07:17:01 +0000 (00:17 -0700)
... and start comparing mtime in tree-cmp, and fix cases where return
codes in scripts were being ignored by use of '&&'.

tests/common_tests.sh
tests/test-imagex-update_and_extract
tests/tree-cmp.c

index 4aaeadbfd08e5afb7911566d764649e3d6f60e91..68ccba6228ea47263f5e806dd9f652be6dcde6fb 100644 (file)
@@ -69,3 +69,6 @@ do_test 'echo -n 8 > file;
         ln file dir/subdir/file;
         echo -n 8 > dir/subdir/file2;
         ln dir/subdir/file dir/subdir/link;'
+
+ msg "timestamp before 1970 (before start of UNIX epoch)"
+ do_test 'touch -t 196901231234.56 file'
index ddeea3ff474d2d7a21f491c8465e5afc95f43a79..202371b1027de6d14121b293997b16f2d4e1dddf 100755 (executable)
@@ -116,7 +116,8 @@ 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 adding, then renaming file in WIM image in one command"
@@ -125,7 +126,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 +138,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 +173,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"
index 1fed0234cccbd07044364ec07cadea53e25117ba..4b70a8308277c5aa15a3055064a79293e5656fec 100644 (file)
@@ -323,16 +323,14 @@ static void tree_cmp(char file1[], int file1_len, char file2[], int file2_len)
                           file1, file2);
 #if 0
        if (ntfs_mode && st1.st_atime != st2.st_atime)
-               difference("Access times of `%s' and `%s' are not the same",
-                          file1, file2);
+               difference("Access times of `%s' (%x) and `%s' (%x) are "
+                          "not the same",
+                          file1, st1.st_atime, file2, st2.st_atime);
+#endif
        if (st1.st_mtime != st2.st_mtime)
                difference("Modification times of `%s' (%x) and `%s' (%x) are "
                           "not the same",
                           file1, st1.st_mtime, file2, st2.st_mtime);
-       if (st1.st_ctime != st2.st_ctime)
-               difference("Status change times of `%s' and `%s' are not the same",
-                          file1, file2);
-#endif
        if ((ntfs_mode || S_ISREG(st1.st_mode)) && st1.st_nlink != st2.st_nlink)
                difference("Link count of `%s' (%u) and `%s' (%u) "
                           "are not the same",