diff options
author | Adrian Prantl <aprantl@apple.com> | 2019-01-02 19:06:22 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2019-01-02 19:06:22 +0000 |
commit | 5eade7ab3c930514f701b033026574771d0cab8b (patch) | |
tree | 33537eeb5cce4f54c11b78d0ad37381261a0b2df /lldb/packages/Python/lldbsuite/test/macosx/queues/main.c | |
parent | f5f1fb594b34718e951fcf92823ca4ec5a7660c2 (diff) | |
download | bcm5719-llvm-5eade7ab3c930514f701b033026574771d0cab8b.tar.gz bcm5719-llvm-5eade7ab3c930514f701b033026574771d0cab8b.zip |
Add file-based synchronization to flaky test
TestQueues is failing randomly on green dragon and I suspect it is
because the enqueued threads haven't executed by the time we expect
them. This patch adds file-based synchronization to the queues.
Differential Revision: https://reviews.llvm.org/D56208
llvm-svn: 350247
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/macosx/queues/main.c')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/macosx/queues/main.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c b/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c index 715a3f3af52..9e7c1a8aedc 100644 --- a/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c +++ b/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c @@ -1,4 +1,6 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <unistd.h> #include <dispatch/dispatch.h> #include <pthread.h> @@ -6,6 +8,19 @@ int finished_enqueueing_work = 0; void +touch (const char *name, unsigned n) +{ + char token[2048]; + snprintf (token, 2048, "%s%d", name, n); + FILE *f = fopen (token, "wx"); + if (!f) + exit (1); + fputs ("\n", f); + fflush (f); + fclose (f); +} + +void doing_the_work_1(void *in) { while (1) @@ -77,7 +92,7 @@ stopper () } -int main () +int main (int argc, const char **argv) { dispatch_queue_t work_submittor_1 = dispatch_queue_create ("com.apple.work_submittor_1", DISPATCH_QUEUE_SERIAL); dispatch_queue_t work_submittor_2 = dispatch_queue_create ("com.apple.work_submittor_and_quit_2", DISPATCH_QUEUE_SERIAL); @@ -100,31 +115,37 @@ int main () dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ pthread_setname_np ("user initiated QoS"); + touch(argv[1], 1); while (1) sleep (10); }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{ pthread_setname_np ("user interactive QoS"); + touch(argv[1], 2); while (1) sleep (10); }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ pthread_setname_np ("default QoS"); + touch(argv[1], 3); while (1) sleep (10); }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{ pthread_setname_np ("utility QoS"); + touch(argv[1], 4); while (1) sleep (10); }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ pthread_setname_np ("background QoS"); + touch(argv[1], 5); while (1) sleep (10); }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{ pthread_setname_np ("unspecified QoS"); + touch(argv[1], 6); while (1) sleep (10); }); |