]> wimlib.net Git - wimlib/commitdiff
Add win32-test-imagex-capture_and_apply.bat
authorEric Biggers <ebiggers3@gmail.com>
Sat, 27 Apr 2013 04:16:49 +0000 (23:16 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 27 Apr 2013 04:16:49 +0000 (23:16 -0500)
tests/win32-test-imagex-capture_and_apply.bat [new file with mode: 0644]

diff --git a/tests/win32-test-imagex-capture_and_apply.bat b/tests/win32-test-imagex-capture_and_apply.bat
new file mode 100644 (file)
index 0000000..023beaf
--- /dev/null
@@ -0,0 +1,304 @@
+@echo off\r
+\r
+REM\r
+REM win32-test-imagex-capture_and_apply.bat\r
+REM\r
+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
+\r
+setlocal EnableDelayedExpansion\r
+\r
+if exist in.dir rd /S /Q in.dir\r
+if exist out.dir rd /S /Q out.dir\r
+md in.dir\r
+cd in.dir\r
+\r
+REM\r
+REM BEGIN TESTS\r
+REM\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 "various hard linked, identical, different, and empty files"\r
+echo 1 > file\r
+echo 5 > file\r
+mklink /h link1 file > nul\r
+mklink /h link2 file > nul\r
+type nul > emptyfile\r
+type nul > emptyfile2\r
+mklink /h emptyfilelink emptyfile > nul\r
+echo 5 > identicalfile\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\r
+md subdir3\r
+echo 1 > subdir1\1\r
+echo 5 > subdir1\5\r
+mklink /h link subdir1\1 > nul\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 "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
+mklink relink 1 > nul\r
+mklink rellinklink relink > nul\r
+mklink /j junction . > nul\r
+md subdir\r
+mklink /h subdir\hardlink 1 > nul\r
+echo "hello world!!!!" > hello\r
+mklink subdir\hello hello > nul\r
+mklink abslink C:\Users > nul\r
+md subdir2\r
+type nul > emptyfile\r
+type nul > subdir2\emptyfile\r
+md subdir2\s\r
+md subdir2\s\s\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 "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
+compact /C subdir > nul\r
+echo 1 > subdir\file1\r
+echo 2 > subdir\file2\r
+echo 1 > subdir\file1\r
+md subdir\subsubdir\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
+compact /C subdir > nul\r
+echo 1 > subdir\1\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 a > file:a\r
+echo aa > file:aa\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 a > file:a\r
+echo aa > file:aa\r
+echo aaa > file:aaa\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
+echo 5 > file2\r
+echo 1 > file:1\r
+echo 1 > file:1again\r
+echo aaa > file:aaa\r
+echo 5 > file:5\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 "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 "subdirectory with alternate data streams"\r
+md subdir\r
+echo 1 > subdir:1\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 hello > hello\r
+echo hello > subdir:hello\r
+echo hello > subdir:helloagain\r
+echo hello > helloagain\r
+mklink /h hellolink hello > nul\r
+echo 1 > helloagain:1\r
+echo 8 > helloagain:8\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
+echo test > .\1:test\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 1 > .\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
+REM\r
+REM END OF TESTS\r
+REM\r
+\r
+exit /b 0\r
+\r
+:do_test\r
+cd ..\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
+if %errorlevel% neq 0 exit /b %errorlevel%\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
+\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 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
+\r
+rd /S /Q in.dir out.dir\r
+md in.dir\r
+cd in.dir\r
+goto :eof\r
+\r
+:msg\r
+echo Testing capture and apply of %~1\r
+goto :eof\r