Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/testsuite')
-rw-r--r--winsup/testsuite/winsup.api/pthread/cancel3.c18
-rw-r--r--winsup/testsuite/winsup.api/pthread/cancel5.c18
2 files changed, 32 insertions, 4 deletions
diff --git a/winsup/testsuite/winsup.api/pthread/cancel3.c b/winsup/testsuite/winsup.api/pthread/cancel3.c
index 07feb7c9b..8ed7d529b 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel3.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel3.c
@@ -75,9 +75,9 @@ mythread(void * arg)
assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
/*
- * We wait up to 10 seconds for a cancelation to be applied to us.
+ * We wait up to 30 seconds for a cancelation to be applied to us.
*/
- for (bag->count = 0; bag->count < 10; bag->count++)
+ for (bag->count = 0; bag->count < 30; bag->count++)
{
/* Busy wait to avoid Sleep(), since we can't asynchronous cancel inside a
kernel function. (This is still somewhat fragile as if the async cancel
@@ -92,6 +92,9 @@ mythread(void * arg)
}
}
+ /* Notice if asynchronous cancel got deferred */
+ pthread_testcancel();
+
return result;
}
@@ -101,6 +104,7 @@ main()
int failed = 0;
int i;
pthread_t t[NUMTHREADS + 1];
+ int ran_to_completion = 0;
assert((t[0] = pthread_self()) != NULL);
@@ -166,9 +170,19 @@ main()
threadbag[i].count,
result);
}
+
+ if (threadbag[i].count >= 30)
+ ran_to_completion++;
+
failed = (failed || fail);
}
+ if (ran_to_completion >= 10)
+ {
+ fprintf(stderr, "All threads ran to completion, async cancellation never happened\n");
+ failed = 1;
+ }
+
assert(!failed);
/*
diff --git a/winsup/testsuite/winsup.api/pthread/cancel5.c b/winsup/testsuite/winsup.api/pthread/cancel5.c
index 999b3c95c..dd5be7bea 100644
--- a/winsup/testsuite/winsup.api/pthread/cancel5.c
+++ b/winsup/testsuite/winsup.api/pthread/cancel5.c
@@ -76,9 +76,9 @@ mythread(void * arg)
assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
/*
- * We wait up to 10 seconds for a cancelation to be applied to us.
+ * We wait up to 30 seconds for a cancelation to be applied to us.
*/
- for (bag->count = 0; bag->count < 10; bag->count++)
+ for (bag->count = 0; bag->count < 30; bag->count++)
{
/* Busy wait to avoid Sleep(), since we can't asynchronous cancel inside a
kernel function. (This is still somewhat fragile as if the async cancel
@@ -93,6 +93,9 @@ mythread(void * arg)
}
}
+ /* Notice if asynchronous cancel got deferred */
+ pthread_testcancel();
+
return result;
}
@@ -102,6 +105,7 @@ main()
int failed = 0;
int i;
pthread_t t[NUMTHREADS + 1];
+ int ran_to_completion = 0;
for (i = 1; i <= NUMTHREADS; i++)
{
@@ -165,9 +169,19 @@ main()
threadbag[i].count,
result);
}
+
+ if (threadbag[i].count >= 30)
+ ran_to_completion++;
+
failed = (failed || fail);
}
+ if (ran_to_completion >= 10)
+ {
+ fprintf(stderr, "All threads ran to completion, async cancellation never happened\n");
+ failed = TRUE;
+ }
+
assert(!failed);
/*