Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KevF3-0006sU-J8 for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:18:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KevF2-0006s5-Uy for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:18:33 -0400 Received: from [199.232.76.173] (port=55091 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KevF2-0006rz-Px for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:18:32 -0400 Received: from savannah.gnu.org ([199.232.41.3]:57383 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KevF2-0005bk-J2 for qemu-devel@nongnu.org; Sun, 14 Sep 2008 13:18:32 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KevF1-000788-Oh for qemu-devel@nongnu.org; Sun, 14 Sep 2008 17:18:31 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KevF0-000782-Nt for qemu-devel@nongnu.org; Sun, 14 Sep 2008 17:18:31 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sun, 14 Sep 2008 17:18:30 +0000 Subject: [Qemu-devel] [5216] alpha: add tests Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5216 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5216 Author: aurel32 Date: 2008-09-14 17:18:29 +0000 (Sun, 14 Sep 2008) Log Message: ----------- alpha: add tests This patch creates tests/alpha directory and adds an "hello world" program as well as two tests. Signed-off-by: Tristan Gingold Signed-off-by: Aurelien Jarno Added Paths: ----------- trunk/tests/alpha/ trunk/tests/alpha/Makefile trunk/tests/alpha/crt.s trunk/tests/alpha/hello-alpha.c trunk/tests/alpha/test-cond.c Added: trunk/tests/alpha/Makefile =================================================================== --- trunk/tests/alpha/Makefile (rev 0) +++ trunk/tests/alpha/Makefile 2008-09-14 17:18:29 UTC (rev 5216) @@ -0,0 +1,29 @@ +CROSS=alpha-linux-gnu- +CC=$(CROSS)gcc +AS=$(CROSS)as + +SIM=../../alpha-linux-user/qemu-alpha + +CFLAGS=-O +LINK=$(CC) -v -o $@ crt.o $< -nostdlib + +TESTS=test-cond test-cmov + +all: hello-alpha $(TESTS) + +hello-alpha: hello-alpha.o crt.o + $(LINK) + +test-cond: test-cond.o crt.o + $(LINK) + +test-cmov.o: test-cond.c + $(CC) -c $(CFLAGS) -DTEST_CMOV -o $@ $< + +test-cmov: test-cmov.o crt.o + $(LINK) + +clean: + $(RM) *.o *~ hello-alpha $(TESTS) + +.PHONY: clean all Added: trunk/tests/alpha/crt.s =================================================================== --- trunk/tests/alpha/crt.s (rev 0) +++ trunk/tests/alpha/crt.s 2008-09-14 17:18:29 UTC (rev 5216) @@ -0,0 +1,23 @@ + .text + + .globl _start + .ent _start,0 +_start: + .frame $15,0,$15 + br $29,1f +1: ldgp $29, 0($29) + .prologue 0 + ldq $27,main($29) !literal!1 + jsr $26,($27) + + lda $0,1 + callsys + + call_pal 0 + .end _start + + .globl write +write: + lda $0,4 + callsys + ret Added: trunk/tests/alpha/hello-alpha.c =================================================================== --- trunk/tests/alpha/hello-alpha.c (rev 0) +++ trunk/tests/alpha/hello-alpha.c 2008-09-14 17:18:29 UTC (rev 5216) @@ -0,0 +1,5 @@ +int main (void) +{ + write (1, "hello\n", 6); + return 0; +} Added: trunk/tests/alpha/test-cond.c =================================================================== --- trunk/tests/alpha/test-cond.c (rev 0) +++ trunk/tests/alpha/test-cond.c 2008-09-14 17:18:29 UTC (rev 5216) @@ -0,0 +1,87 @@ + +#ifdef TEST_CMOV + +#define TEST_COND(N) \ +int test_##N (long a) \ +{ \ + int res = 1; \ + \ + asm ("cmov"#N" %1,$31,%0" \ + : "+r" (res) : "r" (a)); \ + return !res; \ +} + +#else + +#define TEST_COND(N) \ +int test_##N (long a) \ +{ \ + int res = 1; \ + \ + asm ("b"#N" %1,1f\n\t" \ + "addq $31,$31,%0\n\t" \ + "1: unop\n" \ + : "+r" (res) : "r" (a)); \ + return res; \ +} + +#endif + +TEST_COND(eq) +TEST_COND(ne) +TEST_COND(ge) +TEST_COND(gt) +TEST_COND(lbc) +TEST_COND(lbs) +TEST_COND(le) +TEST_COND(lt) + +static struct { + int (*func)(long); + long v; + int r; +} vectors[] = + { + {test_eq, 0, 1}, + {test_eq, 1, 0}, + + {test_ne, 0, 0}, + {test_ne, 1, 1}, + + {test_ge, 0, 1}, + {test_ge, 1, 1}, + {test_ge, -1, 0}, + + {test_gt, 0, 0}, + {test_gt, 1, 1}, + {test_gt, -1, 0}, + + {test_lbc, 0, 1}, + {test_lbc, 1, 0}, + {test_lbc, -1, 0}, + + {test_lbs, 0, 0}, + {test_lbs, 1, 1}, + {test_lbs, -1, 1}, + + {test_le, 0, 1}, + {test_le, 1, 0}, + {test_le, -1, 1}, + + {test_lt, 0, 0}, + {test_lt, 1, 0}, + {test_lt, -1, 1}, + }; + +int main (void) +{ + int i; + + for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++) + if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) { + write(1, "Failed\n", 7); + return 1; + } + write(1, "OK\n", 3); + return 0; +}