]> wimlib.net Git - wimlib/blobdiff - tests/win32-test-imagex-capture_and_apply.bat
Update Windows test script
[wimlib] / tests / win32-test-imagex-capture_and_apply.bat
index 6e2bebafd995c6169ae0a34b8de365fa51f72a99..cc19dd9803f2353bea10ad27f65c2e7ebd7019f9 100644 (file)
@@ -6,10 +6,12 @@ REM
 REM Run some tests on the Windows version of wimlib-imagex.\r
 REM\r
 REM This must be run on Windows Vista or later in a clean directory, with\r
-REM Administrator privileges.  wimlib-imagex and win32-tree-cmp must be callable\r
-REM (on PATH or in same directory).\r
+REM Administrator privileges.  wimlib-imagex and win32-tree-cmp must be\r
+REM executable using the paths set below.\r
 \r
 setlocal EnableDelayedExpansion\r
+set WIN32_TREE_CMP=win32-tree-cmp\r
+set WIMLIB_IMAGEX=wimlib-imagex\r
 \r
 if exist in.dir rd /S /Q in.dir\r
 if exist out.dir rd /S /Q out.dir\r
@@ -59,6 +61,12 @@ type nul > emptyfile
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+call :msg "hard linked empty file"\r
+type nul > file\r
+mklink /h link file > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
 call :msg "various hard linked, identical, different, and empty files"\r
 echo 1 > file\r
 echo 5 > file\r
@@ -85,6 +93,38 @@ type nul > subdir2\emptyfile
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+call :msg "file with custom security descriptor"\r
+echo hello > file\r
+icacls file /deny Administrator:F > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "directory with custom security descriptor (inheritence enabled)"\r
+md subdir\r
+icacls subdir /inheritance:e > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "directory with custom security descriptor (inheritence disabled)"\r
+md subdir\r
+icacls subdir /inheritance:d > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+REM            win32-tree-cmp can't handle this case.\r
+REM\r
+REM call :msg "file with custom security descriptor (all inherited ACEs removed)"\r
+REM echo hello > file\r
+REM icacls file /inheritance:r > nul\r
+REM call :do_test\r
+REM if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "file with custom integrity level"\r
+echo hello > file\r
+icacls file /setintegritylevel H > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
 call :msg "relative symlink"\r
 mklink relink dest > nul\r
 call :do_test\r
@@ -208,6 +248,18 @@ echo aaa > file2:aaa
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+call :msg "file with empty alternate data stream"\r
+echo 1 > file\r
+type nul > file:ads\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "directory with empty alternate data stream"\r
+md subdir\r
+type nul > subdir:ads\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
 call :msg "root directory with alternate data stream"\r
 echo 1 > ..\in.dir:ads\r
 call :do_test\r
@@ -257,12 +309,36 @@ attrib +h hidden
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+call :msg "hidden system file"\r
+echo 1 > file\r
+attrib +h +s file\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "hidden, readonly, system file"\r
+echo 1 > file\r
+attrib +h +r +s file\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
 call :msg "hidden directory"\r
 md subdir\r
 attrib +h subdir\r
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+call :msg "hidden system directory"\r
+md subdir\r
+attrib +h +s subdir\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "hidden, readonly, system directory"\r
+md subdir\r
+attrib +h +r +s subdir\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
 call :msg "encrypted file"\r
 echo "hello" > encrypted\r
 cipher /e encrypted > nul\r
