diff options
Diffstat (limited to 'src/regress/lib/libc/arch')
| -rw-r--r-- | src/regress/lib/libc/arch/alpha/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/Makefile | 30 | ||||
| -rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/divremtest.c | 184 | ||||
| -rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/mkcases.c | 64 | ||||
| -rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c | 68 |
5 files changed, 355 insertions, 0 deletions
diff --git a/src/regress/lib/libc/arch/alpha/Makefile b/src/regress/lib/libc/arch/alpha/Makefile new file mode 100644 index 0000000000..8c4dfb735c --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.3 2002/02/23 01:25:11 art Exp $ | ||
| 2 | # $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $ | ||
| 3 | |||
| 4 | # do nothing here; none of the tests here can be run automatically | ||
| 5 | SUBDIR= | ||
| 6 | |||
| 7 | install: | ||
| 8 | |||
| 9 | .include <bsd.subdir.mk> | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/Makefile b/src/regress/lib/libc/arch/alpha/divremtest/Makefile new file mode 100644 index 0000000000..1da3ac8494 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/Makefile | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.2 2001/01/29 02:05:39 niklas Exp $ | ||
| 2 | # $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $ | ||
| 3 | |||
| 4 | PROG= divremtest | ||
| 5 | NOMAN= | ||
| 6 | |||
| 7 | CLEANFILES+= mkcases cases.c mktestcases testcases | ||
| 8 | |||
| 9 | divremtest.c: cases.c | ||
| 10 | |||
| 11 | cases.c: mkcases | ||
| 12 | /bin/rm -f cases.c | ||
| 13 | mkcases > cases.c | ||
| 14 | |||
| 15 | # a typical strategy to use this: | ||
| 16 | # compile a NetBSD divremtest binary, an OSF/1 divremtest binary, and an | ||
| 17 | # OSF/1 mktestcases binary. You then run mktestecases | divremtest -g | ||
| 18 | # on an OSF/1 machine, and pipe the output to an rsh to a NetBSD machine | ||
| 19 | # which then runs divremtest. You can test an infinite number of random | ||
| 20 | # values that way; I like to put a 'dd' in, so I can see how much I've done. | ||
| 21 | |||
| 22 | testcases: mktestcases divremtest | ||
| 23 | /bin/rm -f testcases | ||
| 24 | mktestcases | divremtest -g > testcases | ||
| 25 | |||
| 26 | regress: | ||
| 27 | @echo THIS TEST CANNOT BE RUN AUTOMATICALLY. | ||
| 28 | @false | ||
| 29 | |||
| 30 | .include <bsd.prog.mk> | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c new file mode 100644 index 0000000000..3d9e8a6de2 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | /* $OpenBSD: divremtest.c,v 1.2 2001/01/29 02:05:39 niklas Exp $ */ | ||
| 2 | /* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Copyright (c) 1995 Christopher G. Demetriou | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | * notice, this list of conditions and the following disclaimer in the | ||
| 15 | * documentation and/or other materials provided with the distribution. | ||
| 16 | * 3. All advertising materials mentioning features or use of this software | ||
| 17 | * must display the following acknowledgement: | ||
| 18 | * This product includes software developed by Christopher G. Demetriou | ||
| 19 | * for the NetBSD Project. | ||
| 20 | * 4. The name of the author may not be used to endorse or promote products | ||
| 21 | * derived from this software without specific prior written permission | ||
| 22 | * | ||
| 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 33 | */ | ||
| 34 | |||
| 35 | #include <stdio.h> | ||
| 36 | #include <unistd.h> | ||
| 37 | #include <signal.h> | ||
| 38 | |||
| 39 | void testfile(); | ||
| 40 | void usage(); | ||
| 41 | |||
| 42 | int generate; | ||
| 43 | |||
| 44 | int | ||
| 45 | main(argc, argv) | ||
| 46 | int argc; | ||
| 47 | char **argv; | ||
| 48 | { | ||
| 49 | int c; | ||
| 50 | |||
| 51 | signal(SIGFPE, SIG_IGN); | ||
| 52 | |||
| 53 | while ((c = getopt(argc, argv, "g")) != -1) | ||
| 54 | switch (c) { | ||
| 55 | case 'g': | ||
| 56 | generate = 1; | ||
| 57 | break; | ||
| 58 | |||
| 59 | default: | ||
| 60 | usage(); | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | |||
| 64 | argc -= optind; | ||
| 65 | argv += optind; | ||
| 66 | |||
| 67 | if (argc == 0) | ||
| 68 | testfile(); | ||
| 69 | else | ||
| 70 | for (; argc != 0; argc--, argv++) { | ||
| 71 | if (freopen(argv[0], "r", stdin) == NULL) { | ||
| 72 | fprintf(stderr, | ||
| 73 | "divremtest: couldn't open %s\n", | ||
| 74 | argv[0]); | ||
| 75 | exit(1); | ||
| 76 | } | ||
| 77 | |||
| 78 | testfile(); | ||
| 79 | } | ||
| 80 | |||
| 81 | exit(0); | ||
| 82 | } | ||
| 83 | |||
| 84 | void | ||
| 85 | testfile() | ||
| 86 | { | ||
| 87 | union operand { | ||
| 88 | unsigned long input; | ||
| 89 | int op_int; | ||
| 90 | unsigned int op_u_int; | ||
| 91 | long op_long; | ||
| 92 | unsigned long op_u_long; | ||
| 93 | } op1, op2, divres, modres, divwant, modwant; | ||
| 94 | char opspec[6]; | ||
| 95 | int encoded, i; | ||
| 96 | |||
| 97 | while (scanf("%6c %lx %lx %lx %lx\n", opspec, &op1.input, | ||
| 98 | &op2.input, &divwant.input, &modwant.input) != EOF) { | ||
| 99 | |||
| 100 | encoded = 0; | ||
| 101 | |||
| 102 | for (i = 0; i < 6; i += 2) { | ||
| 103 | int posval; | ||
| 104 | |||
| 105 | switch (opspec[i]) { | ||
| 106 | case '.': | ||
| 107 | posval = 0; | ||
| 108 | break; | ||
| 109 | case '-': | ||
| 110 | posval = 1; | ||
| 111 | break; | ||
| 112 | default: | ||
| 113 | fprintf(stderr, | ||
| 114 | "unknown signedness spec %c\n", | ||
| 115 | opspec[i]); | ||
| 116 | exit(1); | ||
| 117 | } | ||
| 118 | encoded |= posval << ((5 - i) * 4); | ||
| 119 | } | ||
| 120 | |||
| 121 | for (i = 1; i < 6; i += 2) { | ||
| 122 | int posval; | ||
| 123 | |||
| 124 | switch (opspec[i]) { | ||
| 125 | case 'i': | ||
| 126 | posval = 0; | ||
| 127 | break; | ||
| 128 | case 'l': | ||
| 129 | posval = 1; | ||
| 130 | break; | ||
| 131 | default: | ||
| 132 | fprintf(stderr, "unknown length spec %c\n", | ||
| 133 | opspec[i]); | ||
| 134 | exit(1); | ||
| 135 | } | ||
| 136 | encoded |= posval << ((5 - i) * 4); | ||
| 137 | } | ||
| 138 | |||
| 139 | /* KILL ME!!! */ | ||
| 140 | switch (encoded) { | ||
| 141 | |||
| 142 | #define TRY_IT(a, b, c) \ | ||
| 143 | divres.a = op1.b / op2.c; \ | ||
| 144 | modres.a = op1.b % op2.c; \ | ||
| 145 | if (generate) { \ | ||
| 146 | printf("%6s 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", \ | ||
| 147 | opspec, op1.input, op2.input, \ | ||
| 148 | divres.a, modres.a); \ | ||
| 149 | } else { \ | ||
| 150 | if ((divres.a != divwant.a) || \ | ||
| 151 | (modres.a != modwant.a)) { \ | ||
| 152 | fprintf(stderr, "%6s 0x%016lx 0x%016lx\n", \ | ||
| 153 | opspec, op1.input, op2.input); \ | ||
| 154 | fprintf(stderr, "FAILED:\n"); \ | ||
| 155 | fprintf(stderr, \ | ||
| 156 | "div:\twanted 0x%16lx, got 0x%16lx\n", \ | ||
| 157 | divwant.a, divres.a); \ | ||
| 158 | fprintf(stderr, \ | ||
| 159 | "mod:\twanted 0x%16lx, got 0x%16lx\n", \ | ||
| 160 | modwant.a, modres.a); \ | ||
| 161 | \ | ||
| 162 | exit(1); \ | ||
| 163 | } \ | ||
| 164 | } | ||
| 165 | |||
| 166 | #include "cases.c" | ||
| 167 | |||
| 168 | #undef TRY_IT | ||
| 169 | |||
| 170 | default: | ||
| 171 | fprintf(stderr, | ||
| 172 | "INTERNAL ERROR: unknown encoding %x\n", encoded); | ||
| 173 | exit(1); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | void | ||
| 179 | usage() | ||
| 180 | { | ||
| 181 | |||
| 182 | fprintf(stderr, "usage: divremtest [-v] [testfile ...]\n"); | ||
| 183 | exit(1); | ||
| 184 | } | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c new file mode 100644 index 0000000000..fcb4765b8c --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /* $OpenBSD: mkcases.c,v 1.2 2001/01/29 02:05:39 niklas Exp $ */ | ||
| 2 | /* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Copyright (c) 1995 Christopher G. Demetriou | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | * notice, this list of conditions and the following disclaimer in the | ||
| 15 | * documentation and/or other materials provided with the distribution. | ||
| 16 | * 3. All advertising materials mentioning features or use of this software | ||
| 17 | * must display the following acknowledgement: | ||
| 18 | * This product includes software developed by Christopher G. Demetriou | ||
| 19 | * for the NetBSD Project. | ||
| 20 | * 4. The name of the author may not be used to endorse or promote products | ||
| 21 | * derived from this software without specific prior written permission | ||
| 22 | * | ||
| 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 33 | */ | ||
| 34 | |||
| 35 | char *tab[4] = { "u_int", "int", "u_long", "long" }; | ||
| 36 | |||
| 37 | int | ||
| 38 | main() | ||
| 39 | { | ||
| 40 | int i; | ||
| 41 | |||
| 42 | for (i = 0; i < 64; i++) { | ||
| 43 | printf( | ||
| 44 | " case 0x%d%d%d%d%d%d: /* %s <= %s op %s */\n", | ||
| 45 | (i >> 5) & 1, | ||
| 46 | (i >> 4) & 1, | ||
| 47 | (i >> 3) & 1, | ||
| 48 | (i >> 2) & 1, | ||
| 49 | (i >> 1) & 1, | ||
| 50 | (i >> 0) & 1, | ||
| 51 | tab[(i >> 4) & 0x3], | ||
| 52 | tab[(i >> 2) & 0x3], | ||
| 53 | tab[(i >> 0) & 0x3]); | ||
| 54 | printf( | ||
| 55 | " TRY_IT(op_%s, op_%s, op_%s);\n", | ||
| 56 | tab[(i >> 4) & 0x3], | ||
| 57 | tab[(i >> 2) & 0x3], | ||
| 58 | tab[(i >> 0) & 0x3]); | ||
| 59 | printf( | ||
| 60 | " break;\n\n"); | ||
| 61 | } | ||
| 62 | |||
| 63 | exit(0); | ||
| 64 | } | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c new file mode 100644 index 0000000000..3b01653f32 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | /* $OpenBSD: mktestcases.c,v 1.2 2001/01/29 02:05:40 niklas Exp $ */ | ||
| 2 | /* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Copyright (c) 1995 Christopher G. Demetriou | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | * notice, this list of conditions and the following disclaimer in the | ||
| 15 | * documentation and/or other materials provided with the distribution. | ||
| 16 | * 3. All advertising materials mentioning features or use of this software | ||
| 17 | * must display the following acknowledgement: | ||
| 18 | * This product includes software developed by Christopher G. Demetriou | ||
| 19 | * for the NetBSD Project. | ||
| 20 | * 4. The name of the author may not be used to endorse or promote products | ||
| 21 | * derived from this software without specific prior written permission | ||
| 22 | * | ||
| 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
| 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 33 | */ | ||
| 34 | |||
| 35 | #include <stdio.h> | ||
| 36 | |||
| 37 | int | ||
| 38 | main() | ||
| 39 | { | ||
| 40 | int i, j; | ||
| 41 | unsigned long n1, n2; | ||
| 42 | |||
| 43 | srandom(time(NULL)); | ||
| 44 | |||
| 45 | for (i = 1; /* i < 10240 */ 1; i++) { | ||
| 46 | n1 = (unsigned) | ||
| 47 | (random() & ((random() & random()) | 0x80000000)); | ||
| 48 | n1 <<= 32; | ||
| 49 | n1 |= (unsigned)(random() & random() & random()); | ||
| 50 | |||
| 51 | n2 = (unsigned) | ||
| 52 | (random() & ((random() & random()) | 0x80000000)); | ||
| 53 | n2 <<= 32; | ||
| 54 | n2 |= (unsigned)(random() & random() & random()); | ||
| 55 | |||
| 56 | for (j = 0; j < 64; j++) { | ||
| 57 | char *tab[] = { ".i", ".l", "-i", "-l" }; | ||
| 58 | |||
| 59 | printf("%s%s%s 0x%lx 0x%lx 0 0\n", | ||
| 60 | tab[(j >> 4) & 0x3], | ||
| 61 | tab[(j >> 2) & 0x3], | ||
| 62 | tab[(j >> 0) & 0x3], | ||
| 63 | n1, n2); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | exit(0); | ||
| 68 | } | ||
