From: Martin Perner Date: Sat, 29 May 2010 22:12:49 +0000 (+0200) Subject: New Testcases + New Script X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=testub10.git;a=commitdiff_plain;h=a6c53118bb80b750a02f6bb02393309ec7816d94 New Testcases + New Script Some new Testcases A Script that starts gdb on a testcase --- diff --git a/codeb/skinner33_00.0 b/codeb/skinner33_00.0 new file mode 100644 index 0000000..a1c1a9e --- /dev/null +++ b/codeb/skinner33_00.0 @@ -0,0 +1,27 @@ +struct bar end; + +method foo(bar) + while not(0 = bar) do + bar := (bar - 1); + this.bar := (this.bar * 2); + end; + return this.bar; +end; + +method bar(x) + while 1 do + x := x - (-1); + if not(x = 10) then + x := x * 1; + else + return x; + end; + end; +end; + +method blu(a) + while 0 do + return 3; + end; + return 4; +end; diff --git a/codeb/skinner33_00.call b/codeb/skinner33_00.call new file mode 100644 index 0000000..147d180 --- /dev/null +++ b/codeb/skinner33_00.call @@ -0,0 +1,8 @@ + +long foo(long*, long); +long bar(long, long); +long blu(long, long); + +long inp[] = {2}; + +RET(foo(inp, 4) == 32 && blu(1337,42) == 4 && bar(0xDEAD,4) == 10 && bar(0x1337, 9) == 10); diff --git a/codeb/skinner33_00.instr b/codeb/skinner33_00.instr new file mode 100644 index 0000000..84df352 --- /dev/null +++ b/codeb/skinner33_00.instr @@ -0,0 +1 @@ +87 diff --git a/codeb/skinner33_01.0 b/codeb/skinner33_01.0 new file mode 100644 index 0000000..d6a008f --- /dev/null +++ b/codeb/skinner33_01.0 @@ -0,0 +1,30 @@ +struct a end; + + +method foo(x) + if (x-1) then + return 5*(this*3); + else + return 4*(2*this); + end; +end; + +method bar(n) + var x := 5; + var y := 6; + if n then + return x - a; + end; + if n < 7 then + return y * a; + end; + return x; +end; + +method bla() + if a then + return 5; + else + return a; + end; +end; diff --git a/codeb/skinner33_01.call b/codeb/skinner33_01.call new file mode 100644 index 0000000..17eb2f8 --- /dev/null +++ b/codeb/skinner33_01.call @@ -0,0 +1,9 @@ + +long foo(long, long); +long bar(long*, long); +long bla(long*); + +long muh[] = {3}, kuh[] = {0}; + +RET(foo(5,1) == 40 && foo(4,0) == 60 && bar(muh, 1) == 2 && bar(muh,0) == 18 && bla(muh) == 5 && bla(kuh) == 0); + diff --git a/codeb/skinner33_01.instr b/codeb/skinner33_01.instr new file mode 100644 index 0000000..8f92bfd --- /dev/null +++ b/codeb/skinner33_01.instr @@ -0,0 +1 @@ +35 diff --git a/codeb/skinner33_02.0 b/codeb/skinner33_02.0 new file mode 100644 index 0000000..3f7adbf --- /dev/null +++ b/codeb/skinner33_02.0 @@ -0,0 +1,17 @@ + +struct a b end; + +method foo() + var x := 5; + if this * x then + return (x - this) * x; + end; + return x; +end; + +method bar(n) + var x := n; + this.a := x; + return x; +end; + diff --git a/codeb/skinner33_02.call b/codeb/skinner33_02.call new file mode 100644 index 0000000..a0c1825 --- /dev/null +++ b/codeb/skinner33_02.call @@ -0,0 +1,9 @@ + +long foo(long); +long bar(long*, long); + +long muh[] = {1, 3}; +long kuh[] = {2,6}; + +RET(foo(1) == 20 && foo(0) == 5 && bar(muh, 5) == 5 && muh[0] == 5 && bar(muh,10) == 10 && muh[0] == 10 ); + diff --git a/codeb/skinner33_02.instr b/codeb/skinner33_02.instr new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/codeb/skinner33_02.instr @@ -0,0 +1 @@ +22 diff --git a/codeb/skinner33_03.0 b/codeb/skinner33_03.0 new file mode 100644 index 0000000..b799e02 --- /dev/null +++ b/codeb/skinner33_03.0 @@ -0,0 +1,9 @@ +struct a end; + +method foo(b) + if 0 * b then + return b; + else + return (b - a); + end; +end; diff --git a/codeb/skinner33_03.call b/codeb/skinner33_03.call new file mode 100644 index 0000000..ce6dee0 --- /dev/null +++ b/codeb/skinner33_03.call @@ -0,0 +1,7 @@ + +long foo(long*, long); + +long muh[] = {4}; + +RET(foo(muh,5) == 1 && foo(muh, 2) == -2 && foo(muh,0) == -4); + diff --git a/codeb/skinner33_03.instr b/codeb/skinner33_03.instr new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/codeb/skinner33_03.instr @@ -0,0 +1 @@ +12 diff --git a/codeb/skinner33_04.0 b/codeb/skinner33_04.0 new file mode 100644 index 0000000..c59bdd9 --- /dev/null +++ b/codeb/skinner33_04.0 @@ -0,0 +1,13 @@ + +struct a b end; + +method foo(n) + if 0 then + return 0; + end; + a := b; + if not(not(a = b)) then + return n - (a*b); + end; + return 0x9999; +end; diff --git a/codeb/skinner33_04.call b/codeb/skinner33_04.call new file mode 100644 index 0000000..84677a8 --- /dev/null +++ b/codeb/skinner33_04.call @@ -0,0 +1,9 @@ + +long foo(long*, long); + +long muh[] = {10, 3}; +long kuh[] = {2,6}; + + +RET(foo(muh, 10) == 1 && muh[1] == 3 && muh[0] == 3 && foo(kuh, 50) == 14 && kuh[0] == 6 && kuh[1] == 6 ); + diff --git a/codeb/skinner33_04.instr b/codeb/skinner33_04.instr new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/codeb/skinner33_04.instr @@ -0,0 +1 @@ +24 diff --git a/scripts/debug_codeb b/scripts/debug_codeb new file mode 100755 index 0000000..4991a16 --- /dev/null +++ b/scripts/debug_codeb @@ -0,0 +1,72 @@ +#!/bin/bash + +i=$1 +beispiel=codeb +PROGRAM=./$beispiel + +#LOC=. +LOC=/usr/ftp/pub/ubvl/test/$beispiel + +allow_null_glob_expansion=1 + +if [ ! -d ~/abgabe/$beispiel ]; then + echo "Fehler: Verzeichnis ~/abgabe/$beispiel existiert nicht." + exit 1 +else + cd ~/abgabe/$beispiel + echo 'Teste "make"' + make +fi + +if test ! -x $PROGRAM +then + echo "Fehler: Kein Programm $PROGRAM" + exit 1 +fi +let prgnum=0 +#for i in $LOC/*.0 $LOC2/*.0 +if [ -f $i ]; then + let prgnum=prgnum+1 + let errorfound=0 + echo "==========> Eingabe von $i:" + cat $i + echo + RESFILE=test${beispiel}out$$ + $PROGRAM <$i >$RESFILE + retval=$? + echo -n "Übersetzung: " + if test $retval -eq 0 + then + echo "Status korrekt" + else + echo "[Errot] Status=$retval. Erwartet: 0" + let errorfound=1 + fi + echo + echo "Ausgabe:" + if [ -f ~/test/scripts/clr.py ]; then + cat $RESFILE | ~/test/scripts/clr.py + else + cat $RESFILE + fi + mv -f $RESFILE $RESFILE.s + CALLFILE=${i%.*}.call + echo + if [ ! -f $CALLFILE ]; then + echo "Fehler: Datei $CALLFILE existiert nicht, kann Code nicht ausführen..." + exit 1 + else + echo "Übersetze und linke das Testprogramm:" + if cc -g -I. -DCALL=\"$CALLFILE\" $LOC/testmain.c $LOC/callingconvention.o $RESFILE.s; then + echo + echo "Rufe folgendes Codefragment auf:" + cat $CALLFILE + echo + gdb ./a.out + else + echo "[Error] Erzeugter Code konnte nicht assembliert und gelinkt werden." + let errorfound=1 + fi + fi + rm -f a.out $RESFILE $RESFILE.s +fi