mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
adding memory tests
This commit is contained in:
parent
938f527c79
commit
c355e0146f
8 changed files with 51 additions and 1 deletions
8
Makefile
8
Makefile
|
@ -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
12
tests/memory/memory-tests.sh
Executable 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
|
1
tests/memory/test00-read-string.err-res
Normal file
1
tests/memory/test00-read-string.err-res
Normal file
|
@ -0,0 +1 @@
|
|||
ERROR: out of memory
|
1
tests/memory/test00-read-string.res
Normal file
1
tests/memory/test00-read-string.res
Normal file
|
@ -0,0 +1 @@
|
|||
string: "aaa...
|
16
tests/memory/test00-read-string.scm
Normal file
16
tests/memory/test00-read-string.scm
Normal 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)
|
1
tests/memory/test01-read-symbol.err-res
Normal file
1
tests/memory/test01-read-symbol.err-res
Normal file
|
@ -0,0 +1 @@
|
|||
ERROR: out of memory
|
1
tests/memory/test01-read-symbol.res
Normal file
1
tests/memory/test01-read-symbol.res
Normal file
|
@ -0,0 +1 @@
|
|||
string: aaaa...
|
12
tests/memory/test01-read-symbol.scm
Normal file
12
tests/memory/test01-read-symbol.scm
Normal 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)
|
Loading…
Add table
Reference in a new issue