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
+set WIN32_TREE_CMP=win32-tree-cmp\r
+set SET_REPARSE_POINT=set_reparse_point\r
\r
if exist in.dir rd /S /Q in.dir\r
if exist out.dir rd /S /Q out.dir\r
\r
call :msg "empty directory"\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "single file"\r
echo 1 > file\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "different files"\r
echo 1 > file\r
echo 2 > anotherfile\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "identical files"\r
echo 1 > file\r
echo 1 > identicalfile\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "hard linked file"\r
echo 1 > file\r
mklink /h link file > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "hard linked file, with other identical files"\r
echo 1 > file\r
mklink /h link file > nul\r
echo 1 > identicalfile\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "empty file"\r
type nul > emptyfile\r
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 1 > 1file\r
mklink /h 1filelink 1file > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "multiple subdirectories, some empty, some not"\r
md subdir1\r
md subdir2\subdir2subdir\r
type nul > subdir2\emptyfile\r
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 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
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "absolute symlink, with drive letter"\r
mklink abslink C:\absolute\target > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "absolute symlink, without drive letter"\r
mklink abslink \absolute\target > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "relative symlink, with file target"\r
echo 1 > 1\r
mklink relink 1 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "relative symlink, with directory target"\r
md subdir\r
mklink reldlink subdir > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "junction"\r
md subdir\r
mklink /j junction subdir > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "symlinks, junctions, files, subdirectories, etc."\r
echo 1 > 1\r
md subdir2\s\s\s\r
echo "hello world!!!!" > subdir2\otherfile\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "reparse point that is neither a symlink nor a junction"\r
+type nul > file\r
+%SET_REPARSE_POINT% file\r
+call :do_test\r
+\r
+call :msg "reparse point with named data streams"\r
+type nul > file\r
+echo 11 > file:a\r
+echo 1 > file:aa\r
+%SET_REPARSE_POINT% file\r
+call :do_test\r
+\r
+call :msg "reparse point with unnamed data stream"\r
+echo "test" > file\r
+%SET_REPARSE_POINT% file\r
+call :do_test\r
+\r
+call :msg "reparse point with unnamed data stream and named data streams"\r
+echo "test" > file\r
+echo 11 > file:a\r
+echo 1 > file:aa\r
+%SET_REPARSE_POINT% file\r
+call :do_test\r
+\r
+call :msg "empty reparse point"\r
+type nul > file\r
+%SET_REPARSE_POINT% file 0\r
+call :do_test\r
+\r
+call :msg "empty reparse point with unnamed data stream"\r
+echo hello > file\r
+%SET_REPARSE_POINT% file 0\r
+call :do_test\r
+\r
+call :msg "empty reparse point with unnamed data stream and named data streams"\r
+echo hello > file\r
+echo hello > file:ads1\r
+type nul > file:ads2\r
+%SET_REPARSE_POINT% file 0\r
+call :do_test\r
+\r
+call :msg "maximum length reparse point"\r
+type nul > file\r
+%SET_REPARSE_POINT% file 16376\r
+call :do_test\r
+\r
+call :msg "directory reparse point that is neither a symlink nor a junction"\r
+md subdir\r
+%SET_REPARSE_POINT% subdir\r
+call :do_test\r
+\r
+call :msg "directory reparse point with named data streams"\r
+md subdir\r
+echo 11 > subdir:a\r
+echo 1 > subdir:aa\r
+%SET_REPARSE_POINT% subdir\r
+call :do_test\r
\r
call :msg "compressed file"\r
echo "test" > test\r
compact /C test > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "compressed directory"\r
md subdir\r
compact /C subdir > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "compressed directory with files in it"\r
md subdir\r
mklink /h subdir\hardlink subdir\file1 > nul\r
mklink /j subdir\j subdir\subsubdir > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "compressed directory with some uncompressed files in it"\r
md subdir\r
echo 5 > subdir\5\r
compact /U subdir\1 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "file with alternate data stream"\r
echo 1 > file\r
echo 5 > file:ads\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "file with multiple alternate data streams"\r
echo 1 > file\r
echo aaa > file:aaa\r
echo aaaa > file:aaaa\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "file with multiple alternate data streams, with hard link"\r
echo 1 > file\r
echo aaaa > file:aaaa\r
mklink /h link file > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "files with multiple alternate data streams, some identical, with hard link"\r
echo 1 > file\r
mklink /h link file > nul\r
echo aaa > file2:aaa\r
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
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+call :msg "root directory with empty alternate data stream"\r
+type nul > ..\in.dir:ads\r
+call :do_test\r
\r
call :msg "subdirectory with alternate data streams"\r
md subdir\r
echo 2 > subdir:2\r
echo 2 > subdir:2again\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "subdirectories and files with alternate data streams"\r
md subdir\r
echo 1 > 1\r
type nul > helloagain:dummy\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "symbolic link and hard link, to file with alternate data streams"\r
echo 1 > 1\r
mklink symlink 1 > nul\r
mklink /h hardlink 1 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "compressed file with alternate data streams"\r
echo 1 > 1\r
echo 2 > .\1:2\r
compact /C 1 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "hidden file"\r
echo 1 > hidden\r
attrib +h hidden\r
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 "readonly directory with named data stream"\r
+md subdir\r
+echo foo > subdir:ads\r
+attrib +r subdir\r
+call :do_test\r
\r
call :msg "encrypted file"\r
echo "hello" > encrypted\r
cipher /e encrypted > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "identical encrypted files"\r
echo "hello" > encrypted1\r
cipher /e encrypted1 > nul\r
cipher /e encrypted2 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "encrypted directory"\r
md subdir\r
cipher /e subdir > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "encrypted directory with encrypted file in it"\r
md subdir\r
cipher /e subdir > nul\r
cipher /e subdir\1 > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
\r
call :msg "encrypted directory with unencrypted file in it"\r
md subdir\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
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
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
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
cipher /e file > nul\r
mklink /h link file > nul\r
call :do_test\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+\r
+REM Note: since object IDs must be unique per filesystem, we can't expect them\r
+REM to preserved using our testing scheme. Therefore, win32-tree-cmp doesn't\r
+REM compare them, and the below tests really just ensure the object ID code is\r
+REM run to some extent.\r
+\r
+call :msg "file with object ID"\r
+echo hello > file\r
+fsutil objectid create file > nul\r
+call :do_test\r
+\r
+call :msg "directory with object ID"\r
+md subdir\r
+fsutil objectid set f67394c12b17608e1d050d181ba8ffd2 7df80cbdf620f4c82c79b9e6799147b6 97621aff72915ade05abb96b15dea1a3 e0bda4caa9e33cfd461c92c16be9713d subdir\r
+call :do_test\r
+\r
+call :msg "sparse files"\r
+fsutil file createnew sparse 1000000 > nul\r
+fsutil sparse setflag sparse\r
+fsutil sparse setrange sparse 0 1000000\r
+\r
+fsutil file createnew mostly_sparse 1000000 > nul\r
+fsutil sparse setflag mostly_sparse\r
+fsutil sparse setrange mostly_sparse 0 1000000\r
+echo hello >> mostly_sparse\r
+type sparse >> mostly_sparse\r
+fsutil sparse setrange mostly_sparse 1000100 2000000\r
+call :do_test\r
+\r
+call :msg "sparse and compressed files"\r
+fsutil file createnew sparse 1000000 > nul\r
+fsutil sparse setflag sparse\r
+fsutil sparse setrange sparse 0 1000000\r
+compact /c sparse > nul\r
+\r
+fsutil file createnew mostly_sparse 1000000 > nul\r
+fsutil sparse setflag mostly_sparse\r
+fsutil sparse setrange mostly_sparse 0 1000000\r
+echo hello >> mostly_sparse\r
+type sparse >> mostly_sparse\r
+fsutil sparse setrange mostly_sparse 1000100 2000000\r
+compact /c mostly_sparse > nul\r
+\r
+type nul > compressed_first\r
+compact /c compressed_first > nul\r
+type sparse >> compressed_first\r
+fsutil sparse setflag compressed_first\r
+fsutil sparse setrange compressed_first 0 500000\r
+call :do_test\r
\r
:rpfix_tests\r
\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
+if %errorlevel% neq 0 goto :fail\r
rd /s /q out.dir\r
del tmp1 tmp2\r
md in.dir\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
+type out.dir\relink > out.dir\tmp\r
+if %errorlevel% neq 0 goto :fail\r
+fc in.dir\file out.dir\tmp > nul\r
+if %errorlevel% neq 0 goto :fail\r
rd /s /q in.dir out.dir\r
md in.dir\r
cd in.dir\r
:do_test\r
cd ..\r
%WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+if %errorlevel% neq 0 goto :fail\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
+if %errorlevel% neq 0 goto :fail\r
+%WIN32_TREE_CMP% in.dir out.dir\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+REM apply a second time so we test the case where the files already exist\r
%WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+if %errorlevel% neq 0 goto :fail\r
%WIN32_TREE_CMP% in.dir out.dir\r
-if %errorlevel% neq 0 (\r
- echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- echo TEST FAILED!!!!!!!\r
- echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- exit /b %errorlevel%\r
-)\r
+if %errorlevel% neq 0 goto :fail\r
\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
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 if %errorlevel% neq 0 goto :fail\r
dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
+if %errorlevel% neq 0 goto :fail\r
%WIN32_TREE_CMP% in.dir out.dir\r
\r
rd /S /Q in.dir out.dir\r
:msg\r
echo Testing capture and apply of %~1\r
goto :eof\r
+\r
+:fail\r
+echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
+echo TEST FAILED!!!!!!!\r
+echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
+exit %errorlevel%\r