Fuzzer improvements.
phase_of_moon and friday_13th determined using rn2() instead of local time if fuzzing. Don't reseed using init_random() if fuzzing. Allow set_random to be called outside of hacklib. rn2_on_display_rng uses rn2 if fuzzing so that we have a single source of random that we can ensure is reproducible. Implement rul() that returns a random unsigned long. Fix bug in fuzzer handling of ntposkey which would cause us to use unitialized values for x and y. Added command line arguments to allow auto starting and stopping of fuzzer. Add a logging facility for the fuzzer to use to record activity. Added some scripts used to automate fuzzer testing on windows.
This commit is contained in:
8
win/win32/scripts/fuzzer/clean.bat
Normal file
8
win/win32/scripts/fuzzer/clean.bat
Normal file
@@ -0,0 +1,8 @@
|
||||
set BIN_DIR=..\..\..\..\bin\Debug\Win32
|
||||
|
||||
set FUZZER_LOG=%BIN_DIR%\fuzzer.log
|
||||
set FUZZER_DIR=%BIN_DIR%\fuzzer
|
||||
|
||||
if exist %BIN_DIR%\%USERNAME%* del %BIN_DIR%\%USERNAME%*
|
||||
if exist %FUZZER_LOG% del %FUZZER_LOG%
|
||||
|
||||
23
win/win32/scripts/fuzzer/longtest.bat
Normal file
23
win/win32/scripts/fuzzer/longtest.bat
Normal file
@@ -0,0 +1,23 @@
|
||||
echo off
|
||||
|
||||
SETLOCAL ENABLEEXTENSIONS
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
set STEP_SIZE=5000
|
||||
set FINAL_MOVE=500000
|
||||
set START_MOVE=5000
|
||||
|
||||
for /L %%i in (%START_MOVE%, %STEP_SIZE%, %FINAL_MOVE%) do (
|
||||
|
||||
call runtill.bat %%i
|
||||
|
||||
if ERRORLEVEL 1 (
|
||||
echo FAILED getting running to %%i.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
echo SUCCESS.
|
||||
|
||||
|
||||
7
win/win32/scripts/fuzzer/restore.bat
Normal file
7
win/win32/scripts/fuzzer/restore.bat
Normal file
@@ -0,0 +1,7 @@
|
||||
call clean.bat
|
||||
|
||||
set BIN_DIR=..\..\..\..\bin\Debug\Win32
|
||||
set SAVED_GAME=%USERNAME%-wizard.NetHack-saved-game
|
||||
set FUZZER_DIR=%BIN_DIR%\fuzzer
|
||||
|
||||
copy %FUZZER_DIR%\%SAVED_GAME% %BIN_DIR%\%SAVED_GAME%
|
||||
73
win/win32/scripts/fuzzer/runtill.bat
Normal file
73
win/win32/scripts/fuzzer/runtill.bat
Normal file
@@ -0,0 +1,73 @@
|
||||
REM
|
||||
REM runtill target_move
|
||||
REM
|
||||
echo off
|
||||
|
||||
SETLOCAL ENABLEEXTENSIONS
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
set TARGET_MOVE=%1
|
||||
|
||||
if %TARGET_MOVE% == "" (
|
||||
echo Usage:runtill target_move
|
||||
goto :eof
|
||||
)
|
||||
|
||||
set BIN_DIR=..\..\..\..\bin\Debug\Win32
|
||||
set SAVED_GAME=%USERNAME%-wizard.NetHack-saved-game
|
||||
set LOG_FILE=%BIN_DIR%\runtil.log
|
||||
set FUZZER_LOG=%BIN_DIR%\fuzzer.log
|
||||
set FUZZER_DIR=%BIN_DIR%\fuzzer
|
||||
set BASELINE=%FUZZER_DIR%\fuzzer.log
|
||||
|
||||
if not exist %FUZZER_DIR% mkdir %FUZZER_DIR%
|
||||
|
||||
call clean.bat
|
||||
|
||||
if not exist %FUZZER_DIR%\%SAVED_GAME% (
|
||||
%BIN_DIR%\nethack -D -F 0
|
||||
|
||||
copy %BIN_DIR%\%SAVED_GAME% %FUZZER_DIR%
|
||||
)
|
||||
|
||||
call restore.bat
|
||||
|
||||
%BIN_DIR%\nethack -D -F %TARGET_MOVE%
|
||||
|
||||
move %BIN_DIR%\*.snap %BIN_DIR%\snapshots
|
||||
copy %FUZZER_LOG% %BASELINE%
|
||||
|
||||
for /f "tokens=2,3 delims=: usebackq" %%i in (`findstr /c:START %BASELINE%`) do (
|
||||
set START_SEED=%%j
|
||||
set START_MOVE=%%i
|
||||
)
|
||||
|
||||
for /f "tokens=2,3 delims=: usebackq" %%i in (`findstr /c:STOP %BASELINE%`) do (
|
||||
set STOP_SEED=%%j
|
||||
set STOP_MOVE=%%i
|
||||
)
|
||||
|
||||
if !STOP_MOVE! LSS %TARGET_MOVE% (
|
||||
cls
|
||||
echo FAILED: Failed to reach target move. !STOP_MOVE! is not GTE %TARGET_MOVE%.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call restore.bat
|
||||
|
||||
%BIN_DIR%\nethack -D -F %TARGET_MOVE%
|
||||
|
||||
fc %FUZZER_LOG% %BASELINE%
|
||||
|
||||
if ERRORLEVEL 1 (
|
||||
cls
|
||||
echo FAILED: Unable to reproduce same timeline
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
del /q %FUZZER_DIR%\%SAVED_GAME%
|
||||
|
||||
copy %BIN_DIR%\%SAVED_GAME% %FUZZER_DIR%
|
||||
|
||||
echo !START_MOVE! to !STOP_MOVE!.
|
||||
echo SUCCESS.
|
||||
Reference in New Issue
Block a user