]> wimlib.net Git - wimlib/commitdiff
Fix win32-test-imagex-capture_and_apply.bat and add to CI
authorEric Biggers <ebiggers3@gmail.com>
Mon, 10 Apr 2023 00:02:21 +0000 (17:02 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 10 Apr 2023 00:13:06 +0000 (17:13 -0700)
.github/workflows/ci.yml
tests/win32-test-imagex-capture_and_apply.bat
tests/win32-test-imagex-capture_and_apply.sh [new file with mode: 0755]

index 897d8fb95a9b59f913dac2e7f1d9a7a45656257b..d7919922f016c6b55c3dd495c9b14d3913877dc0 100644 (file)
@@ -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:
index 9cb97bd3d15e4b0dd6bb168c7bb007b9f131cf4d..8af2fa3f5a9e7165b639e93363dabffe10ab34f2 100644 (file)
@@ -5,14 +5,13 @@ REM win32-test-imagex-capture_and_apply.bat
 REM\r
 REM Run some tests on the Windows version of wimlib-imagex.\r
 REM\r
-REM This must be run in a clean directory, with Administrator privileges.\r
-REM wimlib-imagex, win32-tree-cmp, and set_reparse_point must be executable\r
-REM using the paths set below.\r
+REM This must be run with Administrator privileges, in a directory containing\r
+REM the wimlib-imagex, win32-tree-cmp, and set_reparse_point programs.\r
 \r
 setlocal EnableDelayedExpansion\r
-set WIMLIB_IMAGEX=wimlib-imagex\r
-set WIN32_TREE_CMP=win32-tree-cmp\r
-set SET_REPARSE_POINT=set_reparse_point\r
+set WIMLIB_IMAGEX=%cd%\wimlib-imagex\r
+set WIN32_TREE_CMP=%cd%\win32-tree-cmp\r
+set SET_REPARSE_POINT=%cd%\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
@@ -58,7 +57,8 @@ call :do_test
 call :msg "hard linked empty file"\r
 type nul > file\r
 mklink /h link file > nul\r
-call :do_test\r
+REM Use skip_dism_cmp=1 due to DISM bug\r
+call :do_test_with_params 0 1\r
 \r
 call :msg "various hard linked, identical, different, and empty files"\r
 echo 1 > file\r
@@ -71,7 +71,8 @@ mklink /h emptyfilelink emptyfile > nul
 echo 5 > identicalfile\r
 echo 1 > 1file\r
 mklink /h 1filelink 1file > nul\r
-call :do_test\r
+REM Use skip_dism_cmp=1 due to DISM bug\r
+call :do_test_with_params 0 1\r
 \r
 call :msg "multiple subdirectories, some empty, some not"\r
 md subdir1\r
@@ -84,10 +85,12 @@ md subdir2\subdir2subdir
 type nul > subdir2\emptyfile\r
 call :do_test\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
+REM FIXME: win32-tree-cmp can't handle this case.\r
+REM\r
+REM call :msg "file with custom security descriptor"\r
+REM echo hello > file\r
+REM icacls file /deny Administrator:F > nul\r
+REM call :do_test\r
 \r
 call :msg "directory with custom security descriptor (inheritence enabled)"\r
 md subdir\r
@@ -99,7 +102,7 @@ md subdir
 icacls subdir /inheritance:d > nul\r
 call :do_test\r
 \r
-REM            win32-tree-cmp can't handle this case.\r
+REM FIXME: 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
@@ -109,7 +112,8 @@ REM call :do_test
 call :msg "file with custom integrity level"\r
 echo hello > file\r
 icacls file /setintegritylevel H > nul\r
-call :do_test\r
+REM Use skip_dism_cmp=1 due to DISM bug\r
+call :do_test_with_params 0 1\r
 \r
 call :msg "relative symlink"\r
 mklink relink dest > nul\r
@@ -172,14 +176,16 @@ call :do_test
 call :msg "reparse point with unnamed data stream"\r
 echo "test" > file\r
 %SET_REPARSE_POINT% file\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\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
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "empty reparse point"\r
 type nul > file\r
@@ -196,7 +202,8 @@ echo hello > file
 echo hello > file:ads1\r
 type nul > file:ads2\r
 %SET_REPARSE_POINT% file 0\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "maximum length reparse point"\r
 type nul > file\r
@@ -285,22 +292,26 @@ call :do_test
 call :msg "directory with empty alternate data stream"\r
 md subdir\r
 type nul > subdir:ads\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "root directory with alternate data stream"\r
 echo 1 > ..\in.dir:ads\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "root directory with empty alternate data stream"\r
 type nul > ..\in.dir:ads\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\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
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "subdirectories and files with alternate data streams"\r
 md subdir\r
@@ -313,14 +324,16 @@ echo 1 > helloagain:1
 echo 8 > helloagain:8\r
 echo 1 > 1\r
 type nul > helloagain:dummy\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\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
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "compressed file with alternate data streams"\r
 echo 1 > 1\r
@@ -363,7 +376,8 @@ call :msg "readonly directory with named data stream"
 md subdir\r
 echo foo > subdir:ads\r
 attrib +r subdir\r
-call :do_test\r
+REM Use skip_dism_apply=1 due to DISM bug\r
+call :do_test_with_params 1 0\r
 \r
 call :msg "encrypted file"\r
 echo "hello" > encrypted\r
@@ -396,12 +410,14 @@ cipher /e subdir > nul
 cipher /d subdir\1 > nul\r
 call :do_test\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
+REM FIXME: apply fails with STATUS_ACCESS_DENIED\r
+REM\r
+REM call :msg "encrypted root directory"\r
+REM cd ..\r
+REM cipher /e in.dir > nul\r
+REM cd in.dir\r
+REM echo "hello" > encrypted\r
+REM call :do_test\r
 \r
 call :msg "unencrypted file in encrypted directory in compressed directory"\r
 md 1\r
@@ -518,7 +534,14 @@ rd /s /q in.dir
 exit /b 0\r
 \r
 :do_test\r
+call :do_test_with_params 0 0\r
+goto :eof\r
+\r
+:do_test_with_params\r
+set skip_dism_apply=%1\r
+set skip_dism_cmp=%2\r
 cd ..\r
+echo   wimlib test (first time)\r
 %WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL\r
 if %errorlevel% neq 0 goto :fail\r
 %WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
@@ -527,21 +550,30 @@ if %errorlevel% neq 0 goto :fail
 if %errorlevel% neq 0 goto :fail\r
 \r
 REM  apply a second time so we test the case where the files already exist\r
+echo   wimlib test (second time)\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 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
+REM  compatibility test: apply the image with DISM\r
+echo   DISM test\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 goto :fail\r
-dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
-if %errorlevel% neq 0 goto :fail\r
-%WIN32_TREE_CMP% in.dir out.dir\r
+if %skip_dism_apply% neq 1 (\r
+    dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
+    if !errorlevel! neq 0 (\r
+        echo ERROR: DISM apply failed!\r
+        goto :fail\r
+    )\r
+    if %skip_dism_cmp% neq 1 (\r
+        %WIN32_TREE_CMP% in.dir out.dir\r
+        if !errorlevel! neq 0 (\r
+            echo ERROR: DISM comparison failed!\r
+            goto :fail\r
+        )\r
+    )\r
+)\r
 \r
 rd /S /Q in.dir out.dir\r
 md in.dir\r
diff --git a/tests/win32-test-imagex-capture_and_apply.sh b/tests/win32-test-imagex-capture_and_apply.sh
new file mode 100755 (executable)
index 0000000..4a190c4
--- /dev/null
@@ -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