diff options
author | Keith Packard <keithp@keithp.com> | 2016-11-11 23:34:54 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:50 -0800 |
commit | 33aeffc123af1f9063969acf585f1caac885ced4 (patch) | |
tree | bf4f87c83c46ce815070933b947ba27fa65724c8 /src/test | |
parent | 8f2d60b4c029bffaa559bd1f31f5b15230dfa674 (diff) |
altos/lisp: Append a CRC to the saved image to validate on restore
The CRC is actually of the ROM bits, so we can tell if the restored
image relates to the currently running code.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/ao_lisp_test.c | 18 | ||||
-rw-r--r-- | src/test/hanoi.lisp | 8 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/test/ao_lisp_test.c b/src/test/ao_lisp_test.c index 41dae07a..648d1abe 100644 --- a/src/test/ao_lisp_test.c +++ b/src/test/ao_lisp_test.c @@ -35,6 +35,24 @@ ao_lisp_os_save(void) } int +ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset) +{ + FILE *restore = fopen(save_file, "r"); + size_t ret; + + if (!restore) { + perror(save_file); + return 0; + } + fseek(restore, offset, SEEK_SET); + ret = fread(save, sizeof (struct ao_lisp_os_save), 1, restore); + fclose(restore); + if (ret != 1) + return 0; + return 1; +} + +int ao_lisp_os_restore(void) { FILE *restore = fopen(save_file, "r"); diff --git a/src/test/hanoi.lisp b/src/test/hanoi.lisp index 01398d91..2b614829 100644 --- a/src/test/hanoi.lisp +++ b/src/test/hanoi.lisp @@ -6,20 +6,12 @@ (patom "\033[2J" nil) ) -(defun test () - (clear) - (move-to 30 12) - (patom "hello, world") - (move-to 0 19) - ) - (setq stack '("*" "**" "***" "****" "*****" "******" "*******")) (setq stacks nil) (defun display-string (x y str) (move-to x y) - (move-to x y) (patom str) ) |