import winsup-2000-02-17 snapshot
This commit is contained in:
42
winsup/cygwin/testsuite/README
Normal file
42
winsup/cygwin/testsuite/README
Normal file
@@ -0,0 +1,42 @@
|
||||
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.
|
6
winsup/cygwin/testsuite/config/default.exp
Normal file
6
winsup/cygwin/testsuite/config/default.exp
Normal file
@@ -0,0 +1,6 @@
|
||||
proc winsup_version {} {
|
||||
clone_output "\n[exec grep ^%%% ../new-cygwin1.dll]\n"
|
||||
}
|
||||
|
||||
proc winsup_exit {} {
|
||||
}
|
113
winsup/cygwin/testsuite/winsup.api/devzero.c
Normal file
113
winsup/cygwin/testsuite/winsup.api/devzero.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#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);
|
||||
}
|
4
winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c
Normal file
4
winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c
Normal file
@@ -0,0 +1,4 @@
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
main()
|
||||
{
|
||||
return 1;
|
||||
}
|
@@ -0,0 +1 @@
|
||||
foo bar grill
|
43
winsup/cygwin/testsuite/winsup.api/winsup.exp
Normal file
43
winsup/cygwin/testsuite/winsup.api/winsup.exp
Normal file
@@ -0,0 +1,43 @@
|
||||
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"
|
||||
if { $rv != "" } {
|
||||
verbose -log "$testcase: $rv"
|
||||
fail "$testcase (execute)"
|
||||
} else {
|
||||
pass "$testcase"
|
||||
file delete "$base.exe"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user