diff options
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/localtime.c | 1 | ||||
-rw-r--r-- | winsup/cygwin/regexp/regerror.c | 1 | ||||
-rw-r--r-- | winsup/cygwin/regexp/regexp.c | 1 | ||||
-rw-r--r-- | winsup/cygwin/shared.h | 184 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/README | 42 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/config/default.exp | 6 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/crlf.c | 527 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/devzero.c | 113 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/iospeed.c | 115 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c | 4 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/samples/xf-sample-fail.c | 4 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/samples/xf-sample-miscompile.c | 1 | ||||
-rw-r--r-- | winsup/cygwin/testsuite/winsup.api/winsup.exp | 43 |
13 files changed, 3 insertions, 1039 deletions
diff --git a/winsup/cygwin/localtime.c b/winsup/cygwin/localtime.c index 50747dfcf..e4cc766fd 100644 --- a/winsup/cygwin/localtime.c +++ b/winsup/cygwin/localtime.c @@ -5,6 +5,7 @@ /* Temporarily merged private.h and tzfile.h for ease of management - DJ */ /* CYGNUS LOCAL */ +#include "winsup.h" #define lint #include <windows.h> diff --git a/winsup/cygwin/regexp/regerror.c b/winsup/cygwin/regexp/regerror.c index c595a0490..afd7a861a 100644 --- a/winsup/cygwin/regexp/regerror.c +++ b/winsup/cygwin/regexp/regerror.c @@ -1,3 +1,4 @@ +#include "winsup.h" #include "regexp.h" #include <stdio.h> diff --git a/winsup/cygwin/regexp/regexp.c b/winsup/cygwin/regexp/regexp.c index 0678a18c5..26f4b8d5d 100644 --- a/winsup/cygwin/regexp/regexp.c +++ b/winsup/cygwin/regexp/regexp.c @@ -36,6 +36,7 @@ * regular-expression syntax might require a total rethink. */ +#include "winsup.h" #include "regexp.h" #include <stdio.h> #include <ctype.h> diff --git a/winsup/cygwin/shared.h b/winsup/cygwin/shared.h index fa14492cb..ed0b83fc3 100644 --- a/winsup/cygwin/shared.h +++ b/winsup/cygwin/shared.h @@ -41,188 +41,6 @@ public: void process_queue (); }; -/******** Process Table ********/ - -/* Signal constants (have to define them here, unfortunately) */ - -enum -{ - __SIGFLUSH = -2, - __SIGSTRACE = -1, - __SIGCHILDSTOPPED = 0, - __SIGOFFSET = 3 -}; - -class pinfo -{ - public: - - /* If hProcess is set, it's because it came from a - CreateProcess call. This means it's process relative - to the thing which created the process. That's ok because - we only use this handle from the parent. */ - HANDLE hProcess; - - HANDLE parent_alive; - - /* dwProcessId contains the processid used for sending signals. It - * will be reset in a child process when it is capable of receiving - * signals. - */ - DWORD dwProcessId; - - /* User information. - The information is derived from the GetUserName system call, - with the name looked up in /etc/passwd and assigned a default value - if not found. This data resides in the shared data area (allowing - tasks to store whatever they want here) so it's for informational - purposes only. */ - uid_t uid; /* User ID */ - gid_t gid; /* Group ID */ - pid_t pgid; /* Process group ID */ - pid_t sid; /* Session ID */ - int ctty; /* Control tty */ - mode_t umask; - char username[MAX_USER_NAME]; /* user's name */ - - /* Extendend user information. - The information is derived from the internal_getlogin call - when on a NT system. */ - PSID psid; /* user's SID */ - char sidbuf[MAX_SID_LEN]; /* buffer for user's SID */ - char logsrv[MAX_HOST_NAME]; /* Logon server, may be FQDN */ - char domain[MAX_COMPUTERNAME_LENGTH+1]; /* Logon domain of the user */ - - /* token is needed if sexec should be called. It can be set by a call - to `set_impersonation_token()'. */ - HANDLE token; - BOOL impersonated; - uid_t orig_uid; /* Remains intact also after impersonation */ - uid_t orig_gid; /* Ditto */ - uid_t real_uid; /* Remains intact on seteuid, replaced by setuid */ - gid_t real_gid; /* Ditto */ - - /* Filled when chroot() is called by the process or one of it's parents. - Saved without trailing backslash. */ - char root[MAX_PATH+1]; - size_t rootlen; - - /* Non-zero if process was stopped by a signal. */ - char stopsig; - - struct sigaction& getsig (int); - void copysigs (pinfo *); - sigset_t& getsigmask (); - void setsigmask (sigset_t); - LONG* getsigtodo (int); - HANDLE getthread2signal (); - void setthread2signal (void *); - - /* Resources used by process. */ - long start_time; - struct rusage rusage_self; - struct rusage rusage_children; - -private: - struct sigaction sigs[NSIG]; - sigset_t sig_mask; /* one set for everything to ignore. */ - LONG _sigtodo[NSIG + __SIGOFFSET]; -#ifdef _MT_SAFE - ThreadItem* thread2signal; // NULL means means thread any other means a pthread -#endif - -public: - - /* Pointer to mmap'ed areas for this process. Set up by fork. */ - void *mmap_ptr; - - /* Used to spawn a child for fork(), among other things. */ - char progname[MAX_PATH]; - - #define PINFO_ZERO ((((pinfo *) NULL)->progname + 1) - ((char *) NULL)) - - /* Anything below this point is not zeroed automatically by allocate_pid */ - - /* The pid stays the same, while the hProcess moves due to execs. */ - pid_t pid; - /* Parent process id. */ - pid_t ppid; - - /* Various flags indicating the state of the process. See PID_ - constants below. */ - DWORD process_state; - - void record_death (int lock = 1); -}; - -#define ISSTATE(p, f) (!!((p)->process_state & f)) -#define NOTSTATE(p, f) (!((p)->process_state & f)) - -#define PSIZE 128 - -class pinfo_list -{ - public: - int next_pid; - pinfo vec[PSIZE]; - char lock_info[MAX_PATH + 1]; - pinfo * operator[] (pid_t x); - int size (void) { return PSIZE; } - pinfo *allocate_pid (void); - void init (void); -}; - -void __stdcall pinfo_init (PBYTE); -pinfo *__stdcall procinfo (int n); - -enum -{ - PROC_MAGIC = 0xaf08f000, - PROC_FORK = PROC_MAGIC + 1, - PROC_EXEC = PROC_MAGIC + 2, - PROC_SPAWN = PROC_MAGIC + 3, - PROC_FORK1 = PROC_MAGIC + 4 // Newer versions provide stack - // location information -}; - -#define PROC_MAGIC_MASK 0xff00f000 -#define PROC_MAGIC_GENERIC 0xaf00f000 -#define PROC_MAGIC_VER_MASK 0x0ff0000 - -#define EXEC_MAGIC_SIZE sizeof(child_info) -class child_info -{ -public: - DWORD zero[1]; // must be zeroed - DWORD cb; // size of this record - DWORD type; // type of record - int cygpid; // cygwin pid of child process - HANDLE subproc_ready; // used for synchronization with parent - HANDLE shared_h; - HANDLE console_h; - HANDLE parent_alive; // handle of thread used to track children -}; - -class child_info_fork: public child_info -{ -public: - HANDLE forker_finished;// for synchronization with child - DWORD stacksize; // size of parent stack - void *heaptop; - void *heapbase; - void *heapptr; - jmp_buf jmp; // where child will jump to - void *stacktop; // location of top of parent stack - void *stackbottom; // location of bottom of parent stack -}; - -void __stdcall init_child_info (DWORD, child_info *, int, HANDLE); - -extern child_info_fork *child_proc_info; - -/* Process info for this process */ -extern pinfo *myself; - /* non-NULL if this process is a child of a cygwin process */ extern HANDLE parent_alive; @@ -499,8 +317,6 @@ class shared_info DWORD inited; public: - pinfo_list p; - /* FIXME: Doesn't work if more than one user on system. */ mount_info mount; diff --git a/winsup/cygwin/testsuite/README b/winsup/cygwin/testsuite/README deleted file mode 100644 index 92ede0dc7..000000000 --- a/winsup/cygwin/testsuite/README +++ /dev/null @@ -1,42 +0,0 @@ -1999-12-23 DJ Delorie <dj@cygnus.com> - -Here are some notes about adding and using this testsuite. - -First, all the programs are linked with new-libcygwin.a, which is just -like libcygwin.a, except that it wants new-cygwin1.dll, not -cygwin1.dll. The testsuite adds the winsup build directory to the -PATH so that new-cygwin1.dll can be found by windows during testing. - -Because we'll probably run into complaints about using two DLLs, we -run cygrun.exe for each test. All this does is run the test with -CreateProcess() so that we don't attempt to do the special code for -when a cygwin program calls another cygwin program, as this might be a -"multiple cygwins" problem. - -Any test that needs to test command line args or redirection needs to -run such a child program itself, as the testsuite will not do any -arguments or redirection for it. Same for fork, signals, etc. - -The testsuite/winsup.api subdirectory is for testing the API to -cygwin1.dll ONLY. Create other subdirs under testsuite/ for other -classes of testing. - -Tests in winsup.api/*.c or winsup.api/*/*.c (only one subdirectory -level is allowed) either compile, run, and exit(0) or they fail. -Either abort or exit with a non-zero code to indicate failure. Don't -print anything to the screen if you can avoid it (except for failure -reasons, of course). One .c file per test, no compile options are -allowed (we're testing the api, not the compiler). - -Tests whose filename begin with "xf-" will be *expected* to fail, and -will "fail" if they compile, run, and return zero. Note that the -*only* purpose for adding this feature is to test the testing -framework itself. All real tests should NOT be named xf-*, and should -pass for real (compile, run, return 0) if the dll is working -correctly. Do not use xf-* to "silence" a failure that you know isn't -going to get fixed for a while; let it just keep failing. There are -five "sample" tests that demonstrate how the framework works and what -happens to each condition. - -"make check" will only work if you run it *on* an NT machine. -Cross-checking is not supported. diff --git a/winsup/cygwin/testsuite/config/default.exp b/winsup/cygwin/testsuite/config/default.exp deleted file mode 100644 index ec8ce1448..000000000 --- a/winsup/cygwin/testsuite/config/default.exp +++ /dev/null @@ -1,6 +0,0 @@ -proc winsup_version {} { - clone_output "\n[exec grep ^%%% ../new-cygwin1.dll]\n" -} - -proc winsup_exit {} { -} diff --git a/winsup/cygwin/testsuite/winsup.api/crlf.c b/winsup/cygwin/testsuite/winsup.api/crlf.c deleted file mode 100644 index 5dbc2227b..000000000 --- a/winsup/cygwin/testsuite/winsup.api/crlf.c +++ /dev/null @@ -1,527 +0,0 @@ - -typedef enum { - Nop=100000, /* ; do nothing */ - New1, /* ; reset and begin new test */ - Open, /* ; open test file */ - Read, /* [askfor] [get] ; read bytes into buffer */ - Write, /* [expect] [bytestream] ; write to file (expect 0 = ignore)*/ - Compare, /* [bytestream] ; compare buffer to given bytes */ - Verify, /* [bytestream] ; compare file to given bytes */ - Seek, /* [offset] [whence] ; seek in file */ - Tell, /* [offset] ; compare file positions */ - BufSize, /* [size] ; change the stdio buffer size */ - Flush, /* ; flush the stdio stream */ - Text, /* ; switch file to text mode */ - Binary, /* ; switch file to binary mode */ - Rep, /* [count] ; repeat 'R' bytes (used in bytestream) */ - Fill, /* [posn] ; fill 'F' until given byte position */ - Start, /* ; for Seek */ - Current, /* ; for Seek */ - End, /* ; for Seek, or end of byte stream */ - Max } Opcode; - -#define New New1,__LINE__ - -/* Byte streams are just inserted into the command stream, and must - end in an End code. */ - -int commands[] = { -#ifndef __DJGPP__ - New, - Write, 1605, Rep, 1600, 'h', 'e', 'l', 'l', 'o', End, - Tell, 1605, - - Open, - BufSize, 16, - Read, 1605, 1605, - Compare, Rep, 1600, 'h', 'e', 'l', 'l', 'o', End, - Tell, 1605, - Flush, - Tell, 1605, - Seek, 1000, Start, - Tell, 1000, - - New, - Text, - Write, 2, 'x', 10, End, - Verify, 'x', 13, 10, End, - - New, - Binary, - Write, 2, 'x', 10, End, - Verify, 'x', 10, End, - - BufSize, 16, - - New, - Binary, - Write, 0, Fill, 15, 13, 10, 'x', End, - Text, Open, - Read, 17, 17, - Compare, Fill, 15, 10, 'x', End, - Tell, 18, - - New, - Binary, - Write, 0, Fill, 14, 13, 10, 'x', End, - Text, Open, - Read, 16, 16, - Compare, Fill, 14, 10, 'x', End, - Tell, 17, - - New, - Binary, - Write, 0, 13, 10, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 10, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 2, - - New, - Binary, - Write, 0, 13, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 13, 'a', End, - Tell, 2, - - New, - Binary, - Write, 0, 13, 13, 10, 'a', End, - Text, Open, - Read, 2, 2, - Compare, 13, 10, End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 10, 'a', 13, End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 10, 'a', 10, End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 13, 13, 10, 'a', 10, 10, 10, End, - Text, Open, - Read, 4, 4, - Compare, 13, 13, 10, 'a', End, - Tell, 5, -#endif - - New, - Binary, - Write, 0, 13, 13, 13, 10, 'a', 'b', 13, 10, 13, 10, End, - Text, Open, - Read, 4, 4, - Compare, 13, 13, 10, 'a', End, - Tell, 5, - - }; - -/*==========================================================================*/ - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/stat.h> - -#ifndef O_BINARY -#define O_BINARY 0 -#endif -#ifndef O_TEXT -#define O_TEXT 0 -#endif - -int errors = 0; - -#define num_commands (sizeof(commands)/sizeof(commands[0])) - -int pc; -int askfor, get, expect, count, posn, whence, size; - -typedef struct { - unsigned char *bytes; - int max, count; -} Buffer; - -Buffer rw_buf={0,0,0}, cmp_buf={0,0,0}, vfy_buf={0,0,0}; - -void -expand_buf(Buffer *buf, int len) -{ - if (buf->max < len) - { - buf->max = len+20; - if (buf->bytes) - buf->bytes = (unsigned char *)realloc(buf->bytes, buf->max); - else - buf->bytes = (unsigned char *)malloc(buf->max); - } -} - -void -get_bytestream(Buffer *buf) -{ - int tpc; - int len = 0, rep, byte; - unsigned char *bp; - - for (tpc = pc+1; tpc < num_commands && commands[tpc] != End; tpc++) - { - switch (commands[tpc]) - { - case Rep: - len += commands[tpc+1]; - tpc ++; - break; - case Fill: - if (len < commands[tpc+1]) - len = commands[tpc+1]; - tpc ++; - break; - default: - len ++; - break; - } - } - - expand_buf(buf, len); - - len = 0; - bp = buf->bytes; - - for (tpc = pc+1; tpc < num_commands && commands[tpc] != End; tpc++) - { - switch (commands[tpc]) - { - case Rep: - rep = commands[++tpc]; - byte = 'R'; - while (rep--) *bp++ = byte; - break; - case Fill: - rep = commands[++tpc]; - byte = 'F'; - while (bp-buf->bytes < rep) *bp++ = byte; - break; - default: - *bp++ = commands[tpc]; - break; - } - } - buf->count = bp - buf->bytes; - pc = tpc; -} - -char dataname[] = "crlf.dat"; - -int verbose=0; -void -v(char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - printf("\n"); -} - -void -vp(char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - printf("%08x: ", pc); - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - printf("\n"); -} - -void -errorq(int use_errno, char *fmt, ...) -{ - va_list ap; - fprintf(stderr, "crlf: Error at pc=%d: ", pc); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); - if (use_errno) - perror("The error was"); - errors++; -} - -void -error(int use_errno, char *fmt, ...) -{ - va_list ap; - fprintf(stderr, "crlf: Error at pc=%d: ", pc); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); - if (use_errno) - perror("The error was"); - fprintf(stderr, "FAIL\n"); - exit(1); -} - -void -display_buf(char *which, Buffer *buf, int ofs) -{ - int i; - fprintf(stderr, "%s %04x:", which, ofs); - for (i=0; i<8; i++) - if (i+ofs < buf->count) - { - unsigned char b = buf->bytes[i+ofs]; - fprintf(stderr, " %02x", b); - if (isgraph(b)) - fprintf(stderr, " %c ", b); - else - fprintf(stderr, " ", b); - } - fprintf(stderr, "\n"); -} - -void -compare_bufs(char *name, Buffer *actual, Buffer *expected) -{ - int i, got_one=0; - for (i=0; i<actual->count && i<expected->count; i++) - if (actual->bytes[i] != expected->bytes[i]) - { - errorq(0, "%s: byte mismatch at offset 0x%x", name, i); - got_one = 1; - break; - } - if (!got_one) - { - if (actual->count < expected->count) - errorq(0, "%s: too few bytes (0x%x vs 0x%x)", name, - actual->count, expected->count); - else if (actual->count > expected->count) - errorq(0, "%s: too many bytes (0x%x vs 0x%x)", name, - actual->count, expected->count); - else - return; - } - - i -= 4; - if (i<0) i = 0; - display_buf("Actual ", actual, i); - display_buf("Expected", expected, i); -} - -int -main(int argc, char **argv) -{ - char *readmode = "rb"; - char *writemode = "wb"; - FILE *file = 0; - int i, fd; - struct stat st; - char *str; - - while (argc > 1 && argv[1][0] == '-') - { - if (strcmp(argv[1], "-v") == 0) - verbose++; - argc--; - argv++; - } - - size = 0; - - for (pc=0; pc<num_commands; pc++) - { - switch (commands[pc]) - { - case Nop: - vp("Nop"); - break; - - case New1: - i = commands[++pc]; - vp("New %d", i); - if (file) fclose(file); - file = 0; - remove(dataname); - break; - - case Open: - vp("Open"); - if (file) fclose(file); - file = 0; - break; - - case Read: - if (!file) - { - file = fopen(dataname, readmode); - if (size) - setvbuf(file, 0, _IOFBF, size); - } - if (!file) - error(1, "cannot open %s, mode %s", dataname, readmode); - askfor = commands[++pc]; - get = commands[++pc]; - vp("Read %d %d", askfor, get); - expand_buf(&rw_buf, askfor); - if (askfor == 1) - { - i = getc(file); - rw_buf.bytes[0] = i; - i = (i == EOF) ? 0 : 1; - } - else - i = fread(rw_buf.bytes, 1, askfor, file); - if (i != get) - error(0, "read wrong number of bytes (%d vs %d)", i, get); - rw_buf.count = i; - break; - - case Write: - if (!file) - { - file = fopen(dataname, writemode); - if (size) - setvbuf(file, 0, _IOFBF, size); - } - if (!file) - error(1, "cannot open %s, mode %s\n", dataname, writemode); - expect = commands[++pc]; - get_bytestream(&rw_buf); - vp("Write %d %d", rw_buf.count, expect); - if (askfor == 1) - { - i = putc(rw_buf.bytes[0], file); - i = (i == EOF) ? 0 : 1; - } - else - i = fwrite(rw_buf.bytes, 1, rw_buf.count, file); - if (expect && (i != expect)) - error(0, "wrote wrong number of bytes (%d vs %d)", i, expect); - break; - - case Compare: - get_bytestream(&cmp_buf); - vp("Compare %d/%d", rw_buf.count, cmp_buf.count); - compare_bufs("Compare", &rw_buf, &cmp_buf); - break; - - case Verify: - if (file) fclose(file); - file = 0; - get_bytestream(&cmp_buf); - vp("Verify %s", dataname); - if (stat(dataname, &st)) - error(1, "Can't stat %s", dataname); - expand_buf(&vfy_buf, st.st_size); - i = open(dataname, O_RDONLY|O_BINARY, 0); - vfy_buf.count = read(i, vfy_buf.bytes, st.st_size); - close(i); - compare_bufs("Verify", &vfy_buf, &cmp_buf); - break; - - case Seek: - posn = commands[++pc]; - whence = commands[++pc]; - switch (whence) - { - case Start: - whence = SEEK_SET; - str = "Start"; - break; - case Current: - whence = SEEK_CUR; - str = "Current"; - break; - case End: - whence = SEEK_END; - str = "End"; - break; - } - vp("Seek 0x%x %s", posn, str); - i = fseek(file, posn, whence); - if (i) - error(1, "fseek failed"); - break; - - case Tell: - posn = commands[++pc]; - vp("Tell 0x%x", posn); - i = ftell(file); - if (i != posn) - error(0, "ftell failed, got 0x%x expected 0x%x", i, posn); - break; - - case BufSize: - size = commands[++pc]; - vp("BufSize 0x%x", size); - if (file) - { - fflush(file); - setvbuf(file, 0, _IOFBF, size); - } - break; - - case Flush: - vp("Flush"); - if (file) - fflush(file); - break; - - case Text: - vp("Text"); - readmode = "rt"; - writemode = "wt"; - break; - - case Binary: - vp("Binary"); - readmode = "rb"; - writemode = "wb"; - break; - - default: - printf("Invalid command code %d at offset %d\n", commands[pc], pc); - exit(1); - } - } - - if (file) fclose(file); - - if (errors) - printf("FAIL: %d error%s\n", errors, errors==1?"":"s"); - else - { - printf("PASS\n"); - unlink (dataname); - } - return errors; -} diff --git a/winsup/cygwin/testsuite/winsup.api/devzero.c b/winsup/cygwin/testsuite/winsup.api/devzero.c deleted file mode 100644 index 85a2615b1..000000000 --- a/winsup/cygwin/testsuite/winsup.api/devzero.c +++ /dev/null @@ -1,113 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <sys/mman.h> - -main() -{ - int fd, r, w, l; - char buf[1024]; - char *v; - - fd = open("/dev/zero", O_RDONLY); - if (fd < 0) - { - fprintf(stderr, "Unable to open /dev/zero for reading\n"); - perror("The error was"); - exit(1); - } - - l = read(fd, buf, 1024); - if (l != 1024) - { - fprintf(stderr, "Asked to read 1024 bytes, got %d\n", l); - exit(1); - } - - for (r=0; r<1024; r++) - if (buf[r] != 0) - { - fprintf(stderr, "/dev/zero returned a byte of %02x at offset %d\n", - buf[r], r); - exit(1); - } - - l = lseek(fd, 4096, 0); - if (l != 0) - { - fprintf(stderr, "l == %d\n", l); - exit(1); - } - - l = close(fd); - if (l != 0) - { - fprintf(stderr, "close: returned %d\n", l); - perror("The error was"); - exit(1); - } - - fd = open("/dev/zero", O_WRONLY); - if (fd < 0) - { - fprintf(stderr, "Unable to open /dev/zero for writing\n"); - perror("The error was"); - exit(1); - } - - l = write(fd, buf, 1024); - if (l != 1024) - { - fprintf(stderr, "Asked to write 1024 bytes, got %d\n", l); - exit(1); - } - - l = close(fd); - if (l != 0) - { - fprintf(stderr, "close: returned %d\n", l); - perror("The error was"); - exit(1); - } - - fd = open("/dev/zero", O_RDWR); - v = (char *)mmap(0, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - if (v == (char *)-1) - { - fprintf(stderr, "mmap r/w /dev/zero failed\n"); - perror("The error was"); - exit(1); - } - - for (r=0; r<65536; r++) - if (v[r] != 0) - { - fprintf(stderr, "mmap'd r/w /dev/zero has byte %d at offset %d\n", - v[r], r); - exit(1); - } - munmap(v, 65536); - close(fd); - - fd = open("/dev/zero", O_RDONLY); - v = (char *)mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0); - if (v == (char *)-1) - { - fprintf(stderr, "mmap /dev/zero r/o failed\n"); - perror("The error was"); - exit(1); - } - - for (r=0; r<65536; r++) - if (v[r] != 0) - { - fprintf(stderr, "mmap'd r/o /dev/zero has byte %d at offset %d\n", - v[r], r); - exit(1); - } - munmap(v, 65536); - close(fd); - - exit(0); -} diff --git a/winsup/cygwin/testsuite/winsup.api/iospeed.c b/winsup/cygwin/testsuite/winsup.api/iospeed.c deleted file mode 100644 index d286f90bd..000000000 --- a/winsup/cygwin/testsuite/winsup.api/iospeed.c +++ /dev/null @@ -1,115 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> -#include <fcntl.h> -#include <unistd.h> -#include <windows.h> - -int verbose = 0; - -void -v(char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); -} - -#define TSIZE (1024 * 1024 * 16) - -unsigned long start_tic; - -void -start(FILE *f) -{ - fseek(f, 0, SEEK_SET); - start_tic = GetTickCount(); -} - -void -end() -{ - unsigned long end_tic = GetTickCount(); - printf("%6d", end_tic - start_tic); -} - -void -test(int linesz, int cr) -{ - FILE *f = fopen("iospeed.dat", "wb"); - char buf[65536]; - int i, fd; - - memset(buf, 'x', linesz); - buf[linesz-1] = '\n'; - if (cr) - buf[linesz-2] = '\r'; - for (i=0; i<TSIZE; i += linesz) - fwrite(buf, 1, linesz, f); - fclose(f); - - f = fopen("iospeed.dat", "rt"); - fd = fileno(f); - - printf("%6d%6d", linesz, cr); - for (i=0; i<TSIZE; i+= 65536) - read(fd, buf, 65536); - - start(f); - while (getc(f) != EOF); - end(); - - start(f); - while (fread(buf, 1, 256, f) > 0); - end(); - - start(f); - while (fgets(buf, 64436, f)); - end(); - - f = fopen("iospeed.dat", "rb"); - fd = fileno(f); - - for (i=0; i<TSIZE; i+= 65536) - read(fd, buf, 65536); - - start(f); - while (getc(f) != EOF); - end(); - - start(f); - while (fread(buf, 1, 256, f) > 0); - end(); - - start(f); - while (fgets(buf, 64436, f)); - end(); - - printf("\n"); -} - -int -main(int argc, char **argv) -{ - if (argc > 1 && strcmp(argv[1],"-v") == 0) - verbose = 1; - - setbuf(stdout, 0); - - printf(" ----- text ----- ---- binary ----\n"); - printf("linesz cr getc fread fgets getc fread fgets\n"); - - test(4, 0); - test(64, 0); - test(4096, 0); - test(4, 1); - test(64, 1); - test(4096, 1); - - remove ("iospeed.dat"); - - return 0; -} diff --git a/winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c b/winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c deleted file mode 100644 index 893a0b605..000000000 --- a/winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c +++ /dev/null @@ -1,4 +0,0 @@ -main() -{ - return 0; -} diff --git a/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-fail.c b/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-fail.c deleted file mode 100644 index d8beb90be..000000000 --- a/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-fail.c +++ /dev/null @@ -1,4 +0,0 @@ -main() -{ - return 1; -} diff --git a/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-miscompile.c b/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-miscompile.c deleted file mode 100644 index bc0d21d2e..000000000 --- a/winsup/cygwin/testsuite/winsup.api/samples/xf-sample-miscompile.c +++ /dev/null @@ -1 +0,0 @@ -foo bar grill diff --git a/winsup/cygwin/testsuite/winsup.api/winsup.exp b/winsup/cygwin/testsuite/winsup.api/winsup.exp deleted file mode 100644 index 96e7c7cf4..000000000 --- a/winsup/cygwin/testsuite/winsup.api/winsup.exp +++ /dev/null @@ -1,43 +0,0 @@ -source "site.exp" - -if { ! [isnative] } { - verbose "skipping winsup.api because it's not native" - return -} - -set rv "" - -proc ws_spawn {cmd args} { - global rv - verbose "running $cmd\n" - catch [eval "exec $cmd"] rv - verbose send "catchCode = $rv\n" -} - -foreach src [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.c] { - regsub "^$srcdir/$subdir/" $src "" testcase - regsub ".c$" $testcase "" base - regsub ".*/" $base "" basename - regsub "/" $base "-" base - - if { [regexp "^xf-" $basename] } { - setup_xfail "*-*-*" - } else { - clear_xfail - } - - ws_spawn "$CC $src $rootme/new-libcygwin.a -o $base.exe" - if { $rv != "" } { - verbose -log "$rv" - fail "$testcase (compile)" - } else { - ws_spawn "../cygrun ./$base.exe > /dev/null" - if { $rv != "" } { - verbose -log "$testcase: $rv" - fail "$testcase (execute)" - } else { - pass "$testcase" - file delete "$base.exe" - } - } -} |