Make all tests use common.c
This will make sure that all file descriptors are closed through the use of the start() function.
This commit is contained in:
parent
de5a9a3e8b
commit
3fb6c995e0
@ -25,6 +25,7 @@ void start(test_nr)
|
|||||||
int test_nr;
|
int test_nr;
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
int i;
|
||||||
|
|
||||||
common_test_nr = test_nr;
|
common_test_nr = test_nr;
|
||||||
printf("Test %2d ", test_nr);
|
printf("Test %2d ", test_nr);
|
||||||
@ -41,6 +42,11 @@ int test_nr;
|
|||||||
e(6666);
|
e(6666);
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 3; i < OPEN_MAX; ++i) {
|
||||||
|
/* Close all files except stdin, stdout, and stderr */
|
||||||
|
(void) close(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int does_fs_truncate(void)
|
int does_fs_truncate(void)
|
||||||
|
25
test/test1.c
25
test/test1.c
@ -15,6 +15,7 @@
|
|||||||
_VOLATILE int glov, gct;
|
_VOLATILE int glov, gct;
|
||||||
int errct;
|
int errct;
|
||||||
int subtest;
|
int subtest;
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char *argv []));
|
_PROTOTYPE(int main, (int argc, char *argv []));
|
||||||
_PROTOTYPE(void test1a, (void));
|
_PROTOTYPE(void test1a, (void));
|
||||||
@ -24,8 +25,6 @@ _PROTOTYPE(void test1b, (void));
|
|||||||
_PROTOTYPE(void parent1, (int childpid));
|
_PROTOTYPE(void parent1, (int childpid));
|
||||||
_PROTOTYPE(void func, (int s));
|
_PROTOTYPE(void func, (int s));
|
||||||
_PROTOTYPE(void child1, (void));
|
_PROTOTYPE(void child1, (void));
|
||||||
_PROTOTYPE(void e, (int n));
|
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
int main(argc, argv)
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -33,16 +32,10 @@ char *argv[];
|
|||||||
{
|
{
|
||||||
int i, m = 0xFFFF;
|
int i, m = 0xFFFF;
|
||||||
|
|
||||||
sync();
|
start(1);
|
||||||
|
|
||||||
if (argc == 2) m = atoi(argv[1]);
|
if (argc == 2) m = atoi(argv[1]);
|
||||||
|
|
||||||
printf("Test 1 ");
|
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
|
||||||
system("rm -rf DIR_01; mkdir DIR_01");
|
|
||||||
chdir("DIR_01");
|
|
||||||
|
|
||||||
for (i = 0; i < ITERATIONS; i++) {
|
for (i = 0; i < ITERATIONS; i++) {
|
||||||
if (m & 00001) test1a();
|
if (m & 00001) test1a();
|
||||||
if (m & 00002) test1b();
|
if (m & 00002) test1b();
|
||||||
@ -132,17 +125,3 @@ void child1()
|
|||||||
exit(gct);
|
exit(gct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
char *name[] = {"t10a", "t10b", "t10c", "t10d", "t10e", "t10f", "t10g",
|
char *name[] = {"t10a", "t10b", "t10c", "t10d", "t10e", "t10f", "t10g",
|
||||||
"t10h", "t10i", "t10j"};
|
"t10h", "t10i", "t10j"};
|
||||||
int errct;
|
|
||||||
long prog[300];
|
long prog[300];
|
||||||
int psize;
|
int psize;
|
||||||
|
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (void));
|
_PROTOTYPE(int main, (void));
|
||||||
_PROTOTYPE(void spawn, (int n));
|
_PROTOTYPE(void spawn, (int n));
|
||||||
_PROTOTYPE(void mkfiles, (void));
|
_PROTOTYPE(void mkfiles, (void));
|
||||||
@ -25,12 +27,8 @@ int main()
|
|||||||
{
|
{
|
||||||
int i, n, pid, r;
|
int i, n, pid, r;
|
||||||
|
|
||||||
printf("Test 10 ");
|
start(10);
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
system("cp ../t10a .");
|
||||||
|
|
||||||
system("rm -rf DIR_10; mkdir DIR_10; cp t10a DIR_10");
|
|
||||||
chdir("DIR_10");
|
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
|
||||||
/* Create files t10b ... t10h */
|
/* Create files t10b ... t10h */
|
||||||
@ -136,17 +134,3 @@ void rmfiles()
|
|||||||
unlink("t10j");
|
unlink("t10j");
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -17,12 +17,13 @@ int errct, subtest;
|
|||||||
char *envp[3] = {"spring", "summer", 0};
|
char *envp[3] = {"spring", "summer", 0};
|
||||||
char *passwd_file = "/etc/passwd";
|
char *passwd_file = "/etc/passwd";
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char *argv[]));
|
_PROTOTYPE(int main, (int argc, char *argv[]));
|
||||||
_PROTOTYPE(void test11a, (void));
|
_PROTOTYPE(void test11a, (void));
|
||||||
_PROTOTYPE(void test11b, (void));
|
_PROTOTYPE(void test11b, (void));
|
||||||
_PROTOTYPE(void test11c, (void));
|
_PROTOTYPE(void test11c, (void));
|
||||||
_PROTOTYPE(void test11d, (void));
|
_PROTOTYPE(void test11d, (void));
|
||||||
_PROTOTYPE(void e, (int n));
|
|
||||||
|
|
||||||
int main(argc, argv)
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -32,8 +33,10 @@ char *argv[];
|
|||||||
|
|
||||||
if (argc == 2) m = atoi(argv[1]);
|
if (argc == 2) m = atoi(argv[1]);
|
||||||
|
|
||||||
printf("Test 11 ");
|
start(11);
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
system("cp ../t11a .");
|
||||||
|
system("cp ../t11b .");
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
printf("must be setuid root; test aborted\n");
|
printf("must be setuid root; test aborted\n");
|
||||||
@ -44,27 +47,14 @@ char *argv[];
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
system("rm -rf DIR_11; mkdir DIR_11");
|
|
||||||
chdir("DIR_11");
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (i = 0; i < ITERATIONS; i++) {
|
for (i = 0; i < ITERATIONS; i++) {
|
||||||
if (m & 0001) test11a();
|
if (m & 0001) test11a();
|
||||||
if (m & 0002) test11b();
|
if (m & 0002) test11b();
|
||||||
if (m & 0004) test11c();
|
if (m & 0004) test11c();
|
||||||
if (m & 0010) test11d();
|
if (m & 0010) test11d();
|
||||||
}
|
}
|
||||||
if (errct == 0)
|
quit();
|
||||||
printf("ok\n");
|
return(-1);
|
||||||
else
|
|
||||||
printf(" %d errors\n", errct);
|
|
||||||
|
|
||||||
/*
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR_11");
|
|
||||||
*/
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test11a()
|
void test11a()
|
||||||
@ -208,18 +198,3 @@ void test11d()
|
|||||||
if (unlink("T11.1") != 0) e(7);
|
if (unlink("T11.1") != 0) e(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int err_num = errno; /* save errno in case printf clobbers it */
|
|
||||||
|
|
||||||
printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
|
|
||||||
errno = err_num; /* restore errno, just in case */
|
|
||||||
perror("");
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,22 +10,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define NUM_TIMES 1000
|
#define NUM_TIMES 1000
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
|
||||||
int errct = 0;
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (void));
|
_PROTOTYPE(int main, (void));
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
printf("Test 12 ");
|
start(12);
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
|
||||||
system("rm -rf DIR_12; mkdir DIR_12");
|
|
||||||
chdir("DIR_12");
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_TIMES; i++) switch (fork()) {
|
for (i = 0; i < NUM_TIMES; i++) switch (fork()) {
|
||||||
case 0: exit(1); break;
|
case 0: exit(1); break;
|
||||||
@ -39,17 +35,3 @@ int main()
|
|||||||
return(-1); /* impossible */
|
return(-1); /* impossible */
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -15,9 +15,11 @@
|
|||||||
#define BLOCK_SIZE 1000
|
#define BLOCK_SIZE 1000
|
||||||
#define NUM_BLOCKS 1000
|
#define NUM_BLOCKS 1000
|
||||||
|
|
||||||
int errct = 0;
|
|
||||||
char buffer[BLOCK_SIZE];
|
char buffer[BLOCK_SIZE];
|
||||||
|
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (void));
|
_PROTOTYPE(int main, (void));
|
||||||
_PROTOTYPE(void quit, (void));
|
_PROTOTYPE(void quit, (void));
|
||||||
|
|
||||||
@ -25,13 +27,8 @@ int main()
|
|||||||
{
|
{
|
||||||
int stat_loc, pipefd[2];
|
int stat_loc, pipefd[2];
|
||||||
register int i;
|
register int i;
|
||||||
pipe(pipefd);
|
|
||||||
|
|
||||||
printf("Test 13 ");
|
start(13);
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
|
||||||
system("rm -rf DIR_13; mkdir DIR_13");
|
|
||||||
chdir("DIR_13");
|
|
||||||
|
|
||||||
pipe(pipefd);
|
pipe(pipefd);
|
||||||
|
|
||||||
@ -56,17 +53,3 @@ int main()
|
|||||||
return(-1); /* impossible */
|
return(-1); /* impossible */
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -11,9 +11,10 @@
|
|||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
|
|
||||||
char name[20] = {"TMP14."};
|
char name[20] = {"TMP14."};
|
||||||
int errct;
|
|
||||||
int subtest = 1;
|
int subtest = 1;
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (void));
|
_PROTOTYPE(int main, (void));
|
||||||
_PROTOTYPE(void e, (int n));
|
_PROTOTYPE(void e, (int n));
|
||||||
_PROTOTYPE(void quit, (void));
|
_PROTOTYPE(void quit, (void));
|
||||||
@ -22,11 +23,7 @@ int main()
|
|||||||
{
|
{
|
||||||
int fd0, i, pid;
|
int fd0, i, pid;
|
||||||
|
|
||||||
printf("Test 14 ");
|
start(14);
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
system("rm -rf DIR_14; mkdir DIR_14");
|
|
||||||
chdir("DIR_14");
|
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
sprintf(&name[6], "%x", pid);
|
sprintf(&name[6], "%x", pid);
|
||||||
@ -45,33 +42,3 @@ int main()
|
|||||||
return(-1); /* impossible */
|
return(-1); /* impossible */
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int err_num = errno; /* save errno in case printf clobbers it */
|
|
||||||
|
|
||||||
printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
|
|
||||||
errno = err_num; /* restore errno, just in case */
|
|
||||||
perror("");
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
_PROTOTYPE( int chdir, (char *_path)); /* from <unistd.h> */
|
|
||||||
|
|
||||||
#define STREQ(a, b) (strcmp((a), (b)) == 0)
|
#define STREQ(a, b) (strcmp((a), (b)) == 0)
|
||||||
|
|
||||||
@ -24,12 +23,14 @@ int waserror = 0; /* For exit status. */
|
|||||||
char uctest[] = "\004\203"; /* For testing signedness of chars. */
|
char uctest[] = "\004\203"; /* For testing signedness of chars. */
|
||||||
int charsigned; /* Result. */
|
int charsigned; /* Result. */
|
||||||
|
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(void check, (int thing, int number));
|
_PROTOTYPE(void check, (int thing, int number));
|
||||||
_PROTOTYPE(void equal, (char *a, char *b, int number));
|
_PROTOTYPE(void equal, (char *a, char *b, int number));
|
||||||
_PROTOTYPE(int main, (int argc, char *argv []));
|
_PROTOTYPE(int main, (int argc, char *argv []));
|
||||||
_PROTOTYPE(void first, (void));
|
_PROTOTYPE(void first, (void));
|
||||||
_PROTOTYPE(void second, (void));
|
_PROTOTYPE(void second, (void));
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- check - complain if condition is not true
|
- check - complain if condition is not true
|
||||||
@ -76,11 +77,9 @@ int main(argc, argv)
|
|||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
printf("Test 15 ");
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
system("rm -rf DIR_15; mkdir DIR_15");
|
start(15);
|
||||||
chdir("DIR_15");
|
|
||||||
/* First, establish whether chars are signed. */
|
/* First, establish whether chars are signed. */
|
||||||
if (uctest[0] < uctest[1])
|
if (uctest[0] < uctest[1])
|
||||||
charsigned = 0;
|
charsigned = 0;
|
||||||
@ -688,17 +687,3 @@ void second()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
|
|
||||||
int errct, subtest, passes;
|
int subtest, passes;
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char *argv []));
|
_PROTOTYPE(int main, (int argc, char *argv []));
|
||||||
_PROTOTYPE(void test16a, (void));
|
_PROTOTYPE(void test16a, (void));
|
||||||
_PROTOTYPE(void get_times, (char *name, time_t *a, time_t *c, time_t *m));
|
_PROTOTYPE(void get_times, (char *name, time_t *a, time_t *c, time_t *m));
|
||||||
_PROTOTYPE(void e, (int n));
|
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
int main(argc, argv)
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -25,13 +25,11 @@ char *argv[];
|
|||||||
{
|
{
|
||||||
int i, m;
|
int i, m;
|
||||||
|
|
||||||
|
start(16);
|
||||||
|
|
||||||
m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
|
m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
|
||||||
|
|
||||||
system("rm -rf DIR_16; mkdir DIR_16");
|
|
||||||
chdir("DIR_16");
|
|
||||||
|
|
||||||
printf("Test 16 ");
|
|
||||||
fflush(stdout);
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (m & 0001) test16a();
|
if (m & 0001) test16a();
|
||||||
passes++;
|
passes++;
|
||||||
@ -227,34 +225,3 @@ time_t *a, *c, *m;
|
|||||||
*m = s.st_mtime;
|
*m = s.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int err_num = errno; /* save errno in case printf clobbers it */
|
|
||||||
|
|
||||||
printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
|
|
||||||
errno = err_num; /* restore errno, just in case */
|
|
||||||
perror("");
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
630
test/test17.c
630
test/test17.c
File diff suppressed because it is too large
Load Diff
656
test/test18.c
656
test/test18.c
File diff suppressed because it is too large
Load Diff
48
test/test2.c
48
test/test2.c
@ -13,10 +13,12 @@
|
|||||||
#define ITERATIONS 5
|
#define ITERATIONS 5
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
|
|
||||||
int is, array[4], parsigs, parcum, sigct, cumsig, errct, subtest;
|
int is, array[4], parsigs, parcum, sigct, cumsig, subtest;
|
||||||
int iteration, kk = 0, errct = 0;
|
int iteration, kk = 0;
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char *argv []));
|
_PROTOTYPE(int main, (int argc, char *argv []));
|
||||||
_PROTOTYPE(void test2a, (void));
|
_PROTOTYPE(void test2a, (void));
|
||||||
_PROTOTYPE(void test2b, (void));
|
_PROTOTYPE(void test2b, (void));
|
||||||
@ -26,8 +28,6 @@ _PROTOTYPE(void test2e, (void));
|
|||||||
_PROTOTYPE(void test2f, (void));
|
_PROTOTYPE(void test2f, (void));
|
||||||
_PROTOTYPE(void test2g, (void));
|
_PROTOTYPE(void test2g, (void));
|
||||||
_PROTOTYPE(void sigpip, (int s));
|
_PROTOTYPE(void sigpip, (int s));
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
_PROTOTYPE(void e, (int n));
|
|
||||||
|
|
||||||
int main(argc, argv)
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -35,15 +35,7 @@ char *argv[];
|
|||||||
{
|
{
|
||||||
int i, m = 0xFFFF;
|
int i, m = 0xFFFF;
|
||||||
|
|
||||||
sync();
|
start(2);
|
||||||
|
|
||||||
if (argc == 2) m = atoi(argv[1]);
|
|
||||||
|
|
||||||
printf("Test 2 ");
|
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
|
||||||
system("rm -rf DIR_02; mkdir DIR_02");
|
|
||||||
chdir("DIR_02");
|
|
||||||
|
|
||||||
for (i = 0; i < ITERATIONS; i++) {
|
for (i = 0; i < ITERATIONS; i++) {
|
||||||
iteration = i;
|
iteration = i;
|
||||||
@ -362,33 +354,3 @@ int s; /* for ANSI */
|
|||||||
cumsig++;
|
cumsig++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void e(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int err_num = errno; /* save errno in case printf clobbers it */
|
|
||||||
|
|
||||||
printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
|
|
||||||
errno = err_num; /* restore errno, just in case */
|
|
||||||
perror("");
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
28
test/test4.c
28
test/test4.c
@ -8,12 +8,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
pid_t pid0, pid1, pid2, pid3;
|
pid_t pid0, pid1, pid2, pid3;
|
||||||
int s, i, fd, nextb, errct = 0;
|
int s, i, fd, nextb;
|
||||||
char *tempfile = "test4.temp";
|
char *tempfile = "test4.temp";
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
extern int errno;
|
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
_PROTOTYPE(int main, (void));
|
_PROTOTYPE(int main, (void));
|
||||||
_PROTOTYPE(void subr, (void));
|
_PROTOTYPE(void subr, (void));
|
||||||
@ -24,11 +28,7 @@ int main()
|
|||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
printf("Test 4 ");
|
start(4);
|
||||||
fflush(stdout); /* have to flush for child's benefit */
|
|
||||||
|
|
||||||
system("rm -rf DIR_04; mkdir DIR_04");
|
|
||||||
chdir("DIR_04");
|
|
||||||
|
|
||||||
creat(tempfile, 0777);
|
creat(tempfile, 0777);
|
||||||
for (k = 0; k < 20; k++) {
|
for (k = 0; k < 20; k++) {
|
||||||
@ -87,17 +87,3 @@ void nofork()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
158
test/test41.c
158
test/test41.c
@ -17,6 +17,8 @@
|
|||||||
#define ITERATIONS 3
|
#define ITERATIONS 3
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
/* we have to keep in mind the millisecond values are rounded up */
|
/* we have to keep in mind the millisecond values are rounded up */
|
||||||
#define UPPERUSEC(us) ((us)+(1000000/system_hz))
|
#define UPPERUSEC(us) ((us)+(1000000/system_hz))
|
||||||
#define EQUSEC(l,r) \
|
#define EQUSEC(l,r) \
|
||||||
@ -53,13 +55,11 @@ _PROTOTYPE(void test_exec, (void));
|
|||||||
_PROTOTYPE(int do_check, (void));
|
_PROTOTYPE(int do_check, (void));
|
||||||
_PROTOTYPE(void got_alarm, (int sig));
|
_PROTOTYPE(void got_alarm, (int sig));
|
||||||
_PROTOTYPE(void busy_wait, (int secs));
|
_PROTOTYPE(void busy_wait, (int secs));
|
||||||
_PROTOTYPE(void e, (int n));
|
_PROTOTYPE(void my_e, (int n));
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
static char *executable;
|
static char *executable;
|
||||||
static int signals;
|
static int signals;
|
||||||
static int timer;
|
static int timer;
|
||||||
static int errct = 0, subtest;
|
|
||||||
static long system_hz;
|
static long system_hz;
|
||||||
|
|
||||||
static int sigs[] = { SIGALRM, SIGVTALRM, SIGPROF };
|
static int sigs[] = { SIGALRM, SIGVTALRM, SIGPROF };
|
||||||
@ -70,6 +70,7 @@ int argc;
|
|||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
int i, m = 0xFFFF, n = 0xF;
|
int i, m = 0xFFFF, n = 0xF;
|
||||||
|
char cp_cmd[NAME_MAX+10];
|
||||||
|
|
||||||
system_hz = sysconf(_SC_CLK_TCK);
|
system_hz = sysconf(_SC_CLK_TCK);
|
||||||
|
|
||||||
@ -79,11 +80,13 @@ char **argv;
|
|||||||
exit(do_check());
|
exit(do_check());
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Test 41 ");
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
executable = argv[0];
|
executable = argv[0];
|
||||||
|
|
||||||
|
start(41);
|
||||||
|
|
||||||
|
snprintf(cp_cmd, sizeof(cp_cmd), "cp ../%s .", executable);
|
||||||
|
system(cp_cmd);
|
||||||
|
|
||||||
if (argc >= 2) m = atoi(argv[1]);
|
if (argc >= 2) m = atoi(argv[1]);
|
||||||
if (argc >= 3) n = atoi(argv[2]);
|
if (argc >= 3) n = atoi(argv[2]);
|
||||||
|
|
||||||
@ -120,9 +123,9 @@ void test_which()
|
|||||||
|
|
||||||
subtest = 0;
|
subtest = 0;
|
||||||
|
|
||||||
errno = 0; if (!getitimer(-1, &it) || errno != EINVAL) e(1);
|
errno = 0; if (!getitimer(-1, &it) || errno != EINVAL) my_e(1);
|
||||||
errno = 0; if ( getitimer(timer, &it) ) e(2);
|
errno = 0; if ( getitimer(timer, &it) ) my_e(2);
|
||||||
errno = 0; if (!getitimer( 3, &it) || errno != EINVAL) e(3);
|
errno = 0; if (!getitimer( 3, &it) || errno != EINVAL) my_e(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test if we get back what we set */
|
/* test if we get back what we set */
|
||||||
@ -133,29 +136,29 @@ void test_getset()
|
|||||||
subtest = 1;
|
subtest = 1;
|
||||||
|
|
||||||
/* no alarm should be set initially */
|
/* no alarm should be set initially */
|
||||||
if (getitimer(timer, &it)) e(1);
|
if (getitimer(timer, &it)) my_e(1);
|
||||||
if (!EQITIMER(it, 0, 0, 0, 0)) e(2);
|
if (!EQITIMER(it, 0, 0, 0, 0)) my_e(2);
|
||||||
|
|
||||||
if (setitimer(timer, &it, &oit)) e(3);
|
if (setitimer(timer, &it, &oit)) my_e(3);
|
||||||
if (setitimer(timer, &oit, NULL)) e(4);
|
if (setitimer(timer, &oit, NULL)) my_e(4);
|
||||||
if (!EQITIMER(oit, 0, 0, 0, 0)) e(5);
|
if (!EQITIMER(oit, 0, 0, 0, 0)) my_e(5);
|
||||||
|
|
||||||
FILLITIMER(it, 123, 0, 456, 0);
|
FILLITIMER(it, 123, 0, 456, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(6);
|
if (setitimer(timer, &it, NULL)) my_e(6);
|
||||||
|
|
||||||
FILLITIMER(it, 987, 0, 654, 0);
|
FILLITIMER(it, 987, 0, 654, 0);
|
||||||
if (setitimer(timer, &it, &oit)) e(7);
|
if (setitimer(timer, &it, &oit)) my_e(7);
|
||||||
if (!LEITIMER(oit, 123, 0, 456, 0)) e(8);
|
if (!LEITIMER(oit, 123, 0, 456, 0)) my_e(8);
|
||||||
|
|
||||||
if (getitimer(timer, &oit)) e(9);
|
if (getitimer(timer, &oit)) my_e(9);
|
||||||
if (!LEITIMER(oit, 987, 0, 654, 0)) e(10);
|
if (!LEITIMER(oit, 987, 0, 654, 0)) my_e(10);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, 0);
|
FILLITIMER(it, 0, 0, 0, 0);
|
||||||
if (setitimer(timer, &it, &oit)) e(11);
|
if (setitimer(timer, &it, &oit)) my_e(11);
|
||||||
if (!LEITIMER(oit, 987, 0, 654, 0)) e(12);
|
if (!LEITIMER(oit, 987, 0, 654, 0)) my_e(12);
|
||||||
|
|
||||||
if (getitimer(timer, &oit)) e(13);
|
if (getitimer(timer, &oit)) my_e(13);
|
||||||
if (!EQITIMER(oit, 0, 0, 0, 0)) e(14);
|
if (!EQITIMER(oit, 0, 0, 0, 0)) my_e(14);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test negative/large values */
|
/* test negative/large values */
|
||||||
@ -166,31 +169,31 @@ void test_neglarge()
|
|||||||
subtest = 2;
|
subtest = 2;
|
||||||
|
|
||||||
FILLITIMER(it, 4, 0, 5, 0);
|
FILLITIMER(it, 4, 0, 5, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(1);
|
if (setitimer(timer, &it, NULL)) my_e(1);
|
||||||
|
|
||||||
FILLITIMER(it, 1000000000, 0, 0, 0);
|
FILLITIMER(it, 1000000000, 0, 0, 0);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(2);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(2);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 1000000, 0, 0);
|
FILLITIMER(it, 0, 1000000, 0, 0);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(3);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(3);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, 1000000);
|
FILLITIMER(it, 0, 0, 0, 1000000);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(4);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(4);
|
||||||
|
|
||||||
FILLITIMER(it, -1, 0, 0, 0);
|
FILLITIMER(it, -1, 0, 0, 0);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(5);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(5);
|
||||||
|
|
||||||
FILLITIMER(it, 0, -1, 0, 0);
|
FILLITIMER(it, 0, -1, 0, 0);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(6);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(6);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, -1, 0);
|
FILLITIMER(it, 0, 0, -1, 0);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(7);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(7);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, -1);
|
FILLITIMER(it, 0, 0, 0, -1);
|
||||||
if (!setitimer(timer, &it, NULL) || errno != EINVAL) e(8);
|
if (!setitimer(timer, &it, NULL) || errno != EINVAL) my_e(8);
|
||||||
|
|
||||||
if (getitimer(timer, &it)) e(9);
|
if (getitimer(timer, &it)) my_e(9);
|
||||||
if (!LEITIMER(it, 4, 0, 5, 0)) e(10);
|
if (!LEITIMER(it, 4, 0, 5, 0)) my_e(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setitimer with a zero timer has to set the interval to zero as well */
|
/* setitimer with a zero timer has to set the interval to zero as well */
|
||||||
@ -205,9 +208,9 @@ void test_zero()
|
|||||||
it.it_interval.tv_sec = 1;
|
it.it_interval.tv_sec = 1;
|
||||||
it.it_interval.tv_usec = 1;
|
it.it_interval.tv_usec = 1;
|
||||||
|
|
||||||
if (setitimer(timer, &it, NULL)) e(1);
|
if (setitimer(timer, &it, NULL)) my_e(1);
|
||||||
if (getitimer(timer, &it)) e(2);
|
if (getitimer(timer, &it)) my_e(2);
|
||||||
if (!EQITIMER(it, 0, 0, 0, 0)) e(3);
|
if (!EQITIMER(it, 0, 0, 0, 0)) my_e(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test actual timer functioning */
|
/* test actual timer functioning */
|
||||||
@ -217,41 +220,41 @@ void test_timer()
|
|||||||
|
|
||||||
subtest = 4;
|
subtest = 4;
|
||||||
|
|
||||||
if (signal(sigs[timer], got_alarm) == SIG_ERR) e(1);
|
if (signal(sigs[timer], got_alarm) == SIG_ERR) my_e(1);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 1, 0, 1);
|
FILLITIMER(it, 0, 1, 0, 1);
|
||||||
|
|
||||||
if (setitimer(timer, &it, NULL)) e(2);
|
if (setitimer(timer, &it, NULL)) my_e(2);
|
||||||
|
|
||||||
signals = 0;
|
signals = 0;
|
||||||
busy_wait(1);
|
busy_wait(1);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, 0);
|
FILLITIMER(it, 0, 0, 0, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(3);
|
if (setitimer(timer, &it, NULL)) my_e(3);
|
||||||
|
|
||||||
/* we don't know how many signals we'll actually get in practice,
|
/* we don't know how many signals we'll actually get in practice,
|
||||||
* so these checks more or less cover the extremes of the acceptable */
|
* so these checks more or less cover the extremes of the acceptable */
|
||||||
if (signals < 2) e(4);
|
if (signals < 2) my_e(4);
|
||||||
if (signals > system_hz * 2) e(5);
|
if (signals > system_hz * 2) my_e(5);
|
||||||
|
|
||||||
/* only for REAL timer can we check against the clock */
|
/* only for REAL timer can we check against the clock */
|
||||||
if (timer == ITIMER_REAL) {
|
if (timer == ITIMER_REAL) {
|
||||||
FILLITIMER(it, 1, 0, 0, 0);
|
FILLITIMER(it, 1, 0, 0, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(6);
|
if (setitimer(timer, &it, NULL)) my_e(6);
|
||||||
|
|
||||||
signals = 0;
|
signals = 0;
|
||||||
busy_wait(1);
|
busy_wait(1);
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, 0);
|
FILLITIMER(it, 0, 0, 0, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(7);
|
if (setitimer(timer, &it, NULL)) my_e(7);
|
||||||
|
|
||||||
if (signals != 1) e(8);
|
if (signals != 1) my_e(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
signals = 0;
|
signals = 0;
|
||||||
busy_wait(1);
|
busy_wait(1);
|
||||||
|
|
||||||
if (signals != 0) e(9);
|
if (signals != 0) my_e(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test itimer/alarm interaction */
|
/* test itimer/alarm interaction */
|
||||||
@ -263,23 +266,23 @@ void test_alarm(void) {
|
|||||||
|
|
||||||
subtest = 5;
|
subtest = 5;
|
||||||
|
|
||||||
if (signal(SIGALRM, got_alarm) == SIG_ERR) e(1);
|
if (signal(SIGALRM, got_alarm) == SIG_ERR) my_e(1);
|
||||||
|
|
||||||
FILLITIMER(it, 3, 0, 1, 0);
|
FILLITIMER(it, 3, 0, 1, 0);
|
||||||
if (setitimer(timer, &it, NULL)) e(2);
|
if (setitimer(timer, &it, NULL)) my_e(2);
|
||||||
|
|
||||||
if (alarm(2) != 3) e(3);
|
if (alarm(2) != 3) my_e(3);
|
||||||
|
|
||||||
if (getitimer(timer, &it)) e(4);
|
if (getitimer(timer, &it)) my_e(4);
|
||||||
if (!LEITIMER(it, 2, 0, 0, 0)) e(5);
|
if (!LEITIMER(it, 2, 0, 0, 0)) my_e(5);
|
||||||
|
|
||||||
signals = 0;
|
signals = 0;
|
||||||
busy_wait(5);
|
busy_wait(5);
|
||||||
|
|
||||||
if (signals != 1) e(6);
|
if (signals != 1) my_e(6);
|
||||||
|
|
||||||
if (getitimer(timer, &it)) e(7);
|
if (getitimer(timer, &it)) my_e(7);
|
||||||
if (!EQITIMER(it, 0, 0, 0, 0)) e(8);
|
if (!EQITIMER(it, 0, 0, 0, 0)) my_e(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test that the timer is reset on forking */
|
/* test that the timer is reset on forking */
|
||||||
@ -292,10 +295,10 @@ void test_fork(void) {
|
|||||||
|
|
||||||
FILLITIMER(it, 12, 34, 56, 78);
|
FILLITIMER(it, 12, 34, 56, 78);
|
||||||
|
|
||||||
if (setitimer(timer, &it, NULL)) e(1);
|
if (setitimer(timer, &it, NULL)) my_e(1);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0) e(2);
|
if (pid < 0) my_e(2);
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if (getitimer(timer, &it)) exit(5);
|
if (getitimer(timer, &it)) exit(5);
|
||||||
@ -304,13 +307,13 @@ void test_fork(void) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait(&status) != pid) e(3);
|
if (wait(&status) != pid) my_e(3);
|
||||||
if (!WIFEXITED(status)) e(4);
|
if (!WIFEXITED(status)) my_e(4);
|
||||||
if (WEXITSTATUS(status) != 0) e(WEXITSTATUS(status));
|
if (WEXITSTATUS(status) != 0) my_e(WEXITSTATUS(status));
|
||||||
|
|
||||||
FILLITIMER(it, 0, 0, 0, 0);
|
FILLITIMER(it, 0, 0, 0, 0);
|
||||||
if (setitimer(timer, &it, &oit)) e(7);
|
if (setitimer(timer, &it, &oit)) my_e(7);
|
||||||
if (!LEITIMER(oit, 12, 34, 56, 78)) e(8);
|
if (!LEITIMER(oit, 12, 34, 56, 78)) my_e(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test if timer is carried over to exec()'ed process */
|
/* test if timer is carried over to exec()'ed process */
|
||||||
@ -323,7 +326,7 @@ void test_exec(void) {
|
|||||||
subtest = 7;
|
subtest = 7;
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0) e(1);
|
if (pid < 0) my_e(1);
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
FILLITIMER(it, 3, 0, 1, 0);
|
FILLITIMER(it, 3, 0, 1, 0);
|
||||||
@ -335,14 +338,14 @@ void test_exec(void) {
|
|||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait(&status) != pid) e(4);
|
if (wait(&status) != pid) my_e(4);
|
||||||
if (WIFSIGNALED(status)) {
|
if (WIFSIGNALED(status)) {
|
||||||
/* process should have died from corresponding signal */
|
/* process should have died from corresponding signal */
|
||||||
if (WTERMSIG(status) != sigs[timer]) e(5);
|
if (WTERMSIG(status) != sigs[timer]) my_e(5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (WIFEXITED(status)) e(WEXITSTATUS(status));
|
if (WIFEXITED(status)) my_e(WEXITSTATUS(status));
|
||||||
else e(6);
|
else my_e(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,32 +380,15 @@ int secs;
|
|||||||
void got_alarm(sig)
|
void got_alarm(sig)
|
||||||
int sig;
|
int sig;
|
||||||
{
|
{
|
||||||
if (sig != sigs[timer]) e(1001);
|
if (sig != sigs[timer]) my_e(1001);
|
||||||
|
|
||||||
signals++;
|
signals++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(n)
|
void my_e(n)
|
||||||
int n;
|
int n;
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("Timer %s, subtest %d, error %d, errno %d: %s\n",
|
printf("Timer %s, ", names[timer]);
|
||||||
names[timer], subtest, n, errno, strerror(errno));
|
e(n);
|
||||||
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
671
test/test42.c
671
test/test42.c
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,11 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#define MAX_ERROR 2
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
|
int subtest = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -22,8 +27,7 @@ main(int argc, char *argv[])
|
|||||||
ssize_t l;
|
ssize_t l;
|
||||||
pid_t f;
|
pid_t f;
|
||||||
|
|
||||||
printf("Test 44 ");
|
start(44);
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
for(i = 0; i < CHUNKS; i++) {
|
for(i = 0; i < CHUNKS; i++) {
|
||||||
v[i] = minix_mmap(vaddr, CHUNKSIZE, PROT_READ|PROT_WRITE, 0,
|
v[i] = minix_mmap(vaddr, CHUNKSIZE, PROT_READ|PROT_WRITE, 0,
|
||||||
@ -31,13 +35,13 @@ main(int argc, char *argv[])
|
|||||||
if(v[i] == MAP_FAILED) {
|
if(v[i] == MAP_FAILED) {
|
||||||
perror("minix_mmap");
|
perror("minix_mmap");
|
||||||
fprintf(stderr, "minix_mmap failed\n");
|
fprintf(stderr, "minix_mmap failed\n");
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
if(v[i] != vaddr) {
|
if(v[i] != vaddr) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"minix_mmap said 0x%p but i wanted 0x%p\n",
|
"minix_mmap said 0x%p but i wanted 0x%p\n",
|
||||||
v[i], vaddr);
|
v[i], vaddr);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
vaddr += CHUNKSIZE;
|
vaddr += CHUNKSIZE;
|
||||||
}
|
}
|
||||||
@ -46,14 +50,14 @@ main(int argc, char *argv[])
|
|||||||
if((fd=open(DEV_ZERO, O_RDONLY)) < 0) {
|
if((fd=open(DEV_ZERO, O_RDONLY)) < 0) {
|
||||||
perror("open");
|
perror("open");
|
||||||
fprintf(stderr, "open failed for %s\n", DEV_ZERO);
|
fprintf(stderr, "open failed for %s\n", DEV_ZERO);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TOTAL1 (CHUNKS1*CHUNKSIZE)
|
#define TOTAL1 (CHUNKS1*CHUNKSIZE)
|
||||||
/* Make single read cross region boundary. */
|
/* Make single read cross region boundary. */
|
||||||
if((l=read(fd, v[0], TOTAL1)) != TOTAL1) {
|
if((l=read(fd, v[0], TOTAL1)) != TOTAL1) {
|
||||||
fprintf(stderr, "read %d but expected %d\n", l, TOTAL1);
|
fprintf(stderr, "read %d but expected %d\n", l, TOTAL1);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Force single copy to cross region boundary. */
|
/* Force single copy to cross region boundary. */
|
||||||
@ -62,14 +66,14 @@ main(int argc, char *argv[])
|
|||||||
t = v[CHUNKS1]+CHUNKSIZE-2;
|
t = v[CHUNKS1]+CHUNKSIZE-2;
|
||||||
if((l=read(fd, t, CHUNKSIZE)) != CHUNKSIZE) {
|
if((l=read(fd, t, CHUNKSIZE)) != CHUNKSIZE) {
|
||||||
fprintf(stderr, "read %d but expected %d\n", l, CHUNKSIZE);
|
fprintf(stderr, "read %d but expected %d\n", l, CHUNKSIZE);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now start a child to test bogus memory access */
|
/* Now start a child to test bogus memory access */
|
||||||
if((f = fork()) == -1) {
|
if((f = fork()) == -1) {
|
||||||
perror("fork");
|
perror("fork");
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f > 0) {
|
if(f > 0) {
|
||||||
@ -77,15 +81,15 @@ main(int argc, char *argv[])
|
|||||||
/* Parent waits. */
|
/* Parent waits. */
|
||||||
if(waitpid(f, &st, 0) < 0) {
|
if(waitpid(f, &st, 0) < 0) {
|
||||||
perror("waitpid");
|
perror("waitpid");
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
if(!WIFEXITED(st)) {
|
if(!WIFEXITED(st)) {
|
||||||
fprintf(stderr, "child not signaled\n");
|
fprintf(stderr, "child not signaled\n");
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
if(WEXITSTATUS(st) != 0) {
|
if(WEXITSTATUS(st) != 0) {
|
||||||
fprintf(stderr, "child exited with nonzero status\n");
|
fprintf(stderr, "child exited with nonzero status\n");
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Child performs bogus read */
|
/* Child performs bogus read */
|
||||||
@ -95,16 +99,15 @@ main(int argc, char *argv[])
|
|||||||
res = read(fd, buf, LARGESIZE);
|
res = read(fd, buf, LARGESIZE);
|
||||||
if(res >= 0) {
|
if(res >= 0) {
|
||||||
fprintf(stderr, "res %d\n", res);
|
fprintf(stderr, "res %d\n", res);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
if(errno != EFAULT) {
|
if(errno != EFAULT) {
|
||||||
fprintf(stderr, "errno %d\n", errno);
|
fprintf(stderr, "errno %d\n", errno);
|
||||||
exit(1);
|
quit();
|
||||||
}
|
}
|
||||||
exit(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("ok\n");
|
quit();
|
||||||
|
return(-1);
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
static int errct;
|
#include "common.c"
|
||||||
|
|
||||||
/* test strtol */
|
/* test strtol */
|
||||||
#define TYPE long
|
#define TYPE long
|
||||||
@ -51,26 +51,13 @@ static int errct;
|
|||||||
|
|
||||||
#endif /* defined(__LONG_LONG_SUPPORTED) */
|
#endif /* defined(__LONG_LONG_SUPPORTED) */
|
||||||
|
|
||||||
static void quit(void)
|
|
||||||
{
|
|
||||||
if (errct == 0)
|
|
||||||
{
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
start(45);
|
||||||
#ifdef __LONG_LONG_SUPPORTED
|
#ifdef __LONG_LONG_SUPPORTED
|
||||||
printf("Test 45 (GCC) ");
|
printf("(GCC) ");
|
||||||
#else
|
#else
|
||||||
printf("Test 45 (ACK) ");
|
printf("(ACK) ");
|
||||||
#endif
|
#endif
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
@ -8,37 +8,13 @@
|
|||||||
#include <sys/sigcontext.h>
|
#include <sys/sigcontext.h>
|
||||||
|
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
static int errct;
|
#include "common.c"
|
||||||
|
|
||||||
/* maximum allowed FP difference for our tests */
|
/* maximum allowed FP difference for our tests */
|
||||||
#define EPSILON 0.00000000023283064365386962890625 /* 2^(-32) */
|
#define EPSILON 0.00000000023283064365386962890625 /* 2^(-32) */
|
||||||
|
|
||||||
static void quit(void)
|
|
||||||
{
|
|
||||||
if (errct == 0)
|
|
||||||
{
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ERR(x, y) e(__LINE__, (x), (y))
|
#define ERR(x, y) e(__LINE__, (x), (y))
|
||||||
|
|
||||||
static void e(int n, double x, double y)
|
|
||||||
{
|
|
||||||
printf("Line %d, x=%.20g, y=%.20g\n", n, x, y);
|
|
||||||
if (errct++ > MAX_ERROR)
|
|
||||||
{
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void signal_handler(int signum)
|
static void signal_handler(int signum)
|
||||||
{
|
{
|
||||||
struct sigframe *sigframe;
|
struct sigframe *sigframe;
|
||||||
@ -49,7 +25,7 @@ static void signal_handler(int signum)
|
|||||||
printf("Signal %d at 0x%x\n", signum, sigframe->sf_scp->sc_regs.pc);
|
printf("Signal %d at 0x%x\n", signum, sigframe->sf_scp->sc_regs.pc);
|
||||||
|
|
||||||
/* count as error */
|
/* count as error */
|
||||||
ERR(0, 0);
|
e(0);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* handle signa again next time */
|
/* handle signa again next time */
|
||||||
@ -59,14 +35,14 @@ static void signal_handler(int signum)
|
|||||||
static void test_fpclassify(double value, int class, int test_sign)
|
static void test_fpclassify(double value, int class, int test_sign)
|
||||||
{
|
{
|
||||||
/* test fpclassify */
|
/* test fpclassify */
|
||||||
if (fpclassify(value) != class) ERR(value, 0);
|
if (fpclassify(value) != class) e(101);
|
||||||
if (test_sign)
|
if (test_sign)
|
||||||
{
|
{
|
||||||
if (fpclassify(-value) != class) ERR(-value, 0);
|
if (fpclassify(-value) != class) e(102);
|
||||||
|
|
||||||
/* test signbit */
|
/* test signbit */
|
||||||
if (signbit(value)) ERR(value, 0);
|
if (signbit(value)) e(103);
|
||||||
if (!signbit(-value)) ERR(-value, 0);
|
if (!signbit(-value)) e(104);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +79,7 @@ static void test_fpclassify_values(void)
|
|||||||
*/
|
*/
|
||||||
assert(sizeof(negzero) == sizeof(double));
|
assert(sizeof(negzero) == sizeof(double));
|
||||||
test_fpclassify(*(double *) negzero, FP_ZERO, 0);
|
test_fpclassify(*(double *) negzero, FP_ZERO, 0);
|
||||||
if (!signbit(*(double *) negzero)) ERR(0, 0);
|
if (!signbit(*(double *) negzero)) e(4);
|
||||||
|
|
||||||
/* test other small numbers for fpclassify and signbit */
|
/* test other small numbers for fpclassify and signbit */
|
||||||
d = 1;
|
d = 1;
|
||||||
@ -141,7 +117,7 @@ static void test_round_value_mode_func(double value, int mode, double (*func)(do
|
|||||||
/* update and check rounding mode */
|
/* update and check rounding mode */
|
||||||
mode_old = fegetround();
|
mode_old = fegetround();
|
||||||
fesetround(mode);
|
fesetround(mode);
|
||||||
if (fegetround() != mode) ERR(0, 0);
|
if (fegetround() != mode) e(5);
|
||||||
|
|
||||||
/* perform rounding */
|
/* perform rounding */
|
||||||
rounded = func(value);
|
rounded = func(value);
|
||||||
@ -149,20 +125,20 @@ static void test_round_value_mode_func(double value, int mode, double (*func)(do
|
|||||||
/* check direction of rounding */
|
/* check direction of rounding */
|
||||||
switch (exp)
|
switch (exp)
|
||||||
{
|
{
|
||||||
case ROUND_EQ: if (rounded != value) ERR(value, rounded); break;
|
case ROUND_EQ: if (rounded != value) e(6); break;
|
||||||
case ROUND_DN: if (rounded >= value) ERR(value, rounded); break;
|
case ROUND_DN: if (rounded >= value) e(7); break;
|
||||||
case ROUND_UP: if (rounded <= value) ERR(value, rounded); break;
|
case ROUND_UP: if (rounded <= value) e(8); break;
|
||||||
default: assert(0);
|
default: assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check whether the number is sufficiently close */
|
/* check whether the number is sufficiently close */
|
||||||
if (fabs(value - rounded) >= 1) ERR(value, rounded);
|
if (fabs(value - rounded) >= 1) e(9);
|
||||||
|
|
||||||
/* check whether the number is integer */
|
/* check whether the number is integer */
|
||||||
if (remainder(rounded, 1)) ERR(value, rounded);
|
if (remainder(rounded, 1)) e(10);
|
||||||
|
|
||||||
/* re-check and restore rounding mode */
|
/* re-check and restore rounding mode */
|
||||||
if (fegetround() != mode) ERR(0, 0);
|
if (fegetround() != mode) e(11);
|
||||||
fesetround(mode_old);
|
fesetround(mode_old);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +197,7 @@ static void test_remainder_value(double x, double y)
|
|||||||
if (fabs(r1 - r2) > EPSILON && fabs(r1 + r2) > EPSILON)
|
if (fabs(r1 - r2) > EPSILON && fabs(r1 + r2) > EPSILON)
|
||||||
{
|
{
|
||||||
printf("%.20g != %.20g\n", r1, r2);
|
printf("%.20g != %.20g\n", r1, r2);
|
||||||
ERR(x, y);
|
e(13);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,11 +233,10 @@ int main(int argc, char **argv)
|
|||||||
fenv_t fenv;
|
fenv_t fenv;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("Test 47 ");
|
start(47);
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
/* no FPU errors, please */
|
/* no FPU errors, please */
|
||||||
if (feholdexcept(&fenv) < 0) ERR(0, 0);
|
if (feholdexcept(&fenv) < 0) e(14);
|
||||||
|
|
||||||
/* some signals count as errors */
|
/* some signals count as errors */
|
||||||
for (i = 0; i < _NSIG; i++)
|
for (i = 0; i < _NSIG; i++)
|
||||||
|
@ -6,32 +6,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define MAX_ERRORS 3
|
#define MAX_ERROR 3
|
||||||
|
#define err() e(__LINE__)
|
||||||
static int errct;
|
#include "common.c"
|
||||||
|
|
||||||
static void quit(void)
|
|
||||||
{
|
|
||||||
if (errct > 0)
|
|
||||||
{
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void err(void)
|
|
||||||
{
|
|
||||||
if (++errct >= MAX_ERRORS)
|
|
||||||
{
|
|
||||||
printf("aborted, too many errors\n");
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void printstr(const char *s)
|
static void printstr(const char *s)
|
||||||
{
|
{
|
||||||
@ -583,8 +560,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
int use_network;
|
int use_network;
|
||||||
|
|
||||||
printf("Test 48 ");
|
start(48);
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
use_network = can_use_network();
|
use_network = can_use_network();
|
||||||
if (!use_network)
|
if (!use_network)
|
||||||
|
@ -10,45 +10,25 @@
|
|||||||
#define TEST_64_BIT
|
#define TEST_64_BIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERR err(__LINE__)
|
#define ERR e(__LINE__)
|
||||||
|
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
static int errct;
|
#include "common.c"
|
||||||
|
|
||||||
static void quit(void)
|
|
||||||
{
|
|
||||||
if (errct == 0)
|
|
||||||
{
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void err(int line)
|
|
||||||
{
|
|
||||||
printf("error at line %d\n", line);
|
|
||||||
if (++errct >= MAX_ERROR)
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TEST_PRINTF(type, macro, value, result) \
|
#define TEST_PRINTF(type, macro, value, result) \
|
||||||
{ \
|
{ \
|
||||||
char buffer[256]; \
|
char buffer[256]; \
|
||||||
snprintf(buffer, sizeof(buffer), "%" macro, (type) value); \
|
snprintf(buffer, sizeof(buffer), "%" macro, (type) value); \
|
||||||
if (strcmp(buffer, result) != 0) err(__LINE__); \
|
if (strcmp(buffer, result) != 0) ERR; \
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
start(49);
|
||||||
#ifdef __LONG_LONG_SUPPORTED
|
#ifdef __LONG_LONG_SUPPORTED
|
||||||
printf("Test 49 (GCC) ");
|
printf("(GCC) ");
|
||||||
#else
|
#else
|
||||||
printf("Test 49 (ACK) ");
|
printf("(ACK) ");
|
||||||
#endif
|
#endif
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -207,6 +187,5 @@ int main(void)
|
|||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
quit();
|
quit();
|
||||||
assert(0);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,14 @@ _PROTOTYPE( void just_exit, (void) );
|
|||||||
_PROTOTYPE( void test_brk, (void) );
|
_PROTOTYPE( void test_brk, (void) );
|
||||||
_PROTOTYPE( void verify_main_reenter, (void) );
|
_PROTOTYPE( void verify_main_reenter, (void) );
|
||||||
|
|
||||||
#define ERROR_MAX 5
|
#define MAX_ERROR 5
|
||||||
#define SSIZE 32768
|
#define SSIZE 32768
|
||||||
#define ROUNDS 10
|
#define ROUNDS 10
|
||||||
#define SWAPS 10
|
#define SWAPS 10
|
||||||
|
|
||||||
int errct = 0;
|
#include "common.c"
|
||||||
|
|
||||||
|
int subtest;
|
||||||
ucontext_t ctx[3];
|
ucontext_t ctx[3];
|
||||||
int entered_func1, entered_func2, reentered_main, entered_overflow;
|
int entered_func1, entered_func2, reentered_main, entered_overflow;
|
||||||
|
|
||||||
@ -99,6 +101,7 @@ void do_child(void)
|
|||||||
do_calcs();
|
do_calcs();
|
||||||
if (fegetround() != FE_DOWNWARD) err(9, 4);
|
if (fegetround() != FE_DOWNWARD) err(9, 4);
|
||||||
}
|
}
|
||||||
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_parent(void)
|
void do_parent(void)
|
||||||
@ -181,16 +184,16 @@ void test_brk(void)
|
|||||||
void verify_main_reenter(void)
|
void verify_main_reenter(void)
|
||||||
{
|
{
|
||||||
if (reentered_main == 0) err(4, 1);
|
if (reentered_main == 0) err(4, 1);
|
||||||
if (errct == 0) printf("ok\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
start(51);
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
printf("Test 51 (GCC) ");
|
printf("(GCC) ");
|
||||||
#else
|
#else
|
||||||
printf("Test 51 (ACK) ");
|
printf("(ACK) ");
|
||||||
#endif
|
#endif
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -306,19 +309,16 @@ int main(void)
|
|||||||
makecontext(&ctx[2], (void (*) (void)) do_child, 0);
|
makecontext(&ctx[2], (void (*) (void)) do_child, 0);
|
||||||
if (swapcontext(&ctx[0], &ctx[2]) == -1) err(1, 16);
|
if (swapcontext(&ctx[0], &ctx[2]) == -1) err(1, 16);
|
||||||
|
|
||||||
return(0);
|
quit();
|
||||||
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't use a global subtest variable reliably, because threads might
|
/* We can't use a global subtest variable reliably, because threads might
|
||||||
change the value when we reenter a thread (i.e., report wrong subtest
|
change the value when we reenter a thread (i.e., report wrong subtest
|
||||||
number). */
|
number). */
|
||||||
void err(int subtest, int error_no)
|
void err(int sub, int error_no)
|
||||||
{
|
{
|
||||||
printf("Subtest %d, error %d\n", subtest, error_no);
|
subtest = sub;
|
||||||
|
e(error_no);
|
||||||
if (errct++ > ERROR_MAX) {
|
|
||||||
printf("Too many errors, test aborted\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
#define SWAPS 40
|
#define SWAPS 40
|
||||||
#define MAX_ERROR 5
|
#define MAX_ERROR 5
|
||||||
|
|
||||||
|
#include "common.c"
|
||||||
|
|
||||||
int pipefdc[2];
|
int pipefdc[2];
|
||||||
int pipefdp[2];
|
int pipefdp[2];
|
||||||
int subtest = 0, errct = 0;
|
int subtest = 0;
|
||||||
int child_is_dead = 0;
|
int child_is_dead = 0;
|
||||||
|
|
||||||
void dead_child(int n);
|
void dead_child(int n);
|
||||||
@ -25,23 +27,7 @@ void quit(void);
|
|||||||
|
|
||||||
void err(int n)
|
void err(int n)
|
||||||
{
|
{
|
||||||
printf("Subtest %d, error %d\n", subtest, n);
|
e(n);
|
||||||
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit(void)
|
|
||||||
{
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_calcs(void)
|
void do_calcs(void)
|
||||||
@ -162,10 +148,11 @@ int main(void)
|
|||||||
pid_t r;
|
pid_t r;
|
||||||
subtest = 1;
|
subtest = 1;
|
||||||
|
|
||||||
|
start(52);
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
printf("Test 52 (GCC) ");
|
printf("(GCC) ");
|
||||||
#else
|
#else
|
||||||
printf("Test 52 (ACK) ");
|
printf("(ACK) ");
|
||||||
#endif
|
#endif
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
45
test/test8.c
45
test/test8.c
@ -18,33 +18,25 @@
|
|||||||
#define Fstat(a,b) if (fstat(a,b) != 0) printf("Can't fstat %d\n", a)
|
#define Fstat(a,b) if (fstat(a,b) != 0) printf("Can't fstat %d\n", a)
|
||||||
#define Time(t) if (time(t) == (time_t)-1) printf("Time error\n")
|
#define Time(t) if (time(t) == (time_t)-1) printf("Time error\n")
|
||||||
|
|
||||||
int errct = 0;
|
#include "common.c"
|
||||||
int subtest = 1;
|
|
||||||
char MaxName[NAME_MAX + 1]; /* Name of maximum length */
|
int subtest;
|
||||||
char MaxPath[PATH_MAX]; /* Same for path */
|
|
||||||
char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */
|
|
||||||
char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */
|
|
||||||
|
|
||||||
_PROTOTYPE(void test8a, (void));
|
_PROTOTYPE(void test8a, (void));
|
||||||
_PROTOTYPE(void test8b, (void));
|
_PROTOTYPE(void test8b, (void));
|
||||||
_PROTOTYPE(void e, (int number));
|
|
||||||
_PROTOTYPE(void quit, (void));
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, m = 0xFFFF;
|
int i, m = 0xFFFF;
|
||||||
|
|
||||||
sync();
|
|
||||||
if (argc == 2) m = atoi(argv[1]);
|
if (argc == 2) m = atoi(argv[1]);
|
||||||
printf("Test 8 ");
|
start(8);
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
for (i = 0; i < ITERATIONS; i++) {
|
for (i = 0; i < ITERATIONS; i++) {
|
||||||
if (m & 0001) test8a();
|
if (m & 0001) test8a();
|
||||||
if (m & 0002) test8b();
|
if (m & 0002) test8b();
|
||||||
}
|
}
|
||||||
quit();
|
quit();
|
||||||
return 1;
|
return(-1); /* Unreachable */
|
||||||
}
|
}
|
||||||
|
|
||||||
void test8a()
|
void test8a()
|
||||||
@ -234,30 +226,3 @@ void test8b()
|
|||||||
for (i = 3; i < OPEN_MAX; i++) (void) close(i);
|
for (i = 3; i < OPEN_MAX; i++) (void) close(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int err_num = errno; /* Save in case printf clobbers it. */
|
|
||||||
|
|
||||||
printf("Subtest %d, error %d errno=%d: ", subtest, n, errno);
|
|
||||||
errno = err_num;
|
|
||||||
perror("");
|
|
||||||
if (errct++ > MAX_ERROR) {
|
|
||||||
printf("Too many errors; test aborted\n");
|
|
||||||
chdir("..");
|
|
||||||
system("rm -rf DIR*");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
errno = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
if (errct == 0) {
|
|
||||||
printf("ok\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("%d errors\n", errct);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user