| 1 |
@echo off |
| 2 |
REM Run a subset of unit tests as a normal (medium-integrity) non-admin user. |
| 3 |
REM Complements psexec-low-integrity-tests.bat: registry and recycle-bin tests |
| 4 |
REM need medium integrity; locked-file and service tests need non-admin token. |
| 5 |
setlocal |
| 6 |
cd /d "%~dp0.." |
| 7 |
set "REPO=%CD%" |
| 8 |
set "LOG=%REPO%\psexec_nonadmin_tests.log" |
| 9 |
set "DESTRUCTIVE_TESTS=T" |
| 10 |
set "PYTHONWARNINGS=error" |
| 11 |
set "GITHUB_ACTIONS=true" |
| 12 |
set "COVERAGE_FILE=%REPO%\.coverage.nonadmin" |
| 13 |
|
| 14 |
if not defined PYTHON_EXE ( |
| 15 |
if exist "%REPO%\vcpkg_installed\x86-windows\tools\python3\python.exe" ( |
| 16 |
set "PYTHON_EXE=%REPO%\vcpkg_installed\x86-windows\tools\python3\python.exe" |
| 17 |
) else ( |
| 18 |
echo ERROR: PYTHON_EXE is not set> "%LOG%" |
| 19 |
exit /b 1 |
| 20 |
) |
| 21 |
) |
| 22 |
|
| 23 |
( |
| 24 |
echo === psexec non-admin tests === |
| 25 |
echo CD=%CD% |
| 26 |
echo USERNAME=%USERNAME% |
| 27 |
echo PYTHON_EXE=%PYTHON_EXE% |
| 28 |
echo TEMP=%TEMP% |
| 29 |
echo COVERAGE_FILE=%COVERAGE_FILE% |
| 30 |
) > "%LOG%" |
| 31 |
|
| 32 |
"%PYTHON_EXE%" -c "from win32com.shell import shell; print('IsUserAnAdmin:', shell.IsUserAnAdmin())" >> "%LOG%" 2>&1 |
| 33 |
echo.>> "%LOG%" |
| 34 |
|
| 35 |
REM -u keeps stdout in order with stderr when both are redirected to the log |
| 36 |
"%PYTHON_EXE%" -u -m coverage run -m unittest -v ^ |
| 37 |
tests.TestWindows.WindowsTestCase.test_delete_registry_key ^ |
| 38 |
tests.TestWindows.WindowsTestCase.test_delete_registry_value ^ |
| 39 |
tests.TestWindows.WindowsTestCase.test_detect_registry_key ^ |
| 40 |
tests.TestWindows.WindowsTestCase.test_get_recycle_bin ^ |
| 41 |
tests.TestWindows.WindowsTestCase.test_get_recycle_bin_destructive ^ |
| 42 |
tests.TestWindows.WindowsTestCase.test_broken_link_in_recycle_bin ^ |
| 43 |
tests.TestWindows.WindowsTestCase.test_empty_recycle_bin ^ |
| 44 |
tests.TestWindows.WindowsTestCase.test_empty_recycle_bin_per_drive_destructive ^ |
| 45 |
tests.TestWindows.WindowsTestCase.test_empty_recycle_bin_all_drives_destructive ^ |
| 46 |
tests.TestWorker.WorkerTestCase.test_Locked ^ |
| 47 |
tests.TestWindows.WindowsTestCase.test_run_net_service_command_not_admin ^ |
| 48 |
tests.TestWindows.WindowsTestCase.test_delete_locked_file ^ |
| 49 |
tests.TestWindows.WindowsTestCase.test_file_wipe >> "%LOG%" 2>&1 |
| 50 |
exit /b %ERRORLEVEL% |