diff options
Diffstat (limited to 'regress/lib/libc/arch/alpha')
-rw-r--r-- | regress/lib/libc/arch/alpha/Makefile | 10 | ||||
-rw-r--r-- | regress/lib/libc/arch/alpha/divremtest/Makefile | 29 | ||||
-rw-r--r-- | regress/lib/libc/arch/alpha/divremtest/divremtest.c | 183 | ||||
-rw-r--r-- | regress/lib/libc/arch/alpha/divremtest/mkcases.c | 63 | ||||
-rw-r--r-- | regress/lib/libc/arch/alpha/divremtest/mktestcases.c | 67 |
5 files changed, 352 insertions, 0 deletions
diff --git a/regress/lib/libc/arch/alpha/Makefile b/regress/lib/libc/arch/alpha/Makefile new file mode 100644 index 00000000000..b79a82b0e2e --- /dev/null +++ b/regress/lib/libc/arch/alpha/Makefile @@ -0,0 +1,10 @@ +# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $ + +# do nothing here; none of the tests here can be run automatically +SUBDIR= + +regress: _SUBDIRUSE + +install: + +.include <bsd.subdir.mk> diff --git a/regress/lib/libc/arch/alpha/divremtest/Makefile b/regress/lib/libc/arch/alpha/divremtest/Makefile new file mode 100644 index 00000000000..bd3b12f5373 --- /dev/null +++ b/regress/lib/libc/arch/alpha/divremtest/Makefile @@ -0,0 +1,29 @@ +# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $ + +PROG= divremtest +NOMAN= + +CLEANFILES+= mkcases cases.c mktestcases testcases + +divremtest.c: cases.c + +cases.c: mkcases + /bin/rm -f cases.c + mkcases > cases.c + +# a typical strategy to use this: +# compile a NetBSD divremtest binary, an OSF/1 divremtest binary, and an +# OSF/1 mktestcases binary. You then run mktestecases | divremtest -g +# on an OSF/1 machine, and pipe the output to an rsh to a NetBSD machine +# which then runs divremtest. You can test an infinite number of random +# values that way; I like to put a 'dd' in, so I can see how much I've done. + +testcases: mktestcases divremtest + /bin/rm -f testcases + mktestcases | divremtest -g > testcases + +regress: + @echo THIS TEST CANNOT BE RUN AUTOMATICALLY. + @false + +.include <bsd.prog.mk> diff --git a/regress/lib/libc/arch/alpha/divremtest/divremtest.c b/regress/lib/libc/arch/alpha/divremtest/divremtest.c new file mode 100644 index 00000000000..fcf64c93845 --- /dev/null +++ b/regress/lib/libc/arch/alpha/divremtest/divremtest.c @@ -0,0 +1,183 @@ +/* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */ + +/* + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <unistd.h> +#include <signal.h> + +void testfile(); +void usage(); + +int generate; + +int +main(argc, argv) + int argc; + char **argv; +{ + int c; + + signal(SIGFPE, SIG_IGN); + + while ((c = getopt(argc, argv, "g")) != -1) + switch (c) { + case 'g': + generate = 1; + break; + + default: + usage(); + break; + } + + argc -= optind; + argv += optind; + + if (argc == 0) + testfile(); + else + for (; argc != 0; argc--, argv++) { + if (freopen(argv[0], "r", stdin) == NULL) { + fprintf(stderr, + "divremtest: couldn't open %s\n", + argv[0]); + exit(1); + } + + testfile(); + } + + exit(0); +} + +void +testfile() +{ + union operand { + unsigned long input; + int op_int; + unsigned int op_u_int; + long op_long; + unsigned long op_u_long; + } op1, op2, divres, modres, divwant, modwant; + char opspec[6]; + int encoded, i; + + while (scanf("%6c %lx %lx %lx %lx\n", opspec, &op1.input, + &op2.input, &divwant.input, &modwant.input) != EOF) { + + encoded = 0; + + for (i = 0; i < 6; i += 2) { + int posval; + + switch (opspec[i]) { + case '.': + posval = 0; + break; + case '-': + posval = 1; + break; + default: + fprintf(stderr, + "unknown signedness spec %c\n", + opspec[i]); + exit(1); + } + encoded |= posval << ((5 - i) * 4); + } + + for (i = 1; i < 6; i += 2) { + int posval; + + switch (opspec[i]) { + case 'i': + posval = 0; + break; + case 'l': + posval = 1; + break; + default: + fprintf(stderr, "unknown length spec %c\n", + opspec[i]); + exit(1); + } + encoded |= posval << ((5 - i) * 4); + } + + /* KILL ME!!! */ + switch (encoded) { + +#define TRY_IT(a, b, c) \ + divres.a = op1.b / op2.c; \ + modres.a = op1.b % op2.c; \ + if (generate) { \ + printf("%6s 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", \ + opspec, op1.input, op2.input, \ + divres.a, modres.a); \ + } else { \ + if ((divres.a != divwant.a) || \ + (modres.a != modwant.a)) { \ + fprintf(stderr, "%6s 0x%016lx 0x%016lx\n", \ + opspec, op1.input, op2.input); \ + fprintf(stderr, "FAILED:\n"); \ + fprintf(stderr, \ + "div:\twanted 0x%16lx, got 0x%16lx\n", \ + divwant.a, divres.a); \ + fprintf(stderr, \ + "mod:\twanted 0x%16lx, got 0x%16lx\n", \ + modwant.a, modres.a); \ + \ + exit(1); \ + } \ + } + +#include "cases.c" + +#undef TRY_IT + + default: + fprintf(stderr, + "INTERNAL ERROR: unknown encoding %x\n", encoded); + exit(1); + } + } +} + +void +usage() +{ + + fprintf(stderr, "usage: divremtest [-v] [testfile ...]\n"); + exit(1); +} diff --git a/regress/lib/libc/arch/alpha/divremtest/mkcases.c b/regress/lib/libc/arch/alpha/divremtest/mkcases.c new file mode 100644 index 00000000000..65ca17af4c6 --- /dev/null +++ b/regress/lib/libc/arch/alpha/divremtest/mkcases.c @@ -0,0 +1,63 @@ +/* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */ + +/* + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +char *tab[4] = { "u_int", "int", "u_long", "long" }; + +int +main() +{ + int i; + + for (i = 0; i < 64; i++) { + printf( +" case 0x%d%d%d%d%d%d: /* %s <= %s op %s */\n", + (i >> 5) & 1, + (i >> 4) & 1, + (i >> 3) & 1, + (i >> 2) & 1, + (i >> 1) & 1, + (i >> 0) & 1, + tab[(i >> 4) & 0x3], + tab[(i >> 2) & 0x3], + tab[(i >> 0) & 0x3]); + printf( +" TRY_IT(op_%s, op_%s, op_%s);\n", + tab[(i >> 4) & 0x3], + tab[(i >> 2) & 0x3], + tab[(i >> 0) & 0x3]); + printf( +" break;\n\n"); + } + + exit(0); +} diff --git a/regress/lib/libc/arch/alpha/divremtest/mktestcases.c b/regress/lib/libc/arch/alpha/divremtest/mktestcases.c new file mode 100644 index 00000000000..ef02d61d701 --- /dev/null +++ b/regress/lib/libc/arch/alpha/divremtest/mktestcases.c @@ -0,0 +1,67 @@ +/* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */ + +/* + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> + +int +main() +{ + int i, j; + unsigned long n1, n2; + + srandom(time(NULL)); + + for (i = 1; /* i < 10240 */ 1; i++) { + n1 = (unsigned) + (random() & ((random() & random()) | 0x80000000)); + n1 <<= 32; + n1 |= (unsigned)(random() & random() & random()); + + n2 = (unsigned) + (random() & ((random() & random()) | 0x80000000)); + n2 <<= 32; + n2 |= (unsigned)(random() & random() & random()); + + for (j = 0; j < 64; j++) { + char *tab[] = { ".i", ".l", "-i", "-l" }; + + printf("%s%s%s 0x%lx 0x%lx 0 0\n", + tab[(j >> 4) & 0x3], + tab[(j >> 2) & 0x3], + tab[(j >> 0) & 0x3], + n1, n2); + } + } + + exit(0); +} |