diff options
| author | fishsoupisgood <github@madingley.org> | 2019-04-29 01:17:54 +0100 | 
|---|---|---|
| committer | fishsoupisgood <github@madingley.org> | 2019-05-27 03:43:43 +0100 | 
| commit | 3f2546b2ef55b661fd8dd69682b38992225e86f6 (patch) | |
| tree | 65ca85f13617aee1dce474596800950f266a456c /roms/openbios/forth/testsuite | |
| download | qemu-master.tar.gz qemu-master.tar.bz2 qemu-master.zip  | |
Diffstat (limited to 'roms/openbios/forth/testsuite')
| -rw-r--r-- | roms/openbios/forth/testsuite/README | 8 | ||||
| -rw-r--r-- | roms/openbios/forth/testsuite/build.xml | 16 | ||||
| -rw-r--r-- | roms/openbios/forth/testsuite/fract.fs | 35 | ||||
| -rw-r--r-- | roms/openbios/forth/testsuite/framebuffer-test.fs | 10 | ||||
| -rw-r--r-- | roms/openbios/forth/testsuite/memory-testsuite.fs | 106 | ||||
| -rw-r--r-- | roms/openbios/forth/testsuite/splitfunc-testsuite.fs | 38 | 
6 files changed, 213 insertions, 0 deletions
diff --git a/roms/openbios/forth/testsuite/README b/roms/openbios/forth/testsuite/README new file mode 100644 index 00000000..7aa98dea --- /dev/null +++ b/roms/openbios/forth/testsuite/README @@ -0,0 +1,8 @@ +TESTSUITES +---------- + +This directory contains additional testsuites for some open  +firmware components. They are not built per default. + + +tag: testsuites readme diff --git a/roms/openbios/forth/testsuite/build.xml b/roms/openbios/forth/testsuite/build.xml new file mode 100644 index 00000000..7b7d62bc --- /dev/null +++ b/roms/openbios/forth/testsuite/build.xml @@ -0,0 +1,16 @@ +<build> + + <!-- +  build description for OpenBIOS test suite +  +  Copyright (C) 2004-2005 by Stefan Reinauer +  See the file "COPYING" for further information about +  the copyright and warranty status of this work. +  --> + + <dictionary name="testsuite" target="forth"> +  <object source="memory-testsuite.fs"/> +  <object source="splitfunc-testsuite.fs"/> + </dictionary> + +</build> diff --git a/roms/openbios/forth/testsuite/fract.fs b/roms/openbios/forth/testsuite/fract.fs new file mode 100644 index 00000000..39c98405 --- /dev/null +++ b/roms/openbios/forth/testsuite/fract.fs @@ -0,0 +1,35 @@ +\ tag: forth fractal example +\  +\ Copyright (C) 2002, 2003 Volker Poplawski <volker@poplawski.de> +\                          Stefan Reinauer + +\ This example even fits in a signature ;-) + +\ hex 4666 dup negate do i 4000 dup 2* negate do 2a 0 dup 2dup 1e 0 do +\ 2swap * d >>a 4 pick + -rot - j + dup dup * e >>a rot dup dup * e >>a  +\ rot swap 2dup + 10000 > if 3drop 2drop 20 0 dup 2dup leave then loop  +\ 2drop 2drop type 268 +loop cr drop 5de +loop + + +: fract +4666 dup negate +do +    i 4000 dup 2* negate +    do +        2a 0 dup 2dup 1e 0 +	do +	    2swap * d >>a 4 pick + +	    -rot - j + +	    dup dup * e >>a rot +	    dup dup * e >>a rot +	    swap +	    2dup + 10000 > if +	        3drop 2drop 20 0 dup 2dup leave +	    then +	loop +	2drop 2drop +	emit +    268 +loop +    cr drop +5de +loop +; diff --git a/roms/openbios/forth/testsuite/framebuffer-test.fs b/roms/openbios/forth/testsuite/framebuffer-test.fs new file mode 100644 index 00000000..11099325 --- /dev/null +++ b/roms/openbios/forth/testsuite/framebuffer-test.fs @@ -0,0 +1,10 @@ + +: test-screen +  10 10 pci-l@ +  f0 0 do +    dup d# 1280 i * + +    500 i fill +  loop +  ; + +  test-screen diff --git a/roms/openbios/forth/testsuite/memory-testsuite.fs b/roms/openbios/forth/testsuite/memory-testsuite.fs new file mode 100644 index 00000000..9dace511 --- /dev/null +++ b/roms/openbios/forth/testsuite/memory-testsuite.fs @@ -0,0 +1,106 @@ +\ this is the memory management testsuite. +\  +\ run it with   paflof < memory-testsuite.fs 2>/dev/null + +s" memory.fs" included + +\ dumps all free-list entries +\ useful for debugging. + +: dump-freelist ( -- ) +  ." Dumping freelist:" cr +  free-list @ + +  \ If the free list is empty we notify the user. +  dup 0= if ."   empty." drop cr exit then +   +  begin dup 0<> while +    dup ." entry 0x" .			\ print pointer to entry +    dup cell+ @ ." , next=0x" u.	\ pointer to next entry +    dup @ ." , size=0x" u. cr		\ len of current entry + +    cell+ @ +  repeat +  cr drop +  ; + +\ simple testsuite. run testsuite-init to initialize +\ with some dummy memory in the dictionary. +\ run testsuite-test[1..3] for different tests. + +: testsuite-init ( -- ) +  here 40000 cell+ dup allot ( -- ptr len ) +  init-mem + +  ." start-mem = 0x" start-mem @ . cr +  ." end-mem   = 0x" end-mem @ . cr +  ." free-list = 0x" free-list @ . cr +   +  ." Memory management initialized." cr +  dump-freelist +  ; + +: testsuite-test1 ( -- ) +  ." Test No. 1: Allocating all available memory (256k)" cr + +  40000 alloc-mem +  dup 0<> if  +    ." worked, ptr=0x" dup . +  else +    ." did not work." +  then +  cr + +  dump-freelist +  ." Freeing memory." cr +  ." stack=" .s cr +  free-mem +  dump-freelist +  ; +   +: testsuite-test2 ( -- ) +  ." Test No. 2: Allocating 5 blocks" cr +  4000 alloc-mem +  4000 alloc-mem +  4000 alloc-mem +  4000 alloc-mem +  4000 alloc-mem +   +  ." Allocated 5 blocks. Stack:" cr .s cr + +  dump-freelist +   +  ." Freeing Block 2" cr +  3 pick free-mem dump-freelist + +  ." Freeing Block 4" cr +  over free-mem dump-freelist + +  ." Freeing Block 3" cr +  2 pick free-mem dump-freelist + +  ." Cleaning up blocks 1 and 5" cr +  free-mem	\ Freeing block 5 +  dump-freelist +  3drop		\ blocks 4, 3, 2 +  free-mem +   +  dump-freelist +  ; + +: testsuite-test3 ( -- ) +  ." Test No. 3: freeing illegal address 0xdeadbeef." cr +  deadbeef free-mem +  dump-freelist +  ; +   +: testsuite ( -- ) +  testsuite-init +  testsuite-test1 +  testsuite-test2 +  testsuite-test3 +  ; + +testsuite + +bye diff --git a/roms/openbios/forth/testsuite/splitfunc-testsuite.fs b/roms/openbios/forth/testsuite/splitfunc-testsuite.fs new file mode 100644 index 00000000..00469bb5 --- /dev/null +++ b/roms/openbios/forth/testsuite/splitfunc-testsuite.fs @@ -0,0 +1,38 @@ +\ this is the splitfunc testsuite. +\  +\ run it with   paflof < splitfunc-testsuite.fs 2>/dev/null + +\ implements split-before, split-after and left-split  +\ as described in 4.3 (Path resolution) + +s" splitfunc.fs" included +  +: test-split + s" var/log/messages" 2dup + + cr ." split-before test:" cr + 2dup ." String: " type cr + 2f split-before + 2swap  + ." initial: " type cr ." remainder:" type cr + cr + ." split-after test:" cr + 2f split-after cr + 2swap  + ." initial: " type cr ." remainder:" type cr + + ." foobar test" cr + + s" foobar" 2dup + + 2f split-after cr + 2swap  + ." initial: " type cr ." remainder:" type cr + + 2f split-after cr + 2swap  + ." initial: " type cr ." remainder:" type cr + ; + + +    | 
