]> wimlib.net Git - wimlib/blobdiff - tests/test-imagex
Test suite: Allow out of directory build
[wimlib] / tests / test-imagex
index f1f2154ad70ed2d81a584d69820271b6fac3839b..a0b88a9658e948c7f452d972622aae07ed15621a 100755 (executable)
@@ -3,13 +3,13 @@
 # This script does some sanity testing of the 'imagex' program.  It by no means
 # tests every aspect of wimlib comprehensively.
 
-# Assume an in-tree build.
 set -e
+srcdir=`realpath $srcdir`
 cd tests
 
 imagex() {
        echo "imagex $@"
-       ../imagex $@
+       ../imagex $@ 
 }
 
 cleanup() {
@@ -19,10 +19,12 @@ cleanup() {
        rm -rf dir* tmp* *.wim *.swm
 }
 trap cleanup exit
+fusermount -u tmp || true
+rm -rf tmp || true
 
 # Make test directory
 mkdir dir
-cp ../src/*.c ../src/*.h dir
+cp $srcdir/src/*.c $srcdir/src/*.h dir
 mkdir dir/subdir
 echo 'hello' > dir/subdir/hello
 echo 'hello' > dir/subdir/hello2
@@ -258,12 +260,14 @@ echo "Testing appending non-existent file (should generate errors)"
 if imagex append SOME_NONEXISTENT_FILE dir.wim; then
        error "Incorrectly succeeded to append non-existent file to WIM"
 fi
-echo "Testing appending directory containing unreadable file (should generate errors)"
-mkdir -p dir3
-echo 1 > dir3/file
-chmod -r dir3/file
-if imagex append dir3 dir.wim; then
-       error "Incorrectly succeeded in capturing directory with unreadable file"
+if [ `id -u` != 0 ]; then
+       echo "Testing appending directory containing unreadable file (should generate errors)"
+       mkdir -p dir3
+       echo 1 > dir3/file
+       chmod -r dir3/file
+       if imagex append dir3 dir.wim; then
+               error "Incorrectly succeeded in capturing directory with unreadable file"
+       fi
 fi
 rm -rf dir3 dir.wim
 
@@ -359,7 +363,7 @@ fi
 if test "`stat -c %i tmp/subdir/hello`" = "`stat -c %i tmp/subdir/hello2`"; then
        error "Incorrect inode number"
 fi
-if ! test -L tmp/subdir/hello || ! test -L tmp/subdir/hello2; then
+if ! test -L tmp/subdir/hello -o -L tmp/subdir/hello2 -o -L tmp/subdir/hellolink; then
        error "Expected symlinks, but found non-symlinks"
 fi
 rm -rf dir.wim tmp
@@ -608,5 +612,5 @@ if imagex export dir.wim all new.wim --boot; then
 fi
 
 echo "**********************************************************"
-echo "                     All tests passed                     "
+echo "                 Basic imagex tests passed                "
 echo "**********************************************************"