Re: [Lldb-commits] [PATCH] fix Bug21211 : reworked test/api/multithreaded/test_listener_event_description.cpp to work properly on Linux/FreeBSD

2014-11-20 Thread Shawn Best
Closed by commit rL222511 (authored by @sbest).

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D5837

Files:
  lldb/trunk/test/api/multithreaded/TestMultithreaded.py
  lldb/trunk/test/api/multithreaded/test_listener_event_description.cpp
Index: lldb/trunk/test/api/multithreaded/TestMultithreaded.py
===
--- lldb/trunk/test/api/multithreaded/TestMultithreaded.py
+++ lldb/trunk/test/api/multithreaded/TestMultithreaded.py
@@ -28,7 +28,6 @@
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
-@expectedFailureFreeBSD(llvm.org/21211)
 @skipIfi386
 @skipIfRemote
 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11
Index: lldb/trunk/test/api/multithreaded/test_listener_event_description.cpp
===
--- lldb/trunk/test/api/multithreaded/test_listener_event_description.cpp
+++ lldb/trunk/test/api/multithreaded/test_listener_event_description.cpp
@@ -16,16 +16,17 @@
 using namespace std;
 
 // listener thread control
-extern atomicbool g_done; 
+extern atomicbool g_done;
+extern SBListener g_listener;
 
 multithreaded_queuestring g_event_descriptions;