@@ -291,13 +367,39 @@ cipher /e subdir\1 > nul
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
-REM call :msg "encrypted directory with unencrypted file in it"\r
-REM md subdir\r
-REM echo 1 > subdir\1\r
-REM cipher /e subdir > nul\r
-REM cipher /d subdir\1 > nul\r
-REM call :do_test\r
-REM if %errorlevel% neq 0 exit /b %errorlevel%\r
+call :msg "encrypted directory with unencrypted file in it"\r
+md subdir\r
+echo 1 > subdir\1\r
+cipher /e subdir > nul\r
+cipher /d subdir\1 > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "encrypted root directory"\r
+cd ..\r
+cipher /e in.dir > nul\r
+cd in.dir\r
+echo "hello" > encrypted\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "unencrypted file in encrypted directory in compressed directory"\r
+md 1\r
+md 1\2\r
+compact /c 1 > nul\r
+cipher /e 1\2 > nul\r
+echo hello > 1\2\file\r
+cipher /d 1\2\file > nul\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "encrypted directory with alternate data streams"\r
+md subdir\r
+cipher /e subdir > nul\r
+echo ads1 > subdir:ads1\r
+echo ads2 > subdir:ads2\r
+call :do_test\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
 call :msg "hardlinked, encrypted file with alternate data streams"\r
 echo hello > file\r
@@ -307,19 +409,53 @@ mklink /h link file > nul
 call :do_test\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
 \r
+:rpfix_tests\r
+\r
+echo Testing rpfix junction\r
+md subdir\r
+echo 1 > subdir\file\r
+mklink /j junction subdir > nul\r
+cd ..\r
+%WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
+rd /s /q in.dir\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
+echo 1 > tmp1\r
+type out.dir\junction\file > tmp2\r
+fc tmp1 tmp2 > nul\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+rd /s /q out.dir\r
+del tmp1 tmp2\r
+md in.dir\r
+cd in.dir\r
+\r
+echo Testing rpfix relative\r
+echo 1 > file\r
+mklink relink file > nul\r
+cd ..\r
+%WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
+fc in.dir\file out.dir\relink > nul\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+rd /s /q in.dir out.dir\r
+md in.dir\r
+cd in.dir\r
+\r
 REM\r
 REM END OF TESTS\r
 REM\r
 \r
+cd ..\r
+del test.wim\r
+rd /s /q in.dir\r
 exit /b 0\r
 \r
 :do_test\r
 cd ..\r
-wimlib-imagex capture in.dir test.wim --norpfix > NUL\r
+%WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
-wimlib-imagex apply test.wim out.dir > NUL\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
 if %errorlevel% neq 0 exit /b %errorlevel%\r
-win32-tree-cmp in.dir out.dir\r
+%WIN32_TREE_CMP% in.dir out.dir\r
 if %errorlevel% neq 0 (\r
        echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
        echo            TEST FAILED!!!!!!!\r
@@ -327,22 +463,16 @@ if %errorlevel% neq 0 (
        exit /b %errorlevel%\r
 )\r
 \r
-REM Fun fact:  There are bugs in Microsoft's imagex.exe that make it fail some\r
-REM of our tests.\r
-REM\r
-REM rd /S /Q out.dir\r
-REM md out.dir\r
-REM imagex /capture in.dir test.wim "test" /norpfix > nul\r
+REM Fun fact: Microsoft's WIMGAPI has bugs that make it fail some of our tests.\r
+REM Even the Windows 8.1 version has incorrect behavior with empty files with\r
+REM multiple links, or files with named data streams and multiple links.\r
+rd /S /Q out.dir\r
+md out.dir\r
+REM dism /capture-image /capturedir:in.dir /imagefile:test.wim /name:"test" /norpfix > nul\r
 REM if %errorlevel% neq 0 exit /b %errorlevel%\r
-REM imagex /apply test.wim 1 out.dir > nul\r
-REM if %errorlevel% neq 0 exit /b %errorlevel%\r
-REM win32-tree-cmp in.dir out.dir\r
-REM if %errorlevel% neq 0 (\r
-       REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
-       REM echo            TEST FAILED!!!!!!! ^(imagex^)\r
-       REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
-       REM exit /b %errorlevel%\r
-REM )\r
+dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
+if %errorlevel% neq 0 exit /b %errorlevel%\r
+%WIN32_TREE_CMP% in.dir out.dir\r
 \r
 rd /S /Q in.dir out.dir\r
 md in.dir\r