]> wimlib.net Git - wimlib/blobdiff - tests/test-imagex-capture_and_apply
rpfix capture on UNIX
[wimlib] / tests / test-imagex-capture_and_apply
index 1dfc9431568662f92613753be8ba9e58b1bd30a4..d4577517c40865e1a793600a1f308535166535f9 100755 (executable)
@@ -14,39 +14,10 @@ srcdir="${srcdir:-.}/.."
 srcdir="$(cd $srcdir; pwd)"
 . "$srcdir/tests/tests-common.sh"
 
-
-imagex() {
-       echo "imagex $@"
-       ../imagex "$@" > /dev/null
-}
-
-imagex_info() {
-       echo "imagex info $@"
-       ../imagex info "$@"
-}
-
-init() {
-       mkdir in.dir out.dir
-}
-
-cleanup() {
-       rm -rf in.dir out.dir test*.wim test*.swm
-}
-
-error() {
-       echo "****************************************************************"
-       echo "                         Test failure                           "
-       echo $*
-       echo "****************************************************************"
-       exit 1
-}
-
-wim_ctype() {
-       ../imagex info $1 | grep Compression | awk '{print $2}'
-}
+TEST_SUBDIR=tmpdir_test-imagex-capture_and_apply
 
 do_tree_cmp() {
-       if ! ./tree-cmp in.dir out.dir; then
+       if ! ../tree-cmp in.dir out.dir; then
                if [ -x /usr/bin/tree ]; then
                        echo "Dumping tree of applied image"
                        echo "(Note: compression type was $ctype)"
@@ -59,7 +30,7 @@ do_tree_cmp() {
 
 image_name=0
 do_test() {
-       for ctype in None LZX XPRESS; do
+       for ctype in None XPRESS LZX; do
 
                # Can we capture the WIM, apply it, and get the same result?
                cd in.dir
@@ -126,8 +97,10 @@ msg() {
        __msg "Testing image capture and application of directory containing $1"
 }
 
-cleanup
-init
+default_cleanup
+mkdir $TEST_SUBDIR
+cd $TEST_SUBDIR
+mkdir in.dir out.dir
 
 . $srcdir/tests/common_tests.sh
 
@@ -140,10 +113,39 @@ imagex apply test.wim out.dir
 if [ -e out.dir/hiberfil.sys -o -e "out.dir/System Volume Information" ]; then
        error "Files were not excluded from capture as expected"
 fi
-rm -rf out.dir/* in.dir/*
 
-cleanup
+__msg "Testing --rpfix"
+rm -r in.dir out.dir
+mkdir in.dir
+ln -s $PWD/in.dir          in.dir/absrootlink
+ln -s $PWD/in.dir////      in.dir/absrootlinkslashes
+ln -s /___NONEXISTENT___   in.dir/absnonexistent
+ln -s /usr/bin/env         in.dir/absoutoftree
+ln -s file                 in.dir/relalink
+ln -s $PWD/in.dir/file     in.dir/abslink
+ln -s $PWD/in.dir/file///  in.dir/abslinkslashes
+imagex capture --rpfix in.dir test.wim
+imagex apply --norpfix test.wim out.dir
+if [[ `readlink out.dir/absrootlink` != "/" ]] ||
+   [[ `readlink out.dir/absrootlinkslashes` != "////" ]]; then
+       error "imagex capture --rpfix failed to fix absolute link to capture root"
+fi
+
+if [[ -e out.dir/absnonexistent ]] ||
+   [[ -e out.dir/absoutoftree ]]; then
+       error "imagex capture --rpfix failed to exclude out of tree absolute links"
+fi
+if [[ `readlink out.dir/relalink` != "file" ]]; then
+       error "imagex capture --rpfix failed to capture relative symlink"
+fi
+if [[ `readlink out.dir/abslink` != "/file" ]] ||
+   [[ `readlink out.dir/abslinkslashes` != "/file///" ]]; then
+       error "imagex capture --rpfix did fix absolute link properly"
+fi
 
 echo "**********************************************************"
 echo "          imagex capture/apply tests passed               "
 echo "**********************************************************"
+
+cd ..
+default_cleanup