diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/macosx/queues')
-rw-r--r-- | packages/Python/lldbsuite/test/macosx/queues/TestQueues.py | 18 | ||||
-rw-r--r-- | packages/Python/lldbsuite/test/macosx/queues/main.c | 48 |
2 files changed, 45 insertions, 21 deletions
diff --git a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py index ba58372ce5b7..cdc9606c377a 100644 --- a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py +++ b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py @@ -18,10 +18,16 @@ class TestQueues(TestBase): @skipUnlessDarwin @add_test_categories(['pyapi']) - def test_with_python_api(self): + def test_with_python_api_queues(self): """Test queues inspection SB APIs.""" self.build() self.queues() + + @skipUnlessDarwin + @add_test_categories(['pyapi']) + def test_with_python_api_queues_with_backtrace(self): + """Test queues inspection SB APIs.""" + self.build() self.queues_with_libBacktraceRecording() def setUp(self): @@ -113,7 +119,7 @@ class TestQueues(TestBase): break1 = target.BreakpointCreateByName("stopper", 'a.out') self.assertTrue(break1, VALID_BREAKPOINT) process = target.LaunchSimple( - None, None, self.get_process_working_directory()) + [], None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: @@ -267,10 +273,14 @@ class TestQueues(TestBase): self.assertTrue(break1, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. + libbtr_path = "/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib" + if self.getArchitecture() in ['arm', 'arm64', 'arm64e', 'arm64_32', 'armv7', 'armv7k']: + libbtr_path = "/Developer/usr/lib/libBacktraceRecording.dylib" + process = target.LaunchSimple( - None, + [], [ - 'DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib', + 'DYLD_INSERT_LIBRARIES=%s' % (libbtr_path), 'DYLD_LIBRARY_PATH=/usr/lib/system/introspection'], self.get_process_working_directory()) diff --git a/packages/Python/lldbsuite/test/macosx/queues/main.c b/packages/Python/lldbsuite/test/macosx/queues/main.c index 715a3f3af52c..3978b92bff1a 100644 --- a/packages/Python/lldbsuite/test/macosx/queues/main.c +++ b/packages/Python/lldbsuite/test/macosx/queues/main.c @@ -1,13 +1,18 @@ -#include <stdio.h> +#include <stdatomic.h> +#include <string.h> #include <unistd.h> #include <dispatch/dispatch.h> #include <pthread.h> -int finished_enqueueing_work = 0; +atomic_int finished_enqueueing_work = 0; +atomic_int thread_count = 0; void doing_the_work_1(void *in) { + // This is only counted once because the first job in the queue + // starves all the others. + atomic_fetch_add(&thread_count, 1); while (1) sleep (1); } @@ -26,13 +31,15 @@ submit_work_1b(void *in) dispatch_queue_t *work_performer_1 = (dispatch_queue_t*) in; dispatch_async_f (*work_performer_1, NULL, doing_the_work_1); dispatch_async_f (*work_performer_1, NULL, doing_the_work_1); + atomic_fetch_add(&thread_count, 1); while (1) - sleep (1); + sleep (1); } void doing_the_work_2(void *in) { + atomic_fetch_add(&thread_count, 1); while (1) sleep (1); } @@ -42,20 +49,22 @@ submit_work_2(void *in) { dispatch_queue_t *work_performer_2 = (dispatch_queue_t*) in; int i = 0; - while (i++ < 5000) + while (i++ < 5000) { dispatch_async_f (*work_performer_2, NULL, doing_the_work_2); dispatch_async_f (*work_performer_2, NULL, doing_the_work_2); } - finished_enqueueing_work = 1; + atomic_fetch_add(&finished_enqueueing_work, 1); } void doing_the_work_3(void *in) { + // This counts four times, since the queue is marked as CONCURRENT. + atomic_fetch_add(&thread_count, 1); while (1) - sleep(1); + sleep (1); } void @@ -77,7 +86,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); @@ -97,41 +106,46 @@ int main () // Spin up threads with each of the different libdispatch QoS values. - dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ pthread_setname_np ("user initiated QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{ pthread_setname_np ("user interactive QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ pthread_setname_np ("default QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{ pthread_setname_np ("utility QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ pthread_setname_np ("background QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{ pthread_setname_np ("unspecified QoS"); + atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); - - while (finished_enqueueing_work == 0) + // Unfortunately there is no pthread_barrier on darwin. + while ((atomic_load(&thread_count) < 13) || (finished_enqueueing_work == 0)) sleep (1); - stopper (); + stopper (); } |