2002-11-25 Robert Collins <rbtcollins@hotmail.com>
* readme: Document running portions of the test suite (Thanks Egor!). * winsup.api/pthread/mainthreadexits.c: New file, derived from Thomas Pfaff's test cases. * winsup.api/pthread/threadidafterfork.c: Ditto.
This commit is contained in:
parent
f29c4db185
commit
4f0de34d37
@ -1,3 +1,10 @@
|
|||||||
|
2002-11-25 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* readme: Document running portions of the test suite (Thanks Egor!).
|
||||||
|
* winsup.api/pthread/mainthreadexits.c: New file, derived from
|
||||||
|
Thomas Pfaff's test cases.
|
||||||
|
* winsup.api/pthread/threadidafterfork.c: Ditto.
|
||||||
|
|
||||||
2002-08-25 Christopher Faylor <cgf@redhat.com>
|
2002-08-25 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* Makefile.in (RUNTEST): Use Makefile's srcdir and bupdir* macros,
|
* Makefile.in (RUNTEST): Use Makefile's srcdir and bupdir* macros,
|
||||||
|
@ -33,3 +33,8 @@ to fail, and will "fail" if they compile, run, and return zero.
|
|||||||
|
|
||||||
"make check" will only work if you run it *on* an NT machine.
|
"make check" will only work if you run it *on* an NT machine.
|
||||||
Cross-checking is not supported.
|
Cross-checking is not supported.
|
||||||
|
|
||||||
|
To test a subset of the test-suite, use
|
||||||
|
$ make check CYGWIN_TESTSUITE_TESTS=regexp
|
||||||
|
|
||||||
|
|
||||||
|
47
winsup/testsuite/winsup.api/pthread/mainthreadexits.c
Normal file
47
winsup/testsuite/winsup.api/pthread/mainthreadexits.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static void * Thread (void *);
|
||||||
|
|
||||||
|
static pthread_t main_thread;
|
||||||
|
static pthread_t secondThread;
|
||||||
|
static int result = 2;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
main_thread = pthread_self ();
|
||||||
|
|
||||||
|
if (pthread_create (&secondThread, NULL, Thread, NULL))
|
||||||
|
exit (1);
|
||||||
|
sleep (5);
|
||||||
|
pthread_exit (&result);
|
||||||
|
/* If pthread_exit doesm't (which would be a bug) then we do */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * Thread (void *not_used)
|
||||||
|
{
|
||||||
|
void *myresult;
|
||||||
|
/* We should be able to join this */
|
||||||
|
if (pthread_join (main_thread, &myresult))
|
||||||
|
exit (1);
|
||||||
|
|
||||||
|
if (*(int *)myresult != 2)
|
||||||
|
exit (1);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
This valid code doesn't work at all. The mainthread object in MTinterface
|
||||||
|
is not properly initialized, the cancel_event is NULL and the win32_obj_id
|
||||||
|
is NULL because myself->hProcess is NULL when MTinterface is initialized
|
||||||
|
(and i don't think that a process handle can be used as thread handle).
|
||||||
|
Even if the handles would be valid the pthread_join call would try to
|
||||||
|
delete a thread object that is created static which would result in a
|
||||||
|
corrupted heap.
|
||||||
|
|
||||||
|
Concept test Contributed by Thomas Pfaff <tpfaff@gmx.net>
|
||||||
|
Scriptable test by Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
*/
|
49
winsup/testsuite/winsup.api/pthread/threadidafterfork.c
Normal file
49
winsup/testsuite/winsup.api/pthread/threadidafterfork.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static void * TestThread ( void * );
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
pthread_t t;
|
||||||
|
|
||||||
|
pthread_create (&t, NULL, TestThread, NULL);
|
||||||
|
pthread_join (t, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void * TestThread ( void *not_used )
|
||||||
|
{
|
||||||
|
pthread_t iAm = pthread_self();
|
||||||
|
int status;
|
||||||
|
switch (fork ())
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
exit(1);
|
||||||
|
case 0:
|
||||||
|
if (iAm != pthread_self())
|
||||||
|
exit (1);
|
||||||
|
else
|
||||||
|
exit (0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wait (&status);
|
||||||
|
if (status != 0)
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The forked child will not get the same thread handle as its parent, it
|
||||||
|
will get the thread handle from the main thread instead. The child will
|
||||||
|
not terminate because the threadcount is still 2 after the fork (it is
|
||||||
|
set to 1 in MTinterface::Init and then set back to 2 after the childs
|
||||||
|
memory gets overwritten by the parent).
|
||||||
|
|
||||||
|
concept test by Thomas Pfaff <tpfaff@gmx.net>
|
||||||
|
scritable test by Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
*/
|
Loading…
x
Reference in New Issue
Block a user