This is an archive of the discontinued LLVM Phabricator instance.

Fix TestJoinAfterBreak test on Windows
ClosedPublic

Authored by amccarth on Jun 1 2015, 1:48 PM.

Details

Reviewers
zturner
jingham
Summary
  1. Converted the inferior to use <thread> so that it can compile cross-platform
  2. Set a thread's state to eStateStopped when it's suspended.
  3. Don't set the resume state in WillResume. That's just a hook for derived Thread classes to do bookkeeping.
  4. Adjust the expectations in the test to match reality.

Diff Detail

Event Timeline

amccarth updated this revision to Diff 26924.Jun 1 2015, 1:48 PM
amccarth retitled this revision from to Fix TestJoinAfterBreak test on Windows.
amccarth updated this object.
amccarth edited the test plan for this revision. (Show Details)
amccarth added reviewers: zturner, jingham.
amccarth added a subscriber: Unknown Object (MLST).
zturner edited edge metadata.Jun 1 2015, 2:01 PM

Do the multithreaded tests actually pass on Windows now after this, or do
they just get farther but fail on something else?

The particular test this addresses now passes. The other one that I'd gotten working earlier (TestNumThreads) continues to pass.

The rest still fail to compile because they depend on pthreads, but I'm hopeful they will work once I convert them to std::threads, which is what I plan to attempt next.

zturner added inline comments.Jun 1 2015, 2:16 PM
test/functionalities/thread/break_after_join/TestBreakAfterJoin.py
81–86

If the STL is creating some magic threads behind the scenes in addition to the ones you requested, then I wonder if their orders will line up correctly. This might still fail if there are actually 7 threads, and the 7th one corresponds to one that actually hit the breakpoint.

Maybe a better check is something like:

threads_stopped = 0
for i in range(0, num_threads):
    thread = process.GetThreadAtIndex(i)
    if (thread.IsStopped())
        threads_stopped = threads_stopped + 1

self.assertEquals(threads_stopped, 6, "Incorrect number of threads stopped!")
amccarth added inline comments.Jun 1 2015, 2:21 PM
test/functionalities/thread/break_after_join/TestBreakAfterJoin.py
81–86

This might still fail if there are actually 7 threads, and the 7th one corresponds to one that actually hit the breakpoint.

Nope, they are all stopped when the breakpoint hits, so the number of stopped threads will be at least 6. In the case of Windows, it's 9, regardless of which one hits.

I could loop through all the threads and assert that they're stopped, but the test for the number of threads must be expressed as >= 6.

Standby for a loop to check that the threads are stopped.

amccarth updated this revision to Diff 26931.Jun 1 2015, 2:31 PM
amccarth edited edge metadata.

Python loop to ensure all the threads are stopped at the breakpoint.

Ok, I get it. looks good

zturner accepted this revision.Oct 15 2015, 1:47 PM
zturner edited edge metadata.
This revision is now accepted and ready to land.Oct 15 2015, 1:47 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL238787.