-
-extern SBListener g_listener;
+string g_error_desc;
 
 void listener_func() {
   while (!g_done) {
 SBEvent event;
 bool got_event = g_listener.WaitForEvent(1, event);
+
 if (got_event) {
   if (!event.IsValid())
 throw Exception(event is not valid in listener thread);
@@ -38,27 +39,59 @@
   }
 }
 
-void check_listener(SBDebugger dbg) {
-  arraystring, 2 expected_states = {running, stopped};
-  for(string  state : expected_states) {
-bool got_description = false;
-string desc = g_event_descriptions.pop(5, got_description);
-
-if (!got_description)
-  throw Exception(Did not get expected event description);
-
+bool check_state(string state, string desc, bool got_description)
+{
+g_error_desc.clear();
+
+if(!got_description)
+{
+g_error_desc.append(Did not get expected event description);
+return false;
+}
 
 if (desc.find(state-changed) == desc.npos)
-  throw Exception(Event description incorrect: missing 'state-changed');
+g_error_desc.append(Event description incorrect: missing 'state-changed' );
+
+if (desc.find(pid = ) == desc.npos)
+g_error_desc.append(Event description incorrect: missing process pid );
 
 string state_search_str = state =  + state;
 if (desc.find(state_search_str) == desc.npos)
-  throw Exception(Event description incorrect: expected state 
+{
+string errString = (Event description incorrect: expected state 
   + state
   +  but desc was 
   + desc);
+g_error_desc.append(errString);
+}
 
-if (desc.find(pid = ) == desc.npos)
-  throw Exception(Event description incorrect: missing process pid);
-  }
+if (g_error_desc.length()  0)
+return false;
+
+cout  check_state:   stateOK\n;
+return true;
+}
+
+void check_listener(SBDebugger dbg)
+{
+bool got_description;
+string state;
+
+// check for launching state, this may or may not be present
+string desc = g_event_descriptions.pop(5, got_description);
+state = launching;
+if (check_state(state, desc, got_description))
+{
+// found a 'launching' state, pop next one from queue
+desc = g_event_descriptions.pop(5, got_description);
+}
+
+state = running;
+if( !check_state(state, desc, got_description) )
+throw Exception(g_error_desc);
+
+desc = g_event_descriptions.pop(5, got_description);
+state = stopped;
+if( !check_state(state, desc, got_description) )
+throw Exception(g_error_desc);
 }
___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] fix Bug21211 : reworked test/api/multithreaded/test_listener_event_description.cpp to work properly on Linux/FreeBSD

2014-11-14 Thread Shawn Best
friendly ping.  I was waiting until the other change (D5838 ENABLE_STD_THREADS) 
landed and I could run the tests in api/multithreaded again.  This is a rework 
of the test program logic to accommodate the fact that OSx and linux broadcast 
a different sequence of public events due to their different inferior launching.

I can confirm the test passes on Linux, and OSx.  I assume it now will pass 
correctly on FreeBSD since it exhibited a similar failure to Linux when it got 
broken by D5632.

http://reviews.llvm.org/D5837



___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] fix Bug21211 : reworked test/api/multithreaded/test_listener_event_description.cpp to work properly on Linux/FreeBSD

2014-10-16 Thread Shawn Best
Hi emaste,

Issue D5632 fixed an issue where linux would dump spurious output to tty on 
startup (due to a broadcast stop event).  After the checkin, it was noticed on 
FreeBSD a unit test was now failing.  On closer investigation I found the test 
was using the C++ API to launch an inferior while using an SBListener to 
monitor the public state changes. It was expecting to see:

eStateRunning
eStateStopped

On Linux/FreeBSD, there is an extra state change

eStateLaunching
eStateRunning
eStateStopped

I reworked the test to work for both cases.

http://reviews.llvm.org/D5837

Files:
  test/api/multithreaded/TestMultithreaded.py
  test/api/multithreaded/test_listener_event_description.cpp
Index: test/api/multithreaded/TestMultithreaded.py
===
--- test/api/multithreaded/TestMultithreaded.py
+++ test/api/multithreaded/TestMultithreaded.py
@@ -28,7 +28,6 @@
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
-@expectedFailureFreeBSD(llvm.org/21211)
 @skipIfi386
 @skipIfRemote
 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11
Index: test/api/multithreaded/test_listener_event_description.cpp
===
--- test/api/multithreaded/test_listener_event_description.cpp
+++ test/api/multithreaded/test_listener_event_description.cpp
@@ -16,16 +16,17 @@
 using namespace std;
 
 // listener thread control
-extern atomicbool g_done; 
+extern atomicbool g_done;
+extern SBListener g_listener;
 
 multithreaded_queuestring g_event_descriptions;
-
-extern SBListener g_listener;
+string g_error_desc;
 
 void listener_func() {
   while (!g_done) {
 SBEvent event;
 bool got_event = g_listener.WaitForEvent(1, event);
+
 if (got_event) {
   if (!event.IsValid())
 throw Exception(event is not valid in listener thread);
@@ -38,27 +39,59 @@
   }
 }
 
-void check_listener(SBDebugger dbg) {
-  arraystring, 2 expected_states = {running, stopped};
-  for(string  state : expected_states) {
-bool got_description = false;
-string desc = g_event_descriptions.pop(5, got_description);
-
-if (!got_description)
-  throw Exception(Did not get expected event description);
+bool check_state(string state, string desc, bool got_description)
+{
+g_error_desc.clear();
 
+if(!got_description)
+{
+g_error_desc.append(Did not get expected event description);
+return false;
+}
 
 if (desc.find(state-changed) == desc.npos)
-  throw Exception(Event description incorrect: missing 'state-changed');
+g_error_desc.append(Event description incorrect: missing 'state-changed' );
+
+if (desc.find(pid = ) == desc.npos)
+g_error_desc.append(Event description incorrect: missing process pid );
 
 string state_search_str = state =  + state;
 if (desc.find(state_search_str) == desc.npos)
-  throw Exception(Event description incorrect: expected state 
+{
+string errString = (Event description incorrect: expected state 
   + state
   +  but desc was 
   + desc);
+g_error_desc.append(errString);
+}
 
-if (desc.find(pid = ) == desc.npos)
-  throw Exception(Event description incorrect: missing process pid);
-  }
+if (g_error_desc.length()  0)
+return false;
+
+cout  check_state:   stateOK\n;
+return true;
+}
+
+void check_listener(SBDebugger dbg)
+{
+bool got_description;
+string state;
+
+// check for launching state, this may or may not be present
+string desc = g_event_descriptions.pop(5, got_description);
+state = launching;
+if (check_state(state, desc, got_description))
+{
+// found a 'launching' state, pop next one from queue
+desc = g_event_descriptions.pop(5, got_description);
+}
+
+state = running;
+if( !check_state(state, desc, got_description) )
+throw Exception(g_error_desc);
+
+desc = g_event_descriptions.pop(5, got_description);
+state = stopped;
+if( !check_state(state, desc, got_description) )
+throw Exception(g_error_desc);
 }
___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits