summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/forth/testsuite
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/openbios/forth/testsuite
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff)
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/openbios/forth/testsuite')
-rw-r--r--qemu/roms/openbios/forth/testsuite/README8
-rw-r--r--qemu/roms/openbios/forth/testsuite/build.xml16
-rw-r--r--qemu/roms/openbios/forth/testsuite/fract.fs35
-rw-r--r--qemu/roms/openbios/forth/testsuite/framebuffer-test.fs10
-rw-r--r--qemu/roms/openbios/forth/testsuite/memory-testsuite.fs106
-rw-r--r--qemu/roms/openbios/forth/testsuite/splitfunc-testsuite.fs38
6 files changed, 213 insertions, 0 deletions
diff --git a/qemu/roms/openbios/forth/testsuite/README b/qemu/roms/openbios/forth/testsuite/README
new file mode 100644
index 000000000..7aa98dea3
--- /dev/null
+++ b/qemu/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/qemu/roms/openbios/forth/testsuite/build.xml b/qemu/roms/openbios/forth/testsuite/build.xml
new file mode 100644
index 000000000..7b7d62bcf
--- /dev/null
+++ b/qemu/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/qemu/roms/openbios/forth/testsuite/fract.fs b/qemu/roms/openbios/forth/testsuite/fract.fs
new file mode 100644
index 000000000..39c984056
--- /dev/null
+++ b/qemu/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/qemu/roms/openbios/forth/testsuite/framebuffer-test.fs b/qemu/roms/openbios/forth/testsuite/framebuffer-test.fs
new file mode 100644
index 000000000..110993259
--- /dev/null
+++ b/qemu/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/qemu/roms/openbios/forth/testsuite/memory-testsuite.fs b/qemu/roms/openbios/forth/testsuite/memory-testsuite.fs
new file mode 100644
index 000000000..9dace5117
--- /dev/null
+++ b/qemu/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/qemu/roms/openbios/forth/testsuite/splitfunc-testsuite.fs b/qemu/roms/openbios/forth/testsuite/splitfunc-testsuite.fs
new file mode 100644
index 000000000..00469bb57
--- /dev/null
+++ b/qemu/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
+ ;
+
+
+