Remove the old alpha divrem test and replace it with a new indep one.

The old one was never run because it required a remote host. The new
one has more knowledge of where the error cases are likely to be, and
instead of using a big file or remote test system, it just keeps an
md5 (in the Makefile) of the endian-indep known-good results.
This commit is contained in:
ross 2002-01-22 01:19:25 +00:00
parent 6e4e75cdae
commit ce4e3aa2a0
9 changed files with 77 additions and 363 deletions

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.22 2001/09/22 19:57:42 simonb Exp $
# $NetBSD: Makefile,v 1.23 2002/01/22 01:19:25 ross Exp $
SUBDIR+= _setjmp clone db div gen hsearch int_fmtio md5sha popen regex rpc \
SUBDIR+= _setjmp clone db div divrem \
gen hsearch int_fmtio md5sha popen regex rpc \
setjmp sigsetjmp string sys time
.if (${MACHINE_ARCH} != "arm32" && ${MACHINE_ARCH} != "vax")
SUBDIR+= ieeefp

View File

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.4 1997/10/11 22:57:29 mycroft Exp $
# do nothing here; none of the tests here can be run automatically
#SUBDIR=
.include <bsd.subdir.mk>

View File

@ -1,4 +0,0 @@
# $NetBSD: Makefile.inc,v 1.2 1998/01/09 08:03:47 perry Exp $
#
# do not install regression test programs
proginstall::

View File

@ -1,29 +0,0 @@
# $NetBSD: Makefile,v 1.3 2001/12/12 01:24:00 tv Exp $
PROG= divremtest
NOMAN= # defined
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>

View File

@ -1,186 +0,0 @@
/* $NetBSD: divremtest.c,v 1.3 2000/06/14 17:25:19 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 for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#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);
}

View File

@ -1,66 +0,0 @@
/* $NetBSD: mkcases.c,v 1.3 2000/06/14 17:25:20 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 for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
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);
}

View File

@ -1,70 +0,0 @@
/* $NetBSD: mktestcases.c,v 1.3 2000/06/14 17:25:20 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 for the
* NetBSD Project. See http://www.netbsd.org/ for
* information about NetBSD.
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#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);
}

View File

@ -0,0 +1,11 @@
# $Id: Makefile,v 1.1 2002/01/22 01:19:31 ross Exp $
PROG= divremtest
NOMAN= # defined
COPTS+= -Wall -Wno-format -Wno-parentheses
GOODRESULT= a8c75451201482303e1508e3b9494879
regress: ${PROG}
[ `./${PROG} | md5` = ${GOODRESULT} ]
.include <bsd.prog.mk>

View File

@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#define IM(x) ((intmax_t)(x))
#define UIM(x) ((uintmax_t)(x))
#define TEST(id, a, b, c) \
if (b) { \
c = (a) / (b); \
printf(id "%16jx / %16jx => %16jx\n", UIM(a), UIM(b), UIM(c)); \
c = (a) % (b); \
printf(id "%16jx / %16jx => %16jx\n", UIM(a), UIM(b), UIM(c)); \
}
int main(int ac, char **av)
{
int32_t sr32;
uint32_t ur32;
intmax_t sr64;
uintmax_t ur64;
int i, j, k, l;
for(i = 0; i <= 31; ++i) {
for(j = 0; j <= 31; ++j) {
for(k = -1; k <= 1; ++k) {
for(l = -1; l <= 1; ++l) {
TEST("32 ", (1 << i) + k, (1 << j) + l, sr32);
TEST("32 ", (1 << i) + k, -(1 << j) + l, sr32);
TEST("32 ", -(1 << i) + k, (1 << j) + l, sr32);
TEST("32 ", -(1 << i) + k, -(1 << j) + l, sr32);
if (k < 0 && 1U << i < abs(k) ||
l < 0 && 1U << j < abs(l))
continue;
TEST("32U", (1U << i) + k, (1U << j) + l, ur32);
}
}
}
}
if (sizeof(intmax_t) == 4)
exit(0);
for(i = 0; i <= 63; ++i) {
for(j = 0; j <= 63; ++j) {
for(k = -1; k <= 1; ++k) {
for(l = -1; l <= 1; ++l) {
TEST("64 ", (IM(1) << i) + k, (IM(1) << j) + l, sr64);
TEST("64 ", (IM(1) << i) + k, -(IM(1) << j) + l, sr64);
TEST("64 ", -(IM(1) << i) + k, (IM(1) << j) + l, sr64);
TEST("64 ", -(IM(1) << i) + k, -(IM(1) << j) + l, sr64);
if (k < 0 && UIM(1U) << i < abs(k) ||
l < 0 && UIM(1U) << j < abs(l))
continue;
TEST("64U", (UIM(1U) << i) + k, (UIM(1U) << j) + l, ur64);
}
}
}
}
exit(0);
return 0;
}