adding memory tests

This commit is contained in:
Alex Shinn 2011-10-03 19:03:42 +09:00
parent 938f527c79
commit c355e0146f
8 changed files with 51 additions and 1 deletions

View file

@ -144,6 +144,9 @@ include/chibi/install.h: Makefile
sexp.o: sexp.c gc.c opt/bignum.c $(INCLUDES) Makefile
$(CC) -c $(XCPPFLAGS) $(XCFLAGS) $(CLIBFLAGS) -o $@ $<
sexp-ulimit.o: sexp.c gc.c opt/bignum.c $(INCLUDES) Makefile
$(CC) -c $(XCPPFLAGS) $(XCFLAGS) $(CLIBFLAGS) -DSEXP_USE_LIMITED_MALLOC -o $@ $<
eval.o: eval.c opcodes.c vm.c opt/simplify.c $(INCLUDES) include/chibi/eval.h Makefile
$(CC) -c $(XCPPFLAGS) $(XCFLAGS) $(CLIBFLAGS) -o $@ $<
@ -162,6 +165,9 @@ chibi-scheme$(EXE): main.o libchibi-scheme$(SO)
chibi-scheme-static$(EXE): main.o eval.o sexp.o
$(CC) $(XCFLAGS) $(STATICFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS) -lm
chibi-scheme-ulimit$(EXE): main.o eval.o sexp-ulimit.o
$(CC) $(XCFLAGS) $(STATICFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS) -lm
clibs.c: $(GENSTATIC) lib lib/chibi lib/srfi chibi-scheme$(EXE) libs
$(CHIBI) $< > $@
@ -214,7 +220,7 @@ test-basic: chibi-scheme$(EXE)
fi; \
done
test-memory:
test-memory: chibi-scheme-ulimit$(EXE)
./tests/memory/memory-tests.sh
test-build:

12
tests/memory/memory-tests.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
for f in tests/memory/*.scm; do
./chibi-scheme-ulimit $f >${f%.scm}.out 2>${f%.scm}.err
if diff -q ${f%.scm}.out ${f%.scm}.res \
&& diff -q ${f%.scm}.err ${f%.scm}.err-res; then
echo "[PASS] ${f%.scm}"
rm -f ${f%.scm}.out ${f%.scm}.err
else
echo "[FAIL] ${f%.scm}"
fi
done

View file

@ -0,0 +1 @@
ERROR: out of memory

View file

@ -0,0 +1 @@
string: "aaa...

View file

@ -0,0 +1,16 @@
(define (show-string str)
(display "string: ")
(display (substring str 0 (min (string-length str) 4)))
(display "...\n"))
(define str-length (inexact->exact (round (* 2 1024 1024)))) ;; 2MB
(define str1
(let ((tmp (make-string str-length #\a)))
(string-set! tmp 0 #\")
(string-set! tmp (- str-length 1) #\")
tmp))
(show-string str1)
(define str2 (call-with-input-string str1 read))
(show-string str2)

View file

@ -0,0 +1 @@
ERROR: out of memory

View file

@ -0,0 +1 @@
string: aaaa...

View file

@ -0,0 +1,12 @@
(define (show-string str)
(display "string: ")
(display (substring str 0 (min (string-length str) 4)))
(display "...\n"))
(define str-length (inexact->exact (round (* 2 1024 1024)))) ;; 2MB
(define str1 (make-string str-length #\a))
(show-string str1)
(define str2 (call-with-input-string str1 read))
(show-string str2)