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:
Bart House
2019-07-14 00:20:09 -07:00
parent aa95e20ca7
commit 435f1c4626
14 changed files with 337 additions and 8 deletions

View File

@@ -139,7 +139,7 @@ dosave0()
return 0;
#endif
HUP if (iflags.window_inited) {
HUP if (!iflags.debug_fuzzer && iflags.window_inited) {
nh_uncompress(fq_save);
fd = open_savefile();
if (fd > 0) {
@@ -1238,6 +1238,18 @@ int fd, mode;
bwrite(fd, (genericptr_t) msg, msglen);
++msgcount;
}
/* If the fuzzer is stopping and saving, save a seed as a message.
In 3.7, we will modify the save file format and save the seed
directly in the saved game state. */
if (iflags.fuzzer_saving) {
char message[BUFSIZ];
unsigned long seed = rul();
sprintf(message, "SEED:%ld:%lu", moves, seed);
fuzzer_log(LOG_MINIMAL, "STOP:%ld:%lu\n", moves, seed);
msglen = strlen(message);
bwrite(fd, (genericptr_t) &msglen, sizeof msglen);
bwrite(fd, (genericptr_t) message, msglen);
}
bwrite(fd, (genericptr_t) &minusone, sizeof (int));
}
debugpline1("Stored %d messages into savefile.", msgcount);