summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-11 23:34:54 -0800
committerKeith Packard <keithp@keithp.com>2016-11-17 22:18:39 -0800
commitd70a79fece4077c263a5773c8849ec60c6b649bc (patch)
tree19bf3359194d276fdec1d5f3c8c1006f52bcd632 /src/test
parent6187afea14c2dbaae98b595963104c527a3a45c8 (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.c18
-rw-r--r--src/test/hanoi.lisp8
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)
)