Real test coverage dor SAVE_TAMPERING.

This commit is contained in:
Eric S. Raymond 2023-03-12 17:37:58 -04:00
parent 43af075fa9
commit 5929a68b88
5 changed files with 26 additions and 3 deletions

View file

@ -161,8 +161,8 @@ int restore(FILE* fp)
if (save.version != VRSION) {
rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10));
} else if (!is_valid(save.game)) {
rspeak(SAVE_TAMPERING); // LCOV_EXCL_LINE
exit(EXIT_SUCCESS); // LCOV_EXCL_LINE
rspeak(SAVE_TAMPERING);
exit(EXIT_SUCCESS);
} else {
game = save.game;
}

View file

@ -52,6 +52,8 @@ savegames:
@$(PARDIR)/cheat -d -900 -o cheat_numdie.adv > /tmp/cheat_numdie
@$(ECHO) "cheat: Generate save file with -1000 deaths"
@$(PARDIR)/cheat -d -1000 -o cheat_numdie1000.adv > /tmp/cheat_numdie1000
@$(ECHO) "cheat: Generate tamper-detection test"
@$(PARDIR)/cheat -d 2000 -o cheat_savetamper.adv > /tmp/cheat_savetamper
@$(ECHO) "cheat: Generate save file with version -1337"
@$(PARDIR)/cheat -v -1337 -o resume_badversion.adv > /tmp/cheat_badversion
@$(ECHO) "cheat: Generate save file 1000 saves"

View file

@ -25,7 +25,7 @@ YAML_PATH = "../adventure.yaml"
HTML_TEMPLATE_PATH = "../templates/coverage_dungeon.html.tpl"
DEFAULT_HTML_OUTPUT_PATH = "../coverage/adventure.yaml.html"
DANGLING_ACTIONS = ["ACT_VERSION"]
DANGLING_MESSAGES = ["SAVERESUME_DISABLED", "SAVE_TAMPERING"]
DANGLING_MESSAGES = ["SAVERESUME_DISABLED"]
STDOUT_REPORT_CATEGORY = " {name:.<19}: {percent:5.1f}% covered ({covered} of {total})\n"

17
tests/savetamper.chk Normal file
View file

@ -0,0 +1,17 @@
Welcome to Adventure!! Would you like instructions?
> n
You are standing at the end of a road before a small brick building.
Around you is a forest. A small stream flows out of the building and
down a gully.
> resume
A dark fog creeps in to surround you. From somewhere in the fog you
hear a stern voice. "This Adventure has been tampered with! You have
been dabbling in magic, knowing not the havoc you might cause thereby.
Leave at once, before you do irrevocable harm!" The fog thickens,
until at last you can see nothing at all. Your vision then clears,
and you find yourself back in The Real World.

4
tests/savetamper.log Normal file
View file

@ -0,0 +1,4 @@
## Resume from artificial "corrupted" save
n
resume
cheat_savetamper.adv