3 # Test capturing and applying a WIM image in the normal (non-NTFS) capture mode
5 # Add in some tests with WIM splitting, joining, and exporting as well.
7 # Test all three compression modes (None, XPRESS, and LZX).
9 # Also, test if the capture configuration file works correctly.
13 srcdir="${srcdir:-.}/.."
14 srcdir="$(cd $srcdir; pwd)"
15 . "$srcdir/tests/tests-common.sh"
17 TEST_SUBDIR=tmpdir_test-imagex-capture_and_apply
20 if ! ../tree-cmp in.dir out.dir; then
21 if [ -x /usr/bin/tree ]; then
22 echo "Dumping tree of applied image"
23 echo "(Note: compression type was $ctype)"
24 tree out.dir --inodes -F -s --noreport
25 error 'Information was lost or corrupted while capturing
26 and then applying a directory tree'
33 for ctype in None XPRESS LZX; do
35 # Can we capture the WIM, apply it, and get the same result?
39 if [ -x /usr/bin/tree -a "$ctype" = "None" ]; then
40 tree in.dir --inodes -F -s --noreport
42 if ! imagex capture in.dir test.wim --compress=$ctype; then
43 error "Failed to capture directory tree into a WIM"
45 if ! imagex apply test.wim 1 out.dir; then
46 error "Failed to apply WIM to directory"
48 if [ `wim_ctype test.wim` != $ctype ]; then
49 error "'imagex info' didn't report the compression type on the captured WIM correctly"
54 # Can we split the WIM, apply the split WIM, join the split WIM,
55 # and apply the joined WIM, and get the same results every time?
56 if ! imagex split test.wim test.swm 0.01; then
57 error "Failed to split WIM"
59 if ! imagex apply test.swm 1 out.dir --ref "test*.swm" ; then
60 error "Failed to apply split WIM"
63 rm -rf out.dir/* test.wim
64 if ! imagex join test.wim test*.swm; then
65 error "Failed to join split WIM"
67 if ! imagex apply test.wim out.dir; then
68 error "Failed to apply joined WIM"
73 # Can we export the image to another WIM, apply it, and get the
75 (( image_name++ )) || true
76 if ! imagex export test.wim 1 test2.wim "$image_name"; then
77 error "Failed to export WIM image"
80 if ! imagex apply test2.wim "$image_name" out.dir; then
81 error "Failed to apply exported WIM image"
85 rm -rf out.dir/* in.dir/* test.wim test*.swm
91 echo "--------------------------------------------------------------------"
93 echo "--------------------------------------------------------------------"
97 __msg "Testing image capture and application of directory containing $1"
105 . $srcdir/tests/common_tests.sh
107 # Make sure exclusion list works
108 __msg "Testing default capture configuration file"
109 touch in.dir/hiberfil.sys
110 mkdir -p "in.dir/System Volume Information/subdir"
111 imagex capture in.dir test.wim
112 imagex apply test.wim out.dir
113 if [ -e out.dir/hiberfil.sys -o -e "out.dir/System Volume Information" ]; then
114 error "Files were not excluded from capture as expected"
117 __msg "Testing --rpfix"
120 ln -s $PWD/in.dir in.dir/absrootlink
121 ln -s $PWD/in.dir//// in.dir/absrootlinkslashes
122 ln -s /___NONEXISTENT___ in.dir/absnonexistent
123 ln -s /usr/bin/env in.dir/absoutoftree
124 ln -s file in.dir/relalink
125 ln -s $PWD/in.dir/file in.dir/abslink
126 ln -s $PWD/in.dir/file/// in.dir/abslinkslashes
127 imagex capture --rpfix in.dir test.wim
128 imagex apply --norpfix test.wim out.dir
129 if [[ `readlink out.dir/absrootlink` != "/" ]] ||
130 [[ `readlink out.dir/absrootlinkslashes` != "////" ]]; then
131 error "imagex capture --rpfix failed to fix absolute link to capture root"
134 if [[ -e out.dir/absnonexistent ]] ||
135 [[ -e out.dir/absoutoftree ]]; then
136 error "imagex capture --rpfix failed to exclude out of tree absolute links"
138 if [[ `readlink out.dir/relalink` != "file" ]]; then
139 error "imagex capture --rpfix failed to capture relative symlink"
141 if [[ `readlink out.dir/abslink` != "/file" ]] ||
142 [[ `readlink out.dir/abslinkslashes` != "/file///" ]]; then
143 error "imagex capture --rpfix did fix absolute link properly"
147 imagex apply test.wim out.dir
148 if [[ $(get_inode_number $(readlink out.dir/absrootlink)) != \
149 $(get_inode_number out.dir) ]];
151 error "imagex apply failed to apply fixed absolute symlinks"
154 echo "**********************************************************"
155 echo " imagex capture/apply tests passed "
156 echo "**********************************************************"