OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/gdb-6.8/pre-binutils-2.20.1-sync/sim/testsuite/sim/cris/c
    from Rev 157 to Rev 223
    Reverse comparison

Rev 157 → Rev 223

/getcwd1.c
0,0 → 1,18
/*
#notarget: cris*-*-elf
*/
 
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
 
int main (int argc, char *argv[])
{
if (getcwd ((void *) -1, 4096) != NULL
|| errno != EFAULT)
abort ();
 
printf ("pass\n");
exit (0);
}
getcwd1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat4.c =================================================================== --- stat4.c (nonexistent) +++ stat4.c (revision 223) @@ -0,0 +1,28 @@ +/* Simulator options: +#notarget: cris*-*-elf +#sim: --sysroot=@exedir@ +*/ + +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + char path[1024] = "/"; + struct stat buf; + + strcat (path, argv[0]); + if (lstat (".", &buf) != 0 + || !S_ISDIR (buf.st_mode)) + abort (); + if (lstat (path, &buf) != 0 + || !S_ISREG (buf.st_mode)) + abort (); + printf ("pass\n"); + exit (0); +} +
stat4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat8.c =================================================================== --- stat8.c (nonexistent) +++ stat8.c (revision 223) @@ -0,0 +1,26 @@ +/* For this test, we need to do the lstat syscall directly, or else + glibc gets a SEGV. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include + +int main (void) +{ + int ret; + + /* From Linux, we get EFAULT. The simulator sends us EINVAL. */ + ret = syscall (SYS_lstat64, ".", NULL); + if (ret != -1 || (errno != EINVAL && errno != EFAULT)) + { + perror ("lstat"); + abort (); + } + + printf ("pass\n"); + exit (0); +}
stat8.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig1.c =================================================================== --- sig1.c (nonexistent) +++ sig1.c (revision 223) @@ -0,0 +1,20 @@ +#include +#include +#include + +void +leave (int n) +{ + exit (0); +} + +int +main (void) +{ + /* Check that the sigaction syscall (for signal) is interpreted, though + possibly ignored. */ + signal (SIGFPE, leave); + + printf ("pass\n"); + exit (0); +}
sig1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig3.c =================================================================== --- sig3.c (nonexistent) +++ sig3.c (revision 223) @@ -0,0 +1,13 @@ +/* Check that TRT happens at an abort (3) call, single thread. +#xerror: +#output: program stopped with signal 6.\n +*/ + +#include +#include +int main (void) +{ + abort (); + printf ("xyzzy\n"); + exit (0); +}
sig3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig5.c =================================================================== --- sig5.c (nonexistent) +++ sig5.c (revision 223) @@ -0,0 +1,16 @@ +/* Check that TRT happens for an uncaught non-abort signal, single thread. +#xerror: +#output: Unimplemented signal: 7\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +int main (void) +{ + kill (getpid (), SIGBUS); + printf ("xyzzy\n"); + exit (0); +}
sig5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: openpf1.c =================================================================== --- openpf1.c (nonexistent) +++ openpf1.c (revision 223) @@ -0,0 +1,38 @@ +/* Check that --sysroot is applied to open(2). +#sim: --sysroot=@exedir@ + + We assume, with EXE being the name of the executable: + - The simulator executes with cwd the same directory where the executable + is located (so argv[0] contains a plain filename without directory + components). + - There's no /EXE on the host file system. */ + +#include +#include +#include +#include +int main (int argc, char *argv[]) +{ + char *fnam = argv[0]; + FILE *f; + if (argv[0][0] != '/') + { + fnam = malloc (strlen (argv[0]) + 2); + if (fnam == NULL) + abort (); + strcpy (fnam, "/"); + strcat (fnam, argv[0]); + } + + f = fopen (fnam, "rb"); + if (f == NULL) + abort (); + close (f); + + /* Cover another execution path. */ + if (fopen ("/nonexistent", "rb") != NULL + || errno != ENOENT) + abort (); + printf ("pass\n"); + return 0; +}
openpf1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig7.c =================================================================== --- sig7.c (nonexistent) +++ sig7.c (revision 223) @@ -0,0 +1,27 @@ +/* Check unsupported case of sigaction syscall. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented rt_sigaction syscall (0x8, 0x3df*\n +#output: program stopped with signal 4.\n +*/ +#include +#include +#include +#include + +int +main (void) +{ + struct sigaction sa; + int err; + sa.sa_sigaction = NULL; + sa.sa_flags = SA_RESTART | SA_SIGINFO; + sigemptyset (&sa.sa_mask); + + err = sigaction (SIGFPE, &sa, NULL); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + + printf ("xyzzy\n"); + exit (0); +}
sig7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: openpf3.c =================================================================== --- openpf3.c (nonexistent) +++ openpf3.c (revision 223) @@ -0,0 +1,49 @@ +/* Basic file operations (rename, unlink); once without sysroot. We + also test that the simulator has chdir:ed to PREFIX, when defined. */ + +#include +#include +#include +#include +#include +#include + +#ifndef PREFIX +#define PREFIX +#endif + +void err (const char *s) +{ + perror (s); + abort (); +} + +int main (int argc, char *argv[]) +{ + FILE *f; + struct stat buf; + + unlink (PREFIX "testfoo2.tmp"); + + f = fopen ("testfoo1.tmp", "w"); + if (f == NULL) + err ("open"); + fclose (f); + + if (rename (PREFIX "testfoo1.tmp", PREFIX "testfoo2.tmp") != 0) + err ("rename"); + + if (stat (PREFIX "testfoo2.tmp", &buf) != 0 + || !S_ISREG (buf.st_mode)) + err ("stat 1"); + + if (stat ("testfoo2.tmp", &buf) != 0 + || !S_ISREG (buf.st_mode)) + err ("stat 2"); + + if (unlink (PREFIX "testfoo2.tmp") != 0) + err ("unlink"); + + printf ("pass\n"); + return 0; +}
openpf3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig9.c =================================================================== --- sig9.c (nonexistent) +++ sig9.c (revision 223) @@ -0,0 +1,36 @@ +/* Check that TRT happens at an non-abort ignored signal, more than one thread. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +*/ + +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + int i; + for (i = 0; i < 100; i++) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + int retcode; + void *retval; + signal (SIGALRM, SIG_IGN); + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + kill (getpid (), SIGALRM); + retcode = pthread_join (th_a, &retval); + if (retcode != 0 || retval != NULL) + abort (); + printf ("pass\n"); + exit (0); +}
sig9.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mmap2.c =================================================================== --- mmap2.c (nonexistent) +++ mmap2.c (revision 223) @@ -0,0 +1,48 @@ +/* +#notarget: cris*-*-elf +*/ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + int fd = open (argv[0], O_RDONLY); + struct stat sb; + int size; + void *a; + const char *str = "a string you'll only find in the program"; + + if (fd == -1) + { + perror ("open"); + abort (); + } + + if (fstat (fd, &sb) < 0) + { + perror ("fstat"); + abort (); + } + + size = sb.st_size; + + /* We want to test mmapping a size that isn't exactly a page. */ + if ((size & 8191) == 0) + size--; + + a = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0); + + if (memmem (a, size, str, strlen (str) + 1) == NULL) + abort (); + + printf ("pass\n"); + exit (0); +}
mmap2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ftruncate1.c =================================================================== --- ftruncate1.c (nonexistent) +++ ftruncate1.c (revision 223) @@ -0,0 +1,52 @@ +/* Check that the ftruncate syscall works trivially. +#notarget: cris*-*-elf +*/ + +#include +#include +#include + +void +perr (const char *s) +{ + perror (s); + exit (1); +} + +int +main (void) +{ + FILE *f; + const char fname[] = "sk1test.dat"; + const char tsttxt1[] + = "This is the first and only line of this file.\n"; + const char tsttxt2[] = "Now there is a second line.\n"; + char buf[sizeof (tsttxt1) + sizeof (tsttxt2) - 1] = ""; + + f = fopen (fname, "w+"); + if (f == NULL + || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1)) + perr ("open or fwrite"); + + if (fflush (f) != 0) + perr ("fflush"); + + if (ftruncate (fileno (f), strlen(tsttxt1) - 20) != 0) + perr ("ftruncate"); + + if (fclose (f) != 0) + perr ("fclose"); + + f = fopen (fname, "r"); + if (f == NULL + || fread (buf, 1, sizeof (buf), f) != strlen (tsttxt1) - 20 + || strncmp (buf, tsttxt1, strlen (tsttxt1) - 20) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
ftruncate1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: openpf5.c =================================================================== --- openpf5.c (nonexistent) +++ openpf5.c (revision 223) @@ -0,0 +1,56 @@ +/* Check that TRT happens when error on too many opened files. +#notarget: cris*-*-elf +#sim: --sysroot=@exedir@ +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + int i; + int filemax; + +#ifdef OPEN_MAX + filemax = OPEN_MAX; +#else + filemax = sysconf (_SC_OPEN_MAX); +#endif + + char *fn = malloc (strlen (argv[0]) + 2); + if (fn == NULL) + abort (); + strcpy (fn, "/"); + strcat (fn, argv[0]); + + for (i = 0; i < filemax + 1; i++) + { + if (open (fn, O_RDONLY) < 0) + { + /* Shouldn't happen too early. */ + if (i < filemax - 3 - 1) + { + fprintf (stderr, "i: %d\n", i); + abort (); + } + if (errno != EMFILE) + { + perror ("open"); + abort (); + } + goto ok; + } + } + abort (); + +ok: + printf ("pass\n"); + exit (0); +}
openpf5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: kill2.c =================================================================== --- kill2.c (nonexistent) +++ kill2.c (revision 223) @@ -0,0 +1,16 @@ +/* Basic kill functionality test; suicide. +#xerror: +#output: program stopped with signal 6.\n +*/ + +#include +#include +#include +#include +int +main (void) +{ + kill (getpid (), SIGABRT); + printf ("undead\n"); + exit (1); +}
kill2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: freopen2.c =================================================================== --- freopen2.c (nonexistent) +++ freopen2.c (revision 223) @@ -0,0 +1,40 @@ +/* Tests that stdin can be redirected from a normal file. */ +#include +#include +#include + +int +main (void) +{ + const char* fname = "freopen.dat"; + const char tsttxt[] + = "A random line of text, used to test correct freopen etc.\n"; + FILE* instream; + FILE *old_stderr; + char c1; + + /* Like the freopen call in flex. */ + old_stderr = freopen (fname, "w+", stderr); + if (old_stderr == NULL + || fwrite (tsttxt, 1, strlen (tsttxt), stderr) != strlen (tsttxt) + || fclose (stderr) != 0) + { + printf ("fail\n"); + exit (1); + } + + instream = freopen(fname, "r", stdin); + if (instream == NULL) { + printf("fail\n"); + exit(1); + } + + c1 = getc(instream); + if (c1 != 'A') { + printf("fail\n"); + exit(1); + } + + printf ("pass\n"); + exit(0); +}
freopen2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fcntl1.c =================================================================== --- fcntl1.c (nonexistent) +++ fcntl1.c (revision 223) @@ -0,0 +1,19 @@ +/* Check that we get the expected message for unsupported fcntl calls. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented fcntl* +#output: program stopped with signal 4.\n +*/ +#include +#include +#include +#include + +int main (void) +{ + int err = fcntl (1, 42); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
fcntl1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: thread2.c =================================================================== --- thread2.c (nonexistent) +++ thread2.c (revision 223) @@ -0,0 +1,28 @@ +/* Compiler options: +#cc: additional_flags=-pthread +#notarget: cris*-*-elf + + A sanity check for syscalls resulting from + pthread_getschedparam and pthread_setschedparam. */ + +#include +#include +#include + +int main (void) +{ + struct sched_param param; + int policy; + + if (pthread_getschedparam (pthread_self (), &policy, ¶m) != 0 + || policy != SCHED_OTHER + || param.sched_priority != 0) + abort (); + + if (pthread_setschedparam (pthread_self (), SCHED_OTHER, ¶m) != 0 + || param.sched_priority != 0) + abort (); + + printf ("pass\n"); + exit (0); +}
thread2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall1.c =================================================================== --- syscall1.c (nonexistent) +++ syscall1.c (revision 223) @@ -0,0 +1,22 @@ +/* Test unknown-syscall output. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include + +int main (void) +{ + /* The number 166 is chosen because there's a gap for that number in + the CRIS asm/unistd.h. */ + int err = syscall (166, 1, 2, 3, 4, 5, 6); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
syscall1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: thread4.c =================================================================== --- thread4.c (nonexistent) +++ thread4.c (revision 223) @@ -0,0 +1,50 @@ +/* Compiler options: +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#output: abb ok\n + + Testing a pthread corner case. Output will change with glibc + releases. */ + +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + int i; + + if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0) + abort (); + write (2, "a", 1); + for (i = 0; i < 10; i++) + { + sched_yield (); + pthread_testcancel (); + write (2, "b", 1); + } + return NULL; +} + +int +main (void) +{ + int retcode; + pthread_t th_a; + void *retval; + + retcode = pthread_create (&th_a, NULL, process, NULL); + sched_yield (); + sched_yield (); + sched_yield (); + sched_yield (); + retcode = pthread_cancel (th_a); + retcode = pthread_join (th_a, &retval); + if (retcode != 0) + abort (); + fprintf (stderr, " ok\n"); + return 0; +}
thread4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ex1.c =================================================================== --- ex1.c (nonexistent) +++ ex1.c (revision 223) @@ -0,0 +1,54 @@ +/* Compiler options: +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#output: Starting process a\naaaaaaaaStarting process b\nababbbbbbbbb + + The output will change depending on the exact syscall sequence per + thread, so will change with glibc versions. Prepare to modify; use + the latest glibc. + + This file is from glibc/linuxthreads, with the difference that the + number is 10, not 10000. */ + +/* Creates two threads, one printing 10000 "a"s, the other printing + 10000 "b"s. + Illustrates: thread creation, thread joining. */ + +#include +#include +#include +#include "pthread.h" + +static void * +process (void *arg) +{ + int i; + fprintf (stderr, "Starting process %s\n", (char *) arg); + for (i = 0; i < 10; i++) + { + write (1, (char *) arg, 1); + } + return NULL; +} + +int +main (void) +{ + int retcode; + pthread_t th_a, th_b; + void *retval; + + retcode = pthread_create (&th_a, NULL, process, (void *) "a"); + if (retcode != 0) + fprintf (stderr, "create a failed %d\n", retcode); + retcode = pthread_create (&th_b, NULL, process, (void *) "b"); + if (retcode != 0) + fprintf (stderr, "create b failed %d\n", retcode); + retcode = pthread_join (th_a, &retval); + if (retcode != 0) + fprintf (stderr, "join a failed %d\n", retcode); + retcode = pthread_join (th_b, &retval); + if (retcode != 0) + fprintf (stderr, "join b failed %d\n", retcode); + return 0; +}
ex1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall3.c =================================================================== --- syscall3.c (nonexistent) +++ syscall3.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, just actually specifying the default. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=stop +#xerror: +#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n +#output: program stopped with signal 4.\n +*/ + +#include "syscall1.c"
syscall3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall5.c =================================================================== --- syscall5.c (nonexistent) +++ syscall5.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, but specifying ENOSYS with message. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys +#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "syscall1.c"
syscall5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall7.c =================================================================== --- syscall7.c (nonexistent) +++ syscall7.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "syscall1.c"
syscall7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sigreturn1.c =================================================================== --- sigreturn1.c (nonexistent) +++ sigreturn1.c (revision 223) @@ -0,0 +1,21 @@ +/* Test that TRT happens for spurious sigreturn calls. Single-thread. +#notarget: cris*-*-elf +#xerror: +#output: Invalid sigreturn syscall: no signal handler active (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include + +int main (void) +{ + int err = syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
sigreturn1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sysctl2.c =================================================================== --- sysctl2.c (nonexistent) +++ sysctl2.c (revision 223) @@ -0,0 +1,41 @@ +/* Check error message for invalid sysctl call. +#xerror: +#output: Unimplemented _sysctl syscall *\n +#output: program stopped with signal 4.\n +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + static int sysctl_args[] = { 99, 99 }; + size_t x = 8; + + struct __sysctl_args { + int *name; + int nlen; + void *oldval; + size_t *oldlenp; + void *newval; + size_t newlen; + unsigned long __unused[4]; + } scargs + = + { + sysctl_args, + sizeof (sysctl_args) / sizeof (sysctl_args[0]), + (void *) -1, &x, NULL, 0 + }; + + int err = syscall (SYS__sysctl, &scargs); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
sysctl2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sigreturn3.c =================================================================== --- sigreturn3.c (nonexistent) +++ sigreturn3.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "sigreturn1.c"
sigreturn3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched1.c =================================================================== --- sched1.c (nonexistent) +++ sched1.c (revision 223) @@ -0,0 +1,15 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include + +int main (void) +{ + if (sched_getscheduler (getpid ()) != SCHED_OTHER) + abort (); + printf ("pass\n"); + exit (0); +}
sched1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: truncate2.c =================================================================== --- truncate2.c (nonexistent) +++ truncate2.c (revision 223) @@ -0,0 +1,6 @@ +/* +#sim: --sysroot=@exedir@ +#notarget: cris*-*-elf +*/ +#define PREFIX "/" +#include "truncate1.c"
truncate2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched3.c =================================================================== --- sched3.c (nonexistent) +++ sched3.c (revision 223) @@ -0,0 +1,24 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + struct sched_param sb; + sb.sched_priority = 0; + if (sched_setscheduler (getpid (), SCHED_OTHER, &sb) != 0 + || sb.sched_priority != 0) + abort (); + sb.sched_priority = 5; + if (sched_setscheduler (getpid (), SCHED_OTHER, &sb) != -1 + || errno != EINVAL + || sb.sched_priority != 5) + abort (); + printf ("pass\n"); + exit (0); +}
sched3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: seek2.c =================================================================== --- seek2.c (nonexistent) +++ seek2.c (revision 223) @@ -0,0 +1,4 @@ +/* Simulator options: +#sim: --sysroot=@exedir@/ +*/ +#include "seek1.c"
seek2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rtsigprocmask2.c =================================================================== --- rtsigprocmask2.c (nonexistent) +++ rtsigprocmask2.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "rtsigprocmask1.c"
rtsigprocmask2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink2.c =================================================================== --- readlink2.c (nonexistent) +++ readlink2.c (revision 223) @@ -0,0 +1,80 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + char buf[1024]; + char buf2[1024]; + int err; + + /* This is a special feature handled in the simulator. The "42" + should be formed from getpid () if this was a real program. */ + err = readlink ("/proc/42/exe", buf, sizeof (buf)); + if (err < 0) + { + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); + } + + /* Don't use an abort in the following; it might cause the printf to + not make it all the way to output and make debugging more + difficult. */ + + /* We assume the program is called with no path, so we might need to + prepend it. */ + if (getcwd (buf2, sizeof (buf2)) != buf2) + { + perror ("getcwd"); + exit (1); + } + + if (argv[0][0] == '/') + { +#ifdef SYSROOTED + if (strchr (argv[0] + 1, '/') != NULL) + { + printf ("%s != %s\n", argv[0], strrchr (argv[0] + 1, '/')); + exit (1); + } +#endif + if (strcmp (argv[0], buf) != 0) + { + printf ("%s != %s\n", buf, argv[0]); + exit (1); + } + } + else if (argv[0][0] != '.') + { + if (buf2[strlen (buf2) - 1] != '/') + strcat (buf2, "/"); + strcat (buf2, argv[0]); + if (strcmp (buf2, buf) != 0) + { + printf ("%s != %s\n", buf, buf2); + exit (1); + } + } + else + { + strcat (buf2, argv[0] + 1); + if (strcmp (buf, buf2) != 0) + { + printf ("%s != %s\n", buf, buf2); + exit (1); + } + } + + printf ("pass\n"); + exit (0); +} + +
readlink2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rtsigsuspend1.c =================================================================== --- rtsigsuspend1.c (nonexistent) +++ rtsigsuspend1.c (revision 223) @@ -0,0 +1,21 @@ +/* Test that TRT happens for invalid rt_sigsuspend calls. Single-thread. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented rt_sigsuspend syscall arguments (0x1, 0x2)\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include + +int main (void) +{ + int err = syscall (SYS_rt_sigsuspend, 1, 2); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
rtsigsuspend1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched5.c =================================================================== --- sched5.c (nonexistent) +++ sched5.c (revision 223) @@ -0,0 +1,19 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +int main (void) +{ + int Min = sched_get_priority_min (SCHED_OTHER); + int Max = sched_get_priority_max (SCHED_OTHER); + if (Min != 0 || Max != 0) + { + fprintf (stderr, "min: %d, max: %d\n", Min, Max); + abort (); + } + printf ("pass\n"); + exit (0); +}
sched5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched7.c =================================================================== --- sched7.c (nonexistent) +++ sched7.c (revision 223) @@ -0,0 +1,17 @@ +/* Check corner error case: specifying invalid PID. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + if (sched_getscheduler (99) != -1 + || errno != ESRCH) + abort (); + printf ("pass\n"); + exit (0); +}
sched7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink4.c =================================================================== --- readlink4.c (nonexistent) +++ readlink4.c (revision 223) @@ -0,0 +1,62 @@ +/* Check for corner case: readlink of too-long name. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +void bye (const char *s, int i) +{ + fprintf (stderr, "%s: %d\n", s, i); + fflush (NULL); + abort (); +} + +int main (int argc, char *argv[]) +{ + char *buf; + char buf2[1024]; + int max, i; + + /* We assume this limit is what we see in the simulator as well. */ +#ifdef PATH_MAX + max = PATH_MAX; +#else + max = pathconf (argv[0], _PC_PATH_MAX); +#endif + + max *= 10; + + if (max <= 0) + bye ("path_max", max); + + if ((buf = malloc (max + 1)) == NULL) + bye ("malloc", 0); + + strcat (buf, argv[0]); + + if (rindex (buf, '/') == NULL) + strcat (buf, "./"); + + for (i = rindex (buf, '/') - buf + 1; i < max; i++) + buf[i] = 'a'; + + buf [i] = 0; + + i = readlink (buf, buf2, sizeof (buf2) - 1); + if (i != -1) + bye ("i", i); + + if (errno != ENAMETOOLONG) + { + perror (buf); + bye ("errno", errno); + } + + printf ("pass\n"); + exit (0); +}
readlink4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mprotect1.c =================================================================== --- mprotect1.c (nonexistent) +++ mprotect1.c (revision 223) @@ -0,0 +1,19 @@ +/* Check unimplemented-output for mprotect call. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented mprotect call (0x0, 0x2001, 0x4)\n +#output: program stopped with signal 4.\n + */ +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + int err = mprotect (0, 8193, PROT_EXEC); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
mprotect1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched9.c =================================================================== --- sched9.c (nonexistent) +++ sched9.c (revision 223) @@ -0,0 +1,24 @@ +/* Check corner error case: specifying invalid scheduling policy. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + if (sched_get_priority_min (-1) != -1 + || errno != EINVAL) + abort (); + + errno = 0; + + if (sched_get_priority_max (-1) != -1 + || errno != EINVAL) + abort (); + + printf ("pass\n"); + exit (0); +}
sched9.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe2.c =================================================================== --- pipe2.c (nonexistent) +++ pipe2.c (revision 223) @@ -0,0 +1,143 @@ +/* Check that closing a pipe with a nonempty buffer works. +#notarget: cris*-*-elf +#output: got: a\ngot: b\nexit: 0\n +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +int pip[2]; + +int pipemax; + +int +process (void *arg) +{ + char *s = arg; + int lots = pipemax + 256; + char *buf = malloc (lots); + int ret; + + if (buf == NULL) + abort (); + + *buf = *s; + + /* The first write should go straight through. */ + if (write (pip[1], buf, 1) != 1) + abort (); + + *buf = s[1]; + + /* The second write may or may not be successful for the whole + write, but should be successful for at least the pipemax part. + As linux/limits.h clamps PIPE_BUF to 4096, but the page size is + actually 8k, we can get away with that much. There should be no + error, though. Doing this on host shows that for + x86_64-unknown-linux-gnu (2.6.14-1.1656_FC4) pipemax * 10 can be + successfully written, perhaps for similar reasons. */ + ret = write (pip[1], buf, lots); + if (ret < pipemax) + { + fprintf (stderr, "ret: %d, %s, %d\n", ret, strerror (errno), pipemax); + fflush (0); + abort (); + } + + return 0; +} + +int +main (void) +{ + int retcode; + int pid; + int st = 0; + long stack[16384]; + char buf[1]; + + /* We need to turn this off because we don't want (to have to model) a + SIGPIPE resulting from the close. */ + if (signal (SIGPIPE, SIG_IGN) != SIG_DFL) + abort (); + + retcode = pipe (pip); + + if (retcode != 0) + { + fprintf (stderr, "Bad pipe %d\n", retcode); + abort (); + } + +#ifdef PIPE_MAX + pipemax = PIPE_MAX; +#else + pipemax = fpathconf (pip[1], _PC_PIPE_BUF); +#endif + + if (pipemax <= 0) + { + fprintf (stderr, "Bad pipemax %d\n", pipemax); + abort (); + } + + pid = clone (process, (char *) stack + sizeof (stack) - 64, + (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + | SIGCHLD, "ab"); + if (pid <= 0) + { + fprintf (stderr, "Bad clone %d\n", pid); + abort (); + } + + while ((retcode = read (pip[0], buf, 1)) == 0) + ; + + if (retcode != 1) + { + fprintf (stderr, "Bad read 1: %d\n", retcode); + abort (); + } + + printf ("got: %c\n", buf[0]); + + /* Need to read out something from the second write too before + closing, or the writer can get EPIPE. */ + while ((retcode = read (pip[0], buf, 1)) == 0) + ; + + if (retcode != 1) + { + fprintf (stderr, "Bad read 2: %d\n", retcode); + abort (); + } + + printf ("got: %c\n", buf[0]); + + if (close (pip[0]) != 0) + { + perror ("pip close"); + abort (); + } + + retcode = waitpid (pid, &st, __WALL); + + if (retcode != pid || !WIFEXITED (st)) + { + fprintf (stderr, "Bad wait %d:%d %x\n", pid, retcode, st); + perror ("errno"); + abort (); + } + + printf ("exit: %d\n", WEXITSTATUS (st)); + return 0; +}
pipe2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink6.c =================================================================== --- readlink6.c (nonexistent) +++ readlink6.c (revision 223) @@ -0,0 +1,5 @@ +/* Check that rare readlink calls don't cause the simulator to abort. +#notarget: cris*-*-elf +#dest: @exedir@/readlink6.c.x +*/ +#include "readlink2.c"
readlink6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: time2.c =================================================================== --- time2.c (nonexistent) +++ time2.c (revision 223) @@ -0,0 +1,18 @@ +/* CB_SYS_time doesn't implement the Linux time syscall; the return + value isn't written to the argument. */ + +#include +#include +#include + +int +main (void) +{ + time_t x = (time_t) -1; + time_t t = time (&x); + + if (t == (time_t) -1 || t != x) + abort (); + printf ("pass\n"); + exit (0); +}
time2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sock1.c =================================================================== --- sock1.c (nonexistent) +++ sock1.c (revision 223) @@ -0,0 +1,32 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +/* Check that socketcall is suitably stubbed. */ + +int main (void) +{ + int ret = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); + + if (ret != -1) + { + fprintf (stderr, "sock: %d\n", ret); + abort (); + } + + if (errno != ENOSYS) + { + perror ("unexpected"); + abort (); + } + + printf ("pass\n"); + return 0; +}
sock1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mremap.c =================================================================== --- mremap.c (nonexistent) +++ mremap.c (revision 223) @@ -0,0 +1,31 @@ +#include +#include + +/* Sanity check that system calls for realloc works. Also tests a few + more cases for mmap2 and munmap. */ + +int main () +{ + void *p1, *p2; + + if ((p1 = malloc (8100)) == NULL + || (p1 = realloc (p1, 16300)) == NULL + || (p1 = realloc (p1, 4000)) == NULL + || (p1 = realloc (p1, 500)) == NULL + || (p1 = realloc (p1, 1023*1024)) == NULL + || (p1 = realloc (p1, 8191*1024)) == NULL + || (p1 = realloc (p1, 512*1024)) == NULL + || (p2 = malloc (1023*1024)) == NULL + || (p1 = realloc (p1, 1023*1024)) == NULL + || (p1 = realloc (p1, 8191*1024)) == NULL + || (p1 = realloc (p1, 512*1024)) == NULL) + { + printf ("fail\n"); + exit (1); + } + + free (p1); + free (p2); + printf ("pass\n"); + exit (0); +}
mremap.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone1.c =================================================================== --- clone1.c (nonexistent) +++ clone1.c (revision 223) @@ -0,0 +1,90 @@ +/* +#notarget: cris*-*-elf +#output: got: a\nthen: bc\nexit: 0\n +*/ + +/* This is a very limited subset of what ex1.c does; we just check that + thread creation (clone syscall) and pipe writes and reads work. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +int pip[2]; + +int +process (void *arg) +{ + char *s = arg; + if (write (pip[1], s+2, 1) != 1) abort (); + if (write (pip[1], s+1, 1) != 1) abort (); + if (write (pip[1], s, 1) != 1) abort (); + return 0; +} + +int +main (void) +{ + int retcode; + int pid; + int st; + long stack[16384]; + char buf[10] = {0}; + + retcode = pipe (pip); + + if (retcode != 0) + { + fprintf (stderr, "Bad pipe %d\n", retcode); + abort (); + } + + pid = clone (process, (char *) stack + sizeof (stack) - 64, + (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + | SIGCHLD, "cba"); + if (pid <= 0) + { + fprintf (stderr, "Bad clone %d\n", pid); + abort (); + } + + if ((retcode = read (pip[0], buf, 1)) != 1) + { + fprintf (stderr, "Bad read 1: %d\n", retcode); + abort (); + } + printf ("got: %c\n", buf[0]); + retcode = read (pip[0], buf, 2); + if (retcode == 1) + { + retcode = read (pip[0], buf+1, 1); + if (retcode != 1) + { + fprintf (stderr, "Bad read 1.5: %d\n", retcode); + abort (); + } + retcode = 2; + } + if (retcode != 2) + { + fprintf (stderr, "Bad read 2: %d\n", retcode); + abort (); + } + + printf ("then: %s\n", buf); + retcode = wait4 (-1, &st, WNOHANG | __WCLONE, NULL); + + if (retcode != pid || !WIFEXITED (st)) + { + fprintf (stderr, "Bad wait %d %x\n", retcode, st); + abort (); + } + + printf ("exit: %d\n", WEXITSTATUS (st)); + return 0; +}
clone1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe4.c =================================================================== --- pipe4.c (nonexistent) +++ pipe4.c (revision 223) @@ -0,0 +1,66 @@ +/* Check that TRT happens for pipe corner cases. +#notarget: cris*-*-elf +*/ +#include +#include +#include +#include +#include +#include +#include + +void err (const char *s) +{ + perror (s); + abort (); +} + +int main (void) +{ + int pip[2]; + char c; + int pipemax; + + if (pipe (pip) != 0) + err ("pipe"); + +#ifdef PIPE_MAX + pipemax = PIPE_MAX; +#else + pipemax = fpathconf (pip[1], _PC_PIPE_BUF); +#endif + + if (pipemax <= 0) + { + fprintf (stderr, "Bad pipemax %d\n", pipemax); + abort (); + } + + /* Writing to wrong end of pipe. */ + if (write (pip[0], "argh", 1) != -1 + || errno != EBADF) + err ("write pipe"); + + errno = 0; + + /* Reading from wrong end of pipe. */ + if (read (pip[1], &c, 1) != -1 + || errno != EBADF) + err ("write pipe"); + + errno = 0; + + if (close (pip[0]) != 0) + err ("close"); + + if (signal (SIGPIPE, SIG_IGN) != SIG_DFL) + err ("signal"); + + /* Writing to pipe with closed read end. */ + if (write (pip[1], "argh", 1) != -1 + || errno != EPIPE) + err ("write closed"); + + printf ("pass\n"); + exit (0); +}
pipe4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink8.c =================================================================== --- readlink8.c (nonexistent) +++ readlink8.c (revision 223) @@ -0,0 +1,8 @@ +/* Check that rare readlink calls don't cause the simulator to abort. +#notarget: cris*-*-elf +#sim: --sysroot=@exedir@ +#simenv: env(-u\ PWD\ foo)=bar + FIXME: Need to unset PWD, but right now I won't bother tweaking the + generic parts of the testsuite machinery and instead abuse a flaw. */ +#define SYSROOTED 1 +#include "readlink2.c"
readlink8.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig10.c =================================================================== --- sig10.c (nonexistent) +++ sig10.c (revision 223) @@ -0,0 +1,33 @@ +/* Check that TRT happens when trying to IGN an non-ignorable signal, more than one thread. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Exiting pid 42 due to signal 9\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + signal (SIGKILL, SIG_IGN); + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + kill (getpid (), SIGKILL); + printf ("xyzzy\n"); + exit (0); +}
sig10.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone3.c =================================================================== --- clone3.c (nonexistent) +++ clone3.c (revision 223) @@ -0,0 +1,45 @@ +/* Check that exiting from a parent thread does not kill the child. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +process (void *arg) +{ + int i; + + for (i = 0; i < 50; i++) + if (sched_yield ()) + abort (); + + printf ("pass\n"); + return 0; +} + +int +main (void) +{ + int pid; + long stack[16384]; + + pid = clone (process, (char *) stack + sizeof (stack) - 64, + (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + | SIGCHLD, "ab"); + if (pid <= 0) + { + fprintf (stderr, "Bad clone %d\n", pid); + abort (); + } + + exit (0); +}
clone3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe6.c =================================================================== --- pipe6.c (nonexistent) +++ pipe6.c (revision 223) @@ -0,0 +1,111 @@ +/* Check that writing an inordinate amount of data works (somewhat). +#notarget: cris*-*-elf +#output: got: a\nexit: 0\n + This test-case will *not* work on host (or for real): the first + pipemax+1 bytes will be successfully written. It's just for + exercising a rare execution path. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int pip[2]; + +int pipemax; + +int +process (void *arg) +{ + char *s = arg; + char *buf = calloc (pipemax * 100, 1); + int ret; + + if (buf == NULL) + abort (); + + *buf = *s; + + ret = write (pip[1], buf, pipemax * 100); + if (ret != -1 || errno != EFBIG) + { + perror ("write"); + abort (); + } + + return 0; +} + +int +main (void) +{ + int retcode; + int pid; + int st = 0; + long stack[16384]; + char buf[1]; + + retcode = pipe (pip); + + if (retcode != 0) + { + fprintf (stderr, "Bad pipe %d\n", retcode); + abort (); + } + +#ifdef PIPE_MAX + pipemax = PIPE_MAX; +#else + pipemax = fpathconf (pip[1], _PC_PIPE_BUF); +#endif + + if (pipemax <= 0) + { + fprintf (stderr, "Bad pipemax %d\n", pipemax); + abort (); + } + + pid = clone (process, (char *) stack + sizeof (stack) - 64, + (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + | SIGCHLD, "ab"); + if (pid <= 0) + { + fprintf (stderr, "Bad clone %d\n", pid); + abort (); + } + + while ((retcode = read (pip[0], buf, 1)) == 0) + ; + + if (retcode != 1) + { + fprintf (stderr, "Bad read 1: %d\n", retcode); + abort (); + } + + printf ("got: %c\n", buf[0]); + + if (close (pip[0]) != 0) + { + perror ("pip close"); + abort (); + } + + retcode = waitpid (pid, &st, __WALL); + + if (retcode != pid || !WIFEXITED (st)) + { + fprintf (stderr, "Bad wait %d:%d %x\n", pid, retcode, st); + perror ("errno"); + abort (); + } + + printf ("exit: %d\n", WEXITSTATUS (st)); + return 0; +}
pipe6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig12.c =================================================================== --- sig12.c (nonexistent) +++ sig12.c (revision 223) @@ -0,0 +1,38 @@ +/* Check that TRT happens for a signal sent to a non-existent process/thread, more than one thread. +#cc: additional_flags=-pthread +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + int i; + for (i = 0; i < 100; i++) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + int retcode; + void *retval; + + if (pthread_create (&th_a, NULL, process, (void *) "a") != 0) + abort (); + if (kill (getpid () - 1, SIGBUS) != -1 + || errno != ESRCH + || pthread_join (th_a, &retval) != 0) + abort (); + printf ("pass\n"); + exit (0); +}
sig12.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone5.c =================================================================== --- clone5.c (nonexistent) +++ clone5.c (revision 223) @@ -0,0 +1,35 @@ +/* Check that unimplemented clone syscalls get the right treatment. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented clone syscall * +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include +#include +#include + +int pip[2]; + +int +process (void *arg) +{ + return 0; +} + +int +main (void) +{ + int retcode; + long stack[16384]; + + retcode = clone (process, (char *) stack + sizeof (stack) - 64, 0, "cba"); + if (retcode == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + return 0; +}
clone5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink11.c =================================================================== --- readlink11.c (nonexistent) +++ readlink11.c (revision 223) @@ -0,0 +1,9 @@ +/* As readlink5.c (sic), but specifying silent ENOSYS. +#notarget: cris*-*-elf +#dest: ./readlink11.c.x +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "readlink2.c"
readlink11.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat1.c =================================================================== --- stat1.c (nonexistent) +++ stat1.c (revision 223) @@ -0,0 +1,16 @@ +#include +#include +#include +#include +#include + +int main (void) +{ + struct stat buf; + + if (stat (".", &buf) != 0 + || !S_ISDIR (buf.st_mode)) + abort (); + printf ("pass\n"); + exit (0); +}
stat1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fdopen1.c =================================================================== --- fdopen1.c (nonexistent) +++ fdopen1.c (revision 223) @@ -0,0 +1,54 @@ +/* Check that the syscalls implementing fdopen work trivially. */ + +#include +#include +#include +#include +#include + +void +perr (const char *s) +{ + perror (s); + exit (1); +} + +int +main (void) +{ + FILE *f; + int fd; + const char fname[] = "sk1test.dat"; + const char tsttxt1[] + = "This is the first and only line of this file.\n"; + char buf[sizeof (tsttxt1)] = ""; + + fd = open (fname, O_WRONLY|O_TRUNC|O_CREAT, S_IRWXU); + if (fd <= 0) + perr ("open-w"); + + f = fdopen (fd, "w"); + if (f == NULL + || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1)) + perr ("fdopen or fwrite"); + + if (fclose (f) != 0) + perr ("fclose"); + + fd = open (fname, O_RDONLY); + if (fd <= 0) + perr ("open-r"); + + f = fdopen (fd, "r"); + if (f == NULL + || fread (buf, 1, sizeof (buf), f) != strlen (tsttxt1) + || strcmp (buf, tsttxt1) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
fdopen1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat3.c =================================================================== --- stat3.c (nonexistent) +++ stat3.c (revision 223) @@ -0,0 +1,26 @@ +/* Simulator options: +#sim: --sysroot=@exedir@ +*/ +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + char path[1024] = "/"; + struct stat buf; + + strcat (path, argv[0]); + if (stat (".", &buf) != 0 + || !S_ISDIR (buf.st_mode)) + abort (); + if (stat (path, &buf) != 0 + || !S_ISREG (buf.st_mode)) + abort (); + printf ("pass\n"); + exit (0); +} +
stat3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat5.c =================================================================== --- stat5.c (nonexistent) +++ stat5.c (revision 223) @@ -0,0 +1,20 @@ +/* Check that lstat:ing an nonexistent file works as expected. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + struct stat buf; + + if (lstat ("nonexistent", &buf) == 0 || errno != ENOENT) + abort (); + printf ("pass\n"); + exit (0); +}
stat5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat7.c =================================================================== --- stat7.c (nonexistent) +++ stat7.c (revision 223) @@ -0,0 +1,26 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + struct stat buf; + + /* From Linux, we get EFAULT. The simulator sends us EINVAL. */ + if (lstat (NULL, &buf) != -1 + || (errno != EINVAL && errno != EFAULT)) + { + perror ("lstat 1"); + abort (); + } + + printf ("pass\n"); + exit (0); +}
stat7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: hello.c =================================================================== --- hello.c (nonexistent) +++ hello.c (revision 223) @@ -0,0 +1,7 @@ +#include +#include +int main () +{ + printf ("pass\n"); + exit (0); +}
hello.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig2.c =================================================================== --- sig2.c (nonexistent) +++ sig2.c (revision 223) @@ -0,0 +1,32 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include + +/* Like sig1.c, but using sigaction. */ + +void +leave (int n, siginfo_t *info, void *x) +{ + abort (); +} + +int +main (void) +{ + struct sigaction sa; + sa.sa_sigaction = leave; + sa.sa_flags = SA_RESTART | SA_SIGINFO; + sigemptyset (&sa.sa_mask); + + /* Check that the sigaction syscall (for signal) is interpreted, though + possibly ignored. */ + if (sigaction (SIGFPE, &sa, NULL) != 0) + abort (); + + printf ("pass\n"); + exit (0); +}
sig2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ugetrlimit1.c =================================================================== --- ugetrlimit1.c (nonexistent) +++ ugetrlimit1.c (revision 223) @@ -0,0 +1,21 @@ +/* Check corner error case: specifying unimplemented resource. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + struct rlimit lim; + + if (getrlimit (RLIMIT_NPROC, &lim) != -1 + || errno != EINVAL) + abort (); + printf ("pass\n"); + exit (0); +}
ugetrlimit1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig4.c =================================================================== --- sig4.c (nonexistent) +++ sig4.c (revision 223) @@ -0,0 +1,30 @@ +/* Check that TRT happens at an abort (3) call, more than one thread. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Exiting pid 42 due to signal 6\n +#output: program stopped with signal 6.\n +*/ + +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + abort (); + printf ("xyzzy\n"); + exit (0); +}
sig4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig6.c =================================================================== --- sig6.c (nonexistent) +++ sig6.c (revision 223) @@ -0,0 +1,32 @@ +/* Check that TRT happens at an non-abort non-caught signal, more than one thread. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Exiting pid 42 due to signal 7\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + kill (getpid (), SIGBUS); + printf ("xyzzy\n"); + exit (0); +}
sig6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: openpf2.c =================================================================== --- openpf2.c (nonexistent) +++ openpf2.c (revision 223) @@ -0,0 +1,16 @@ +/* Check that the simulator has chdir:ed to the --sysroot argument +#sim: --sysroot=@srcdir@ + (or that --sysroot is applied to relative file paths). */ + +#include +#include +#include +int main (int argc, char *argv[]) +{ + FILE *f = fopen ("openpf2.c", "rb"); + if (f == NULL) + abort (); + close (f); + printf ("pass\n"); + return 0; +}
openpf2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig8.c =================================================================== --- sig8.c (nonexistent) +++ sig8.c (revision 223) @@ -0,0 +1,19 @@ +/* Check that TRT happens for an ignored catchable signal, single thread. +#xerror: +#output: Unimplemented signal: 14\n +#output: program stopped with signal 4.\n + + Sure, it'd probably be better to support signals in single-thread too, + but that's on an as-need basis, and I don't have a need for it yet. */ + +#include +#include +#include +#include +int main (void) +{ + signal (SIGALRM, SIG_IGN); + kill (getpid (), SIGALRM); + printf ("xyzzy\n"); + exit (0); +}
sig8.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: openpf4.c =================================================================== --- openpf4.c (nonexistent) +++ openpf4.c (revision 223) @@ -0,0 +1,5 @@ +/* Basic file operations, now *with* sysroot. +#sim: --sysroot=@exedir@ +*/ +#define PREFIX "/" +#include "openpf3.c"
openpf4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mmap1.c =================================================================== --- mmap1.c (nonexistent) +++ mmap1.c (revision 223) @@ -0,0 +1,48 @@ +/* +#notarget: cris*-*-elf +*/ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + int fd = open (argv[0], O_RDONLY); + struct stat sb; + int size; + void *a; + const char *str = "a string you'll only find in the program"; + + if (fd == -1) + { + perror ("open"); + abort (); + } + + if (fstat (fd, &sb) < 0) + { + perror ("fstat"); + abort (); + } + + size = sb.st_size; + + /* We want to test mmapping a size that isn't exactly a page. */ + if ((size & 8191) == 0) + size--; + + a = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + + if (memmem (a, size, str, strlen (str) + 1) == NULL) + abort (); + + printf ("pass\n"); + exit (0); +}
mmap1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: kill1.c =================================================================== --- kill1.c (nonexistent) +++ kill1.c (revision 223) @@ -0,0 +1,30 @@ +/* Basic kill functionality test; fail killing init. Don't run as root. */ +#include +#include +#include +#include +#include +int +main (void) +{ + if (kill (1, SIGTERM) != -1 + || errno != EPERM) + { + printf ("fail\n"); + exit (1); + } + + errno = 0; + + if (kill (1, SIGABRT) != -1 + || errno != EPERM) + { + printf ("fail\n"); + exit (1); + } + + errno = 0; + + printf ("pass\n"); + exit (0); +}
kill1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ftruncate2.c =================================================================== --- ftruncate2.c (nonexistent) +++ ftruncate2.c (revision 223) @@ -0,0 +1,39 @@ +/* +#notarget: cris*-*-elf +*/ + +/* Check that we get a proper error indication if trying ftruncate on a + fd that is a pipe descriptor. */ + +#include +#include +#include +#include +int main (void) +{ + int pip[2]; + + if (pipe (pip) != 0) + { + perror ("pipe"); + abort (); + } + + if (ftruncate (pip[0], 20) == 0 || errno != EINVAL) + { + perror ("ftruncate 1"); + abort (); + } + + errno = 0; + + if (ftruncate (pip[1], 20) == 0 || errno != EINVAL) + { + perror ("ftruncate 2"); + abort (); + } + + printf ("pass\n"); + + exit (0); +}
ftruncate2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mmap3.c =================================================================== --- mmap3.c (nonexistent) +++ mmap3.c (revision 223) @@ -0,0 +1,33 @@ +/* +#notarget: cris*-*-elf +*/ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + volatile unsigned char *a; + + /* Check that we can map a non-multiple of a page and still get a full page. */ + a = mmap (NULL, 0x4c, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (a == NULL || a == (unsigned char *) -1) + abort (); + + a[0] = 0xbe; + a[8191] = 0xef; + memset ((char *) a + 1, 0, 8190); + + if (a[0] != 0xbe || a[8191] != 0xef) + abort (); + + printf ("pass\n"); + exit (0); +}
mmap3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: kill3.c =================================================================== --- kill3.c (nonexistent) +++ kill3.c (revision 223) @@ -0,0 +1,16 @@ +/* Basic kill functionality test; suicide. +#xerror: +#output: program stopped with signal 6.\n +*/ + +#include +#include +#include +#include +int +main (void) +{ + abort (); + printf ("undead\n"); + exit (1); +}
kill3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: freopen1.c =================================================================== --- freopen1.c (nonexistent) +++ freopen1.c (revision 223) @@ -0,0 +1,49 @@ +/* Check that basic freopen functionality works. */ + +#include +#include +#include + +int +main (void) +{ + FILE *old_stderr; + FILE *f; + const char fname[] = "sk1test.dat"; + const char tsttxt[] + = "A random line of text, used to test correct freopen etc.\n"; + char buf[sizeof tsttxt] = ""; + + /* Like the freopen call in flex. */ + old_stderr = freopen (fname, "w+", stderr); + if (old_stderr == NULL + || fwrite (tsttxt, 1, strlen (tsttxt), stderr) != strlen (tsttxt) + || fclose (stderr) != 0) + { + printf ("fail\n"); + exit (1); + } + + /* Using "rb" to make this test similar to the use in genconf.c in + GhostScript. */ + f = fopen (fname, "rb"); + if (f == NULL + || fseek (f, 0L, SEEK_END) != 0 + || ftell (f) != strlen (tsttxt)) + { + printf ("fail\n"); + exit (1); + } + + rewind (f); + if (fread (buf, 1, strlen (tsttxt), f) != strlen (tsttxt) + || strcmp (buf, tsttxt) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
freopen1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: gettod.c =================================================================== --- gettod.c (nonexistent) +++ gettod.c (revision 223) @@ -0,0 +1,27 @@ +/* Basic time functionality test. */ +#include +#include +#include +#include +int +main (void) +{ + struct timeval t_m = {0, 0}; + time_t t; + + if ((t = time (NULL)) == (time_t) -1 + || gettimeofday (&t_m, NULL) != 0 + || t_m.tv_sec == 0 + + /* We assume there will be no delay between the time and + gettimeofday calls above, but allow a timer-tick to make the + seconds increase by one. */ + || (t != t_m.tv_sec && t+1 != t_m.tv_sec)) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
gettod.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fcntl2.c =================================================================== --- fcntl2.c (nonexistent) +++ fcntl2.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "fcntl1.c"
fcntl2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: append1.c =================================================================== --- append1.c (nonexistent) +++ append1.c (revision 223) @@ -0,0 +1,51 @@ +/* Check regression of a bug uncovered by the libio tFile test (old + libstdc++, pre-gcc-3.x era), where appending to a file doesn't work. + The default open-flags-mapping does not match Linux/CRIS, so a + specific mapping is necessary. */ + +#include +#include +#include + +int +main (void) +{ + FILE *f; + const char fname[] = "sk1test.dat"; + const char tsttxt1[] + = "This is the first and only line of this file.\n"; + const char tsttxt2[] = "Now there is a second line.\n"; + char buf[sizeof (tsttxt1) + sizeof (tsttxt2) - 1] = ""; + + f = fopen (fname, "w+"); + if (f == NULL + || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1) + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + f = fopen (fname, "a+"); + if (f == NULL + || fwrite (tsttxt2, 1, strlen (tsttxt2), f) != strlen (tsttxt2) + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + f = fopen (fname, "r"); + if (f == NULL + || fread (buf, 1, sizeof (buf), f) != sizeof (buf) - 1 + || strncmp (buf, tsttxt1, strlen (tsttxt1)) != 0 + || strncmp (buf + strlen (tsttxt1), tsttxt2, strlen (tsttxt2)) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
append1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rename2.c =================================================================== --- rename2.c (nonexistent) +++ rename2.c (revision 223) @@ -0,0 +1,38 @@ +/* Test some execution paths for error cases. +#cc: additional_flags=-Wl,--section-start=.startup=0x8000 + The linker option is for sake of newlib, where the default program + layout starts at address 0. We need to change the layout so + there's no memory at 0, as all sim error checking is "lazy", + depending on lack of memory mapping. */ + +#include +#include +#include + +void err (const char *s) +{ + perror (s); + abort (); +} + +int main (int argc, char *argv[]) +{ + /* Avoid getting files with random characters due to errors + elsewhere. */ + if (argc != 1 + || (argv[0][0] != '.' && argv[0][0] != '/' && argv[0][0] != 'r')) + abort (); + + if (rename (argv[0], NULL) != -1 + || errno != EFAULT) + err ("rename 1 "); + + errno = 0; + + if (rename (NULL, argv[0]) != -1 + || errno != EFAULT) + err ("rename 2"); + + printf ("pass\n"); + return 0; +}
rename2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: thread3.c =================================================================== --- thread3.c (nonexistent) +++ thread3.c (revision 223) @@ -0,0 +1,46 @@ +/* Compiler options: +#cc: additional_flags=-pthread +#notarget: cris*-*-elf + + To test sched_yield in the presencs of threads. Core from ex1.c. */ + +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + int i; + for (i = 0; i < 10; i++) + { + if (sched_yield () != 0) + abort (); + } + return NULL; +} + +int +main (void) +{ + int retcode; + pthread_t th_a, th_b; + void *retval; + + retcode = pthread_create (&th_a, NULL, process, (void *) "a"); + if (retcode != 0) + abort (); + retcode = pthread_create (&th_b, NULL, process, (void *) "b"); + if (retcode != 0) + abort (); + retcode = pthread_join (th_a, &retval); + if (retcode != 0) + abort (); + retcode = pthread_join (th_b, &retval); + if (retcode != 0) + abort (); + printf ("pass\n"); + return 0; +}
thread3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: c.exp =================================================================== --- c.exp (nonexistent) +++ c.exp (revision 223) @@ -0,0 +1,210 @@ +# Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Miscellaneous CRIS simulator testcases testing syscall sequences. + +if ![istarget cris*-*-*] { + return +} + +set CFLAGS_FOR_TARGET "-O2" +if [istarget cris-*-*] { + set mach "crisv10" +} { + set mach "crisv32" +} + +# Using target_compile, since it is less noisy, +if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \ + "executable" "" ] == "" } { + set has_cc 1 +} { + verbose -log "Can't execute C compiler" + set has_cc 0 +} + +# Like istarget, except take a list of targets as a string. +proc anytarget { targets } { + set targetlist [split $targets] + set argc [llength $targetlist] + for { set i 0 } { $i < $argc } { incr i } { + if [istarget [lindex $targetlist $i]] { + return 1 + } + } + return 0 +} + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + if ![runtest_file_p $runtests $src] { + continue + } + set testname "[file tail $src]" + + set opt_array [slurp_options $src] + if { $opt_array == -1 } { + unresolved $testname + return + } + + # And again, to simplify specifying tests. + if ![runtest_file_p $runtests $src] { + continue + } + + # Note absence of CC in results, but don't make a big fuss over it. + if { $has_cc == 0 } { + untested $testname + continue + } + + # Clear default options + set opts(cc) "" + set opts(sim) "" + set opts(output) "" + set opts(progoptions) "" + set opts(timeout) "" + set opts(mach) "" + set opts(xerror) "no" + set opts(dest) "$testname.x" + set opts(simenv) "" + set opts(kfail) "" + set opts(xfail) "" + set opts(target) "" + set opts(notarget) "" + + # Clear any machine specific options specified in a previous test case + if [info exists opts(sim,$mach)] { + unset opts(sim,$mach) + } + + foreach i $opt_array { + set opt_name [lindex $i 0] + set opt_machs [lindex $i 1] + set opt_val [lindex $i 2] + if ![info exists opts($opt_name)] { + perror "unknown option $opt_name in file $src" + unresolved $testname + return + } + + # Replace specific substitutions: + # @exedir@ is where the test-program is located. + regsub -all "@exedir@" $opt_val "[pwd]" opt_val + # @srcdir@ is where the source of the test-program is located. + regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val + + # Multiple of these options concatenate, they don't override. + if { $opt_name == "output" || $opt_name == "progoptions" } { + set opt_val "$opts($opt_name)$opt_val" + } + + # Similar with "xfail", "kfail", "target" and "notarget", but + # arguments are space-separated. + if { $opt_name == "xfail" || $opt_name == "kfail" \ + || $opt_name == "target" || $opt_name == "notarget" } { + if { $opts($opt_name) != "" } { + set opt_val "$opts($opt_name) $opt_val" + } + } + + foreach m $opt_machs { + set opts($opt_name,$m) $opt_val + } + if { "$opt_machs" == "" } { + set opts($opt_name) $opt_val + } + } + + if { $opts(output) == "" } { + if { "$opts(xerror)" == "no" } { + set opts(output) "pass\n" + } else { + set opts(output) "fail\n" + } + } + + if { $opts(target) != "" && ![anytarget $opts(target)] } { + continue + } + + if { $opts(notarget) != "" && [anytarget $opts(notarget)] } { + continue + } + + # If no machine specific options, default to the general version. + if ![info exists opts(sim,$mach)] { + set opts(sim,$mach) $opts(sim) + } + + # Change \n sequences to newline chars. + regsub -all "\\\\n" $opts(output) "\n" opts(output) + + verbose -log "Compiling $src with $opts(cc)" + + set dest "$opts(dest)" + if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } { + unresolved $testname + continue + } + + verbose -log "Simulating $src with $opts(sim,$mach)" + + # Time to setup xfailures and kfailures. + if { "$opts(xfail)" != "" } { + verbose -log "xfail: $opts(xfail)" + # Using eval to make $opts(xfail) appear as individual + # arguments. + eval setup_xfail $opts(xfail) + } + if { "$opts(kfail)" != "" } { + verbose -log "kfail: $opts(kfail)" + eval setup_kfail $opts(kfail) + } + + set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \ + "" "$opts(simenv)"] + set status [lindex $result 0] + set output [lindex $result 1] + + if { "$status" == "pass" } { + if { "$opts(xerror)" == "no" } { + if [string match $opts(output) $output] { + pass "$mach $testname" + } else { + verbose -log "output: $output" 3 + verbose -log "pattern: $opts(output)" 3 + fail "$mach $testname (execution)" + } + } else { + verbose -log "`pass' return code when expecting failure" 3 + fail "$mach $testname (execution)" + } + } elseif { "$status" == "fail" } { + if { "$opts(xerror)" == "no" } { + fail "$mach $testname (execution)" + } else { + if [string match $opts(output) $output] { + pass "$mach $testname" + } else { + verbose -log "output: $output" 3 + verbose -log "pattern: $opts(output)" 3 + fail "$mach $testname (execution)" + } + } + } else { + $status "$mach $testname" + } +} Index: syscall2.c =================================================================== --- syscall2.c (nonexistent) +++ syscall2.c (revision 223) @@ -0,0 +1,23 @@ +/* Test unknown-syscall output. +#notarget: cris*-*-elf +#xerror: +#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include + +int main (void) +{ + int err; + + /* Check special case of number 0 syscall. */ + err = syscall (0, 3, 2, 1, 4, 6, 5); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + printf ("xyzzy\n"); + exit (0); +}
syscall2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: thread5.c =================================================================== --- thread5.c (nonexistent) +++ thread5.c (revision 223) @@ -0,0 +1,77 @@ +/* Compiler options: +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#output: abbb ok\n + + Testing a signal handler corner case. */ + +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + write (2, "a", 1); + write (2, "b", 1); + write (2, "b", 1); + write (2, "b", 1); + return NULL; +} + +int ok = 0; +volatile int done = 0; + +void +sigusr1 (int signum) +{ + if (signum != SIGUSR1 || !ok) + abort (); + done = 1; +} + +int +main (void) +{ + int retcode; + pthread_t th_a; + void *retval; + sigset_t sigs; + + if (sigemptyset (&sigs) != 0) + abort (); + + retcode = pthread_create (&th_a, NULL, process, NULL); + if (retcode != 0) + abort (); + + if (signal (SIGUSR1, sigusr1) != SIG_DFL) + abort (); + if (pthread_sigmask (SIG_BLOCK, NULL, &sigs) != 0 + || sigaddset (&sigs, SIGUSR1) != 0 + || pthread_sigmask (SIG_BLOCK, &sigs, NULL) != 0) + abort (); + if (pthread_kill (pthread_self (), SIGUSR1) != 0 + || sched_yield () != 0 + || sched_yield () != 0 + || sched_yield () != 0) + abort (); + + ok = 1; + if (pthread_sigmask (SIG_UNBLOCK, NULL, &sigs) != 0 + || sigaddset (&sigs, SIGUSR1) != 0 + || pthread_sigmask (SIG_UNBLOCK, &sigs, NULL) != 0) + abort (); + + if (!done) + abort (); + + retcode = pthread_join (th_a, &retval); + if (retcode != 0) + abort (); + fprintf (stderr, " ok\n"); + return 0; +}
thread5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: setrlimit1.c =================================================================== --- setrlimit1.c (nonexistent) +++ setrlimit1.c (revision 223) @@ -0,0 +1,22 @@ +/* Check corner error case: specifying unimplemented resource. +#notarget: cris*-*-elf +*/ +#include +#include +#include +#include +#include +#include +#include + +int main (void) +{ + struct rlimit lim; + memset (&lim, 0, sizeof lim); + + if (setrlimit (RLIMIT_NPROC, &lim) != -1 + || errno != EINVAL) + abort (); + printf ("pass\n"); + exit (0); +}
setrlimit1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall4.c =================================================================== --- syscall4.c (nonexistent) +++ syscall4.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, just actually specifying the default. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=stop +#xerror: +#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n +#output: program stopped with signal 4.\n +*/ + +#include "syscall2.c"
syscall4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall6.c =================================================================== --- syscall6.c (nonexistent) +++ syscall6.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, but specifying ENOSYS with message. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys +#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "syscall2.c"
syscall6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sjlj.c =================================================================== --- sjlj.c (nonexistent) +++ sjlj.c (revision 223) @@ -0,0 +1,34 @@ +/* Check that setjmp and longjmp stand a chance to work; that the used machine + primitives work in the simulator. */ + +#include +#include +#include + +extern void f (void); + +int ok = 0; +jmp_buf b; + +int +main () +{ + int ret = setjmp (b); + + if (ret == 42) + ok = 100; + else if (ret == 0) + f (); + + if (ok == 100) + printf ("pass\n"); + else + printf ("fail\n"); + exit (0); +} + +void +f (void) +{ + longjmp (b, 42); +}
sjlj.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: syscall8.c =================================================================== --- syscall8.c (nonexistent) +++ syscall8.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "syscall2.c"
syscall8.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sysctl1.c =================================================================== --- sysctl1.c (nonexistent) +++ sysctl1.c (revision 223) @@ -0,0 +1,38 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include + +/* I can't seem to include the right things, so we do it brute force. */ +int main (void) +{ + static int sysctl_args[] = { 1, 4 }; + size_t x = 8; + + struct __sysctl_args { + int *name; + int nlen; + void *oldval; + size_t *oldlenp; + void *newval; + size_t newlen; + unsigned long __unused[4]; + } scargs + = + { + sysctl_args, + sizeof (sysctl_args) / sizeof (sysctl_args[0]), + (void *) -1, &x, NULL, 0 + }; + + if (syscall (SYS__sysctl, &scargs) != -1 + || errno != EFAULT) + abort (); + printf ("pass\n"); + exit (0); +}
sysctl1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sigreturn2.c =================================================================== --- sigreturn2.c (nonexistent) +++ sigreturn2.c (revision 223) @@ -0,0 +1,38 @@ +/* Check that TRT happens for spurious sigreturn calls. Multiple threads. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Invalid sigreturn syscall: no signal handler active (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + { + int err = syscall (SYS_sigreturn, 1, 2, 3, 4, 5, 6); + if (err == -1 && errno == ENOSYS) + printf ("ENOSYS\n"); + } + printf ("xyzzy\n"); + exit (0); +}
sigreturn2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sysctl3.c =================================================================== --- sysctl3.c (nonexistent) +++ sysctl3.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "sysctl2.c"
sysctl3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sigreturn4.c =================================================================== --- sigreturn4.c (nonexistent) +++ sigreturn4.c (revision 223) @@ -0,0 +1,9 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "sigreturn2.c"
sigreturn4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: truncate1.c =================================================================== --- truncate1.c (nonexistent) +++ truncate1.c (revision 223) @@ -0,0 +1,49 @@ +/* Check that the truncate syscall works trivially. +#notarget: cris*-*-elf +*/ + +#include +#include +#include + +#ifndef PREFIX +#define PREFIX +#endif +int +main (void) +{ + FILE *f; + const char fname[] = PREFIX "sk1test.dat"; + const char tsttxt1[] + = "This is the first and only line of this file.\n"; + const char tsttxt2[] = "Now there is a second line.\n"; + char buf[sizeof (tsttxt1) + sizeof (tsttxt2) - 1] = ""; + + f = fopen (fname, "w+"); + if (f == NULL + || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1) + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + if (truncate (fname, strlen(tsttxt1) - 10) != 0) + { + perror ("truncate"); + exit (1); + } + + f = fopen (fname, "r"); + if (f == NULL + || fread (buf, 1, sizeof (buf), f) != strlen (tsttxt1) - 10 + || strncmp (buf, tsttxt1, strlen (tsttxt1) - 10) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
truncate1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched2.c =================================================================== --- sched2.c (nonexistent) +++ sched2.c (revision 223) @@ -0,0 +1,19 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + struct sched_param sb; + memset (&sb, -1, sizeof sb); + if (sched_getparam (getpid (), &sb) != 0 + || sb.sched_priority != 0) + abort (); + printf ("pass\n"); + exit (0); +}
sched2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: seek1.c =================================================================== --- seek1.c (nonexistent) +++ seek1.c (revision 223) @@ -0,0 +1,47 @@ +/* Check that basic (ll|f)seek sim functionality works. Also uses basic + file open/write functionality. */ +#include +#include +#include + +int +main (void) +{ + FILE *f; + const char fname[] = "sk1test.dat"; + const char tsttxt[] + = "A random line of text, used to test correct read, write and seek.\n"; + char buf[sizeof tsttxt] = ""; + + f = fopen (fname, "w"); + if (f == NULL + || fwrite (tsttxt, 1, strlen (tsttxt), f) != strlen (tsttxt) + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + /* Using "rb" to make this test similar to the use in genconf.c in + GhostScript. */ + f = fopen (fname, "rb"); + if (f == NULL + || fseek (f, 0L, SEEK_END) != 0 + || ftell (f) != strlen (tsttxt)) + { + printf ("fail\n"); + exit (1); + } + + rewind (f); + if (fread (buf, 1, strlen (tsttxt), f) != strlen (tsttxt) + || strcmp (buf, tsttxt) != 0 + || fclose (f) != 0) + { + printf ("fail\n"); + exit (1); + } + + printf ("pass\n"); + exit (0); +}
seek1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rtsigprocmask1.c =================================================================== --- rtsigprocmask1.c (nonexistent) +++ rtsigprocmask1.c (revision 223) @@ -0,0 +1,51 @@ +/* Compiler options: +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Unimplemented rt_sigprocmask syscall (0x3, 0x0, 0x3dff*\n +#output: program stopped with signal 4.\n + + Testing a signal handler corner case. */ + +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int +main (void) +{ + int retcode; + pthread_t th_a; + void *retval; + sigset_t sigs; + + if (sigemptyset (&sigs) != 0) + abort (); + + retcode = pthread_create (&th_a, NULL, process, NULL); + if (retcode != 0) + abort (); + + /* An invalid parameter 1 should cause this to halt the simulator. */ + retcode + = pthread_sigmask (SIG_BLOCK + SIG_UNBLOCK + SIG_SETMASK, NULL, &sigs); + /* Direct return of the error number; i.e. not using -1 and errno, + is the actual documented behavior. */ + if (retcode == ENOSYS) + printf ("ENOSYS\n"); + + printf ("xyzzy\n"); + return 0; +}
rtsigprocmask1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched4.c =================================================================== --- sched4.c (nonexistent) +++ sched4.c (revision 223) @@ -0,0 +1,24 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + struct sched_param sb; + sb.sched_priority = 0; + if (sched_setparam (getpid (), &sb) != 0 + || sb.sched_priority != 0) + abort (); + sb.sched_priority = 5; + if (sched_setparam (getpid (), &sb) == 0 + || errno != EINVAL + || sb.sched_priority != 5) + abort (); + printf ("pass\n"); + exit (0); +}
sched4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink1.c =================================================================== --- readlink1.c (nonexistent) +++ readlink1.c (revision 223) @@ -0,0 +1,20 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + char buf[1024]; + /* This depends on the test-setup, but it's unlikely that the program + is passed as a symlink, so supposedly safe. */ + if (readlink(argv[0], buf, sizeof (buf)) != -1 || errno != EINVAL) + abort (); + + printf ("pass\n"); + exit (0); +}
readlink1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched6.c =================================================================== --- sched6.c (nonexistent) +++ sched6.c (revision 223) @@ -0,0 +1,15 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include + +int main (void) +{ + if (sched_yield () != 0) + abort (); + printf ("pass\n"); + exit (0); +}
sched6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: rtsigsuspend2.c =================================================================== --- rtsigsuspend2.c (nonexistent) +++ rtsigsuspend2.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "rtsigsuspend1.c"
rtsigsuspend2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink3.c =================================================================== --- readlink3.c (nonexistent) +++ readlink3.c (revision 223) @@ -0,0 +1,6 @@ +/* Simulator options: +#notarget: cris*-*-elf +#sim: --sysroot=@exedir@ +*/ +#define SYSROOTED 1 +#include "readlink2.c"
readlink3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mapbrk.c =================================================================== --- mapbrk.c (nonexistent) +++ mapbrk.c (revision 223) @@ -0,0 +1,39 @@ +#include +#include + +/* Basic sanity check that syscalls to implement malloc (brk, mmap2, + munmap) are trivially functional. */ + +int main () +{ + void *p1, *p2, *p3, *p4, *p5, *p6; + + if ((p1 = malloc (8100)) == NULL + || (p2 = malloc (16300)) == NULL + || (p3 = malloc (4000)) == NULL + || (p4 = malloc (500)) == NULL + || (p5 = malloc (1023*1024)) == NULL + || (p6 = malloc (8191*1024)) == NULL) + { + printf ("fail\n"); + exit (1); + } + + free (p1); + free (p2); + free (p3); + free (p4); + free (p5); + free (p6); + + p1 = malloc (64000); + if (p1 == NULL) + { + printf ("fail\n"); + exit (1); + } + free (p1); + + printf ("pass\n"); + exit (0); +}
mapbrk.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink5.c =================================================================== --- readlink5.c (nonexistent) +++ readlink5.c (revision 223) @@ -0,0 +1,8 @@ +/* Check that unsupported readlink calls don't cause the simulator to abort. +#notarget: cris*-*-elf +#dest: ./readlink5.c.x +#xerror: +#output: Unimplemented readlink syscall (*)\n +#output: program stopped with signal 4.\n +*/ +#include "readlink2.c"
readlink5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe1.c =================================================================== --- pipe1.c (nonexistent) +++ pipe1.c (revision 223) @@ -0,0 +1,47 @@ +/* Check for proper pipe semantics at corner cases. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main (void) +{ + int i; + int filemax; + +#ifdef OPEN_MAX + filemax = OPEN_MAX; +#else + filemax = sysconf (_SC_OPEN_MAX); +#endif + + if (filemax < 10) + abort (); + + /* Check that pipes don't leak file descriptors. */ + for (i = 0; i < filemax * 10; i++) + { + int pip[2]; + if (pipe (pip) != 0) + { + perror ("pipe"); + abort (); + } + + if (close (pip[0]) != 0 || close (pip[1]) != 0) + { + perror ("close"); + abort (); + } + } + printf ("pass\n"); + exit (0); +}
pipe1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sched8.c =================================================================== --- sched8.c (nonexistent) +++ sched8.c (revision 223) @@ -0,0 +1,19 @@ +/* Check corner error case: specifying invalid PID. +#notarget: cris*-*-elf +*/ +#include +#include +#include +#include +#include + +int main (void) +{ + struct sched_param sb; + memset (&sb, -1, sizeof sb); + if (sched_getparam (99, &sb) != -1 + || errno != ESRCH) + abort (); + printf ("pass\n"); + exit (0); +}
sched8.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mprotect2.c =================================================================== --- mprotect2.c (nonexistent) +++ mprotect2.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "mprotect1.c"
mprotect2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: time1.c =================================================================== --- time1.c (nonexistent) +++ time1.c (revision 223) @@ -0,0 +1,46 @@ +/* Basic time functionality test: check that milliseconds are + incremented for each syscall (does not work on host). */ +#include +#include +#include +#include +#include + +void err (const char *s) +{ + perror (s); + abort (); +} + +int +main (void) +{ + struct timeval t_m = {0, 0}; + struct timezone t_z = {0, 0}; + struct timeval t_m1 = {0, 0}; + int i; + + if (gettimeofday (&t_m, &t_z) != 0) + err ("gettimeofday"); + + for (i = 1; i < 10000; i++) + if (gettimeofday (&t_m1, NULL) != 0) + err ("gettimeofday 1"); + else + if (t_m1.tv_sec * 1000000 + t_m1.tv_usec + != (t_m.tv_sec * 1000000 + t_m.tv_usec + i * 1000)) + { + fprintf (stderr, "t0 (%ld, %ld), i %d, t1 (%ld, %ld)\n", + t_m.tv_sec, t_m.tv_usec, i, t_m1.tv_sec, t_m1.tv_usec); + abort (); + } + + if (time (NULL) != t_m1.tv_sec) + { + fprintf (stderr, "time != gettod\n"); + abort (); + } + + printf ("pass\n"); + exit (0); +}
time1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink7.c =================================================================== --- readlink7.c (nonexistent) +++ readlink7.c (revision 223) @@ -0,0 +1,6 @@ +/* Check that rare readlink calls don't cause the simulator to abort. +#notarget: cris*-*-elf +#simenv: env(-u\ PWD\ foo)=bar + FIXME: Need to unset PWD, but right now I won't bother tweaking the + generic parts of the testsuite machinery and instead abuse a flaw. */ +#include "readlink2.c"
readlink7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe3.c =================================================================== --- pipe3.c (nonexistent) +++ pipe3.c (revision 223) @@ -0,0 +1,48 @@ +/* Check that TRT happens when error on pipe call. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + int i; + int filemax; + +#ifdef OPEN_MAX + filemax = OPEN_MAX; +#else + filemax = sysconf (_SC_OPEN_MAX); +#endif + + /* Check that TRT happens when error on pipe call. */ + for (i = 0; i < filemax + 1; i++) + { + int pip[2]; + if (pipe (pip) != 0) + { + /* Shouldn't happen too early. */ + if (i < filemax / 2 - 3 - 1) + { + fprintf (stderr, "i: %d\n", i); + abort (); + } + if (errno != EMFILE) + { + perror ("pipe"); + abort (); + } + goto ok; + } + } + abort (); + +ok: + printf ("pass\n"); + exit (0); +}
pipe3.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink9.c =================================================================== --- readlink9.c (nonexistent) +++ readlink9.c (revision 223) @@ -0,0 +1,23 @@ +/* Check that odd cases of readlink work. +#notarget: cris*-*-elf +#cc: additional_flags=-DX="@exedir@" +*/ + +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + /* We assume that "sim/testsuite" isn't renamed to anything that + together with "/" is shorter than 7 characters. */ + char buf[7]; + + if (readlink("/proc/42/exe", buf, sizeof (buf)) != sizeof (buf) + || strncmp (buf, X, sizeof (buf)) != 0) + abort (); + + printf ("pass\n"); + exit (0); +}
readlink9.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe5.c =================================================================== --- pipe5.c (nonexistent) +++ pipe5.c (revision 223) @@ -0,0 +1,59 @@ +/* Check that TRT happens for pipe corner cases (for our definition of TRT). +#notarget: cris*-*-elf +#xerror: +#output: Terminating simulation due to writing pipe * from one single thread\n +#output: program stopped with signal 4.\n +*/ +#include +#include +#include +#include +#include +#include +#include + +void err (const char *s) +{ + perror (s); + abort (); +} + +int main (void) +{ + int pip[2]; + int pipemax; + char *buf; + + if (pipe (pip) != 0) + err ("pipe"); + +#ifdef PIPE_MAX + pipemax = PIPE_MAX; +#else + pipemax = fpathconf (pip[1], _PC_PIPE_BUF); +#endif + + if (pipemax <= 0) + { + fprintf (stderr, "Bad pipemax %d\n", pipemax); + abort (); + } + + /* Writing an inordinate amount to the pipe. */ + buf = calloc (100 * pipemax, 1); + if (buf == NULL) + err ("calloc"); + + /* The following doesn't trig on host; writing more than PIPE_MAX to a + pipe with no reader makes the program hang. Neither does it trig + on target: we don't want to emulate the "hanging" (which would + happen with *any* amount written to a pipe with no reader if we'd + support it - but we don't). Better to abort the simulation with a + suitable message. */ + if (write (pip[1], buf, 100 * pipemax) != -1 + || errno != EFBIG) + err ("write mucho"); + + printf ("pass\n"); + exit (0); +}
pipe5.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone2.c =================================================================== --- clone2.c (nonexistent) +++ clone2.c (revision 223) @@ -0,0 +1,6 @@ +/* Make sure the thread system trivially works with trace output. +#notarget: cris*-*-elf +#sim: --cris-trace=basic --trace-file=@exedir@/clone2.tmp +#output: got: a\nthen: bc\nexit: 0\n +*/ +#include "clone1.c"
clone2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pipe7.c =================================================================== --- pipe7.c (nonexistent) +++ pipe7.c (revision 223) @@ -0,0 +1,21 @@ +/* Check for proper pipe semantics at corner cases. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (void) +{ + if (pipe (NULL) != -1 + || errno != EFAULT) + { + perror ("pipe"); + abort (); + } + + printf ("pass\n"); + exit (0); +}
pipe7.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone4.c =================================================================== --- clone4.c (nonexistent) +++ clone4.c (revision 223) @@ -0,0 +1,61 @@ +/* Check that TRT happens when we reach the #threads implementation limit. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +process (void *arg) +{ + int i; + + for (i = 0; i < 500; i++) + if (sched_yield ()) + abort (); + + return 0; +} + +int +main (void) +{ + int pid; + int i; + int stacksize = 16384; + + for (i = 0; i < 1000; i++) + { + char *stack = malloc (stacksize); + if (stack == NULL) + abort (); + + pid = clone (process, (char *) stack + stacksize - 64, + (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + | SIGCHLD, "ab"); + if (pid <= 0) + { + /* FIXME: Read sysconf instead of magic number. */ + if (i < 60) + { + fprintf (stderr, "Bad clone %d\n", pid); + abort (); + } + + if (errno == EAGAIN) + { + printf ("pass\n"); + exit (0); + } + } + } + + abort (); +}
clone4.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig11.c =================================================================== --- sig11.c (nonexistent) +++ sig11.c (revision 223) @@ -0,0 +1,32 @@ +/* Check that TRT happens when getting a non-standard (realtime) signal, more than one thread. +#notarget: cris*-*-elf +#cc: additional_flags=-pthread +#xerror: +#output: Unimplemented signal: 77\n +#output: program stopped with signal 4.\n +*/ + +#include +#include +#include +#include +#include +#include +#include + +static void * +process (void *arg) +{ + while (1) + sched_yield (); + return NULL; +} + +int main (void) +{ + pthread_t th_a; + if (pthread_create (&th_a, NULL, process, (void *) "a") == 0) + kill (getpid (), 77); + printf ("xyzzy\n"); + exit (0); +}
sig11.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: clone6.c =================================================================== --- clone6.c (nonexistent) +++ clone6.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "clone5.c"
clone6.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: sig13.c =================================================================== --- sig13.c (nonexistent) +++ sig13.c (revision 223) @@ -0,0 +1,8 @@ +/* As the included file, but specifying silent ENOSYS. +#notarget: cris*-*-elf +#sim: --cris-unknown-syscall=enosys-quiet +#output: ENOSYS\n +#output: xyzzy\n +*/ + +#include "sig7.c"
sig13.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: readlink10.c =================================================================== --- readlink10.c (nonexistent) +++ readlink10.c (revision 223) @@ -0,0 +1,18 @@ +/* Check that odd cases of readlink work. +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + if (readlink("/proc/42/exe", NULL, 4096) != -1 + || errno != EFAULT) + abort (); + + printf ("pass\n"); + exit (0); +}
readlink10.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fdopen2.c =================================================================== --- fdopen2.c (nonexistent) +++ fdopen2.c (revision 223) @@ -0,0 +1,52 @@ +/* Check that the syscalls implementing fdopen work trivially. +#output: This is the first line of this test.\npass\n +*/ + +#include +#include +#include +#include +#include + +void +perr (const char *s) +{ + perror (s); + exit (1); +} + +int +main (void) +{ + FILE *f; + int fd; + const char fname[] = "sk1test.dat"; + const char tsttxt1[] + = "This is the first line of this test.\n"; + char buf[sizeof (tsttxt1)] = ""; + + /* Write a line to stdout. */ + f = fdopen (1, "w"); + if (f == NULL + || fwrite (tsttxt1, 1, strlen (tsttxt1), f) != strlen (tsttxt1)) + perr ("fdopen or fwrite"); + +#if 0 + /* Unfortunately we can't get < /dev/null to the simulator with + reasonable test-framework surgery. */ + + /* Try to read from stdin. Expect EOF. */ + f = fdopen (0, "r"); + if (f == NULL + || fread (buf, 1, sizeof (buf), f) != 0 + || feof (f) == 0 + || ferror (f) != 0) + { + printf ("fail\n"); + exit (1); + } +#endif + + printf ("pass\n"); + exit (0); +}
fdopen2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: stat2.c =================================================================== --- stat2.c (nonexistent) +++ stat2.c (revision 223) @@ -0,0 +1,20 @@ +/* +#notarget: cris*-*-elf +*/ + +#include +#include +#include +#include +#include + +int main (void) +{ + struct stat buf; + + if (lstat (".", &buf) != 0 + || !S_ISDIR (buf.st_mode)) + abort (); + printf ("pass\n"); + exit (0); +}
stat2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.