diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-14 17:18:29 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-14 17:18:29 +0000 |
commit | df0fc998b8139b916c2b268870b74849ca3f34d7 (patch) | |
tree | 5f1fdede28a1680ab527784f1f2e0a49c8a9a696 /tests | |
parent | MIPS: Fix tlbwi/tlbwr (diff) | |
download | qemu-kvm-df0fc998b8139b916c2b268870b74849ca3f34d7.tar.gz qemu-kvm-df0fc998b8139b916c2b268870b74849ca3f34d7.tar.bz2 qemu-kvm-df0fc998b8139b916c2b268870b74849ca3f34d7.zip |
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 <gingold@adacore.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5216 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests')
-rw-r--r-- | tests/alpha/Makefile | 29 | ||||
-rw-r--r-- | tests/alpha/crt.s | 23 | ||||
-rw-r--r-- | tests/alpha/hello-alpha.c | 5 | ||||
-rw-r--r-- | tests/alpha/test-cond.c | 87 |
4 files changed, 144 insertions, 0 deletions
diff --git a/tests/alpha/Makefile b/tests/alpha/Makefile new file mode 100644 index 000000000..9c321af8c --- /dev/null +++ b/tests/alpha/Makefile @@ -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 diff --git a/tests/alpha/crt.s b/tests/alpha/crt.s new file mode 100644 index 000000000..6f10b78b3 --- /dev/null +++ b/tests/alpha/crt.s @@ -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 diff --git a/tests/alpha/hello-alpha.c b/tests/alpha/hello-alpha.c new file mode 100644 index 000000000..79892e652 --- /dev/null +++ b/tests/alpha/hello-alpha.c @@ -0,0 +1,5 @@ +int main (void) +{ + write (1, "hello\n", 6); + return 0; +} diff --git a/tests/alpha/test-cond.c b/tests/alpha/test-cond.c new file mode 100644 index 000000000..74adffaa6 --- /dev/null +++ b/tests/alpha/test-cond.c @@ -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; +} |