From: Eric Biggers Date: Mon, 10 Apr 2023 00:02:21 +0000 (-0700) Subject: Fix win32-test-imagex-capture_and_apply.bat and add to CI X-Git-Tag: v1.14.0~3 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=9811a0b1088004bf2b8631d22cc8a2626b15c3b4;p=wimlib Fix win32-test-imagex-capture_and_apply.bat and add to CI --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 897d8fb9..d7919922 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,6 +169,30 @@ jobs: name: windows-${{matrix.msystem}}-bin path: wimlib-*-bin + win32-test-imagex-capture-and-apply: + name: Run win32-test-imagex-capture_and_apply.bat + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Need tags for tools/get-version-number.sh + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: > + autoconf + automake + git + libtool + make + mingw-w64-x86_64-gcc + pkgconf + - run: tests/win32-test-imagex-capture_and_apply.sh + fuzz-with-libFuzzer: name: Fuzz with libFuzzer (${{matrix.target}} ${{matrix.sanitizer}}) strategy: diff --git a/tests/win32-test-imagex-capture_and_apply.bat b/tests/win32-test-imagex-capture_and_apply.bat index 9cb97bd3..8af2fa3f 100644 --- a/tests/win32-test-imagex-capture_and_apply.bat +++ b/tests/win32-test-imagex-capture_and_apply.bat @@ -5,14 +5,13 @@ REM win32-test-imagex-capture_and_apply.bat REM REM Run some tests on the Windows version of wimlib-imagex. REM -REM This must be run in a clean directory, with Administrator privileges. -REM wimlib-imagex, win32-tree-cmp, and set_reparse_point must be executable -REM using the paths set below. +REM This must be run with Administrator privileges, in a directory containing +REM the wimlib-imagex, win32-tree-cmp, and set_reparse_point programs. setlocal EnableDelayedExpansion -set WIMLIB_IMAGEX=wimlib-imagex -set WIN32_TREE_CMP=win32-tree-cmp -set SET_REPARSE_POINT=set_reparse_point +set WIMLIB_IMAGEX=%cd%\wimlib-imagex +set WIN32_TREE_CMP=%cd%\win32-tree-cmp +set SET_REPARSE_POINT=%cd%\set_reparse_point if exist in.dir rd /S /Q in.dir if exist out.dir rd /S /Q out.dir @@ -58,7 +57,8 @@ call :do_test call :msg "hard linked empty file" type nul > file mklink /h link file > nul -call :do_test +REM Use skip_dism_cmp=1 due to DISM bug +call :do_test_with_params 0 1 call :msg "various hard linked, identical, different, and empty files" echo 1 > file @@ -71,7 +71,8 @@ mklink /h emptyfilelink emptyfile > nul echo 5 > identicalfile echo 1 > 1file mklink /h 1filelink 1file > nul -call :do_test +REM Use skip_dism_cmp=1 due to DISM bug +call :do_test_with_params 0 1 call :msg "multiple subdirectories, some empty, some not" md subdir1 @@ -84,10 +85,12 @@ md subdir2\subdir2subdir type nul > subdir2\emptyfile call :do_test -call :msg "file with custom security descriptor" -echo hello > file -icacls file /deny Administrator:F > nul -call :do_test +REM FIXME: win32-tree-cmp can't handle this case. +REM +REM call :msg "file with custom security descriptor" +REM echo hello > file +REM icacls file /deny Administrator:F > nul +REM call :do_test call :msg "directory with custom security descriptor (inheritence enabled)" md subdir @@ -99,7 +102,7 @@ md subdir icacls subdir /inheritance:d > nul call :do_test -REM win32-tree-cmp can't handle this case. +REM FIXME: win32-tree-cmp can't handle this case. REM REM call :msg "file with custom security descriptor (all inherited ACEs removed)" REM echo hello > file @@ -109,7 +112,8 @@ REM call :do_test call :msg "file with custom integrity level" echo hello > file icacls file /setintegritylevel H > nul -call :do_test +REM Use skip_dism_cmp=1 due to DISM bug +call :do_test_with_params 0 1 call :msg "relative symlink" mklink relink dest > nul @@ -172,14 +176,16 @@ call :do_test call :msg "reparse point with unnamed data stream" echo "test" > file %SET_REPARSE_POINT% file -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "reparse point with unnamed data stream and named data streams" echo "test" > file echo 11 > file:a echo 1 > file:aa %SET_REPARSE_POINT% file -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "empty reparse point" type nul > file @@ -196,7 +202,8 @@ echo hello > file echo hello > file:ads1 type nul > file:ads2 %SET_REPARSE_POINT% file 0 -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "maximum length reparse point" type nul > file @@ -285,22 +292,26 @@ call :do_test call :msg "directory with empty alternate data stream" md subdir type nul > subdir:ads -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "root directory with alternate data stream" echo 1 > ..\in.dir:ads -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "root directory with empty alternate data stream" type nul > ..\in.dir:ads -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "subdirectory with alternate data streams" md subdir echo 1 > subdir:1 echo 2 > subdir:2 echo 2 > subdir:2again -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "subdirectories and files with alternate data streams" md subdir @@ -313,14 +324,16 @@ echo 1 > helloagain:1 echo 8 > helloagain:8 echo 1 > 1 type nul > helloagain:dummy -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "symbolic link and hard link, to file with alternate data streams" echo 1 > 1 echo test > .\1:test mklink symlink 1 > nul mklink /h hardlink 1 > nul -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "compressed file with alternate data streams" echo 1 > 1 @@ -363,7 +376,8 @@ call :msg "readonly directory with named data stream" md subdir echo foo > subdir:ads attrib +r subdir -call :do_test +REM Use skip_dism_apply=1 due to DISM bug +call :do_test_with_params 1 0 call :msg "encrypted file" echo "hello" > encrypted @@ -396,12 +410,14 @@ cipher /e subdir > nul cipher /d subdir\1 > nul call :do_test -call :msg "encrypted root directory" -cd .. -cipher /e in.dir > nul -cd in.dir -echo "hello" > encrypted -call :do_test +REM FIXME: apply fails with STATUS_ACCESS_DENIED +REM +REM call :msg "encrypted root directory" +REM cd .. +REM cipher /e in.dir > nul +REM cd in.dir +REM echo "hello" > encrypted +REM call :do_test call :msg "unencrypted file in encrypted directory in compressed directory" md 1 @@ -518,7 +534,14 @@ rd /s /q in.dir exit /b 0 :do_test +call :do_test_with_params 0 0 +goto :eof + +:do_test_with_params +set skip_dism_apply=%1 +set skip_dism_cmp=%2 cd .. +echo wimlib test (first time) %WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL if %errorlevel% neq 0 goto :fail %WIMLIB_IMAGEX% apply test.wim out.dir > NUL @@ -527,21 +550,30 @@ if %errorlevel% neq 0 goto :fail if %errorlevel% neq 0 goto :fail REM apply a second time so we test the case where the files already exist +echo wimlib test (second time) %WIMLIB_IMAGEX% apply test.wim out.dir > NUL if %errorlevel% neq 0 goto :fail %WIN32_TREE_CMP% in.dir out.dir if %errorlevel% neq 0 goto :fail -REM Fun fact: Microsoft's WIMGAPI has bugs that make it fail some of our tests. -REM Even the Windows 8.1 version has incorrect behavior with empty files with -REM multiple links, or files with named data streams and multiple links. +REM compatibility test: apply the image with DISM +echo DISM test rd /S /Q out.dir md out.dir -REM dism /capture-image /capturedir:in.dir /imagefile:test.wim /name:"test" /norpfix > nul -REM if %errorlevel% neq 0 goto :fail -dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul -if %errorlevel% neq 0 goto :fail -%WIN32_TREE_CMP% in.dir out.dir +if %skip_dism_apply% neq 1 ( + dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul + if !errorlevel! neq 0 ( + echo ERROR: DISM apply failed! + goto :fail + ) + if %skip_dism_cmp% neq 1 ( + %WIN32_TREE_CMP% in.dir out.dir + if !errorlevel! neq 0 ( + echo ERROR: DISM comparison failed! + goto :fail + ) + ) +) rd /S /Q in.dir out.dir md in.dir diff --git a/tests/win32-test-imagex-capture_and_apply.sh b/tests/win32-test-imagex-capture_and_apply.sh new file mode 100755 index 00000000..4a190c47 --- /dev/null +++ b/tests/win32-test-imagex-capture_and_apply.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e -u -v + +./tools/windows-build.sh +bindir=$(find . -name 'wimlib-*-bin' | tail -1) +for helper in win32-tree-cmp set_reparse_point; do + cc -O2 -municode -Wall -Werror ./tests/$helper.c -o "$bindir"/$helper.exe + chmod 700 "$bindir"/$helper.exe +done +cd "$bindir" +../tests/win32-test-imagex-capture_and_apply.bat