Index: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py @@ -30,6 +30,16 @@ # Find the line numbers that we will step to in main: self.main_source = "main.c" + def remove_token(self, name): + for i in range(6): + token = name+'.token.%d'%(i+1) + if os.path.exists(token): + os.remove(token) + + def await_token(self, name): + for i in range(6): + lldbutil.wait_for_file_on_target(self, name+'.token.%d'%(i+1)) + def check_queue_for_valid_queue_id(self, queue): self.assertTrue( queue.GetQueueID() != 0, "Check queue %s for valid QueueID (got 0x%x)" % @@ -112,12 +122,14 @@ self.main_source_spec = lldb.SBFileSpec(self.main_source) break1 = target.BreakpointCreateByName("stopper", 'a.out') self.assertTrue(break1, VALID_BREAKPOINT) + self.remove_token(exe) process = target.LaunchSimple( - None, None, self.get_process_working_directory()) + [exe+'.token.'], 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: self.fail("Failed to stop at breakpoint 1.") + self.await_token(exe) queue_submittor_1 = lldb.SBQueue() queue_performer_1 = lldb.SBQueue() @@ -271,8 +283,9 @@ if self.getArchitecture() in ['arm', 'arm64', 'arm64e', 'arm64_32', 'armv7', 'armv7k']: libbtr_path = "/Developer/usr/lib/libBacktraceRecording.dylib" + self.remove_token(exe) process = target.LaunchSimple( - None, + [exe+'.token.'], [ 'DYLD_INSERT_LIBRARIES=%s' % (libbtr_path), 'DYLD_LIBRARY_PATH=/usr/lib/system/introspection'], @@ -284,6 +297,7 @@ threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1) if len(threads) != 1: self.fail("Failed to stop at breakpoint 1.") + self.await_token(exe) libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib") libbtr_module = target.FindModule(libbtr_module_filespec) Index: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -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 @@ } -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 @@ 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); });