Improve gdb plugin unit tests
ClosedPublic

Authored by qi437103 on Jun 23 2016, 7:46 PM.

Details

Summary

This is a side effect of my work on lldb plugin unit tests, in which I tried to fix the somewhat unreliable test results.

  • Move unit test debugees to common folder, make gdb uses common unit test helpers
  • Make gdb plugin unit tests more reliable. waitForState now guarantees the session state after returning is exactly the requested one (otherwise fails the test).

The main problem is that DebugSession could end and get deleted when running event loop (i.e. in QTest::qWait).
And this fix adds proper checks to it. This by itself doesn't fix any tests, but it helps when some tests
did goes wrong. Without this fix, they could crash the whole test process due to accessing to deleted object.

Test Plan

gdb plugin unit tests (and actually some lldb plugin unit tests, which is only on local yet)

Diff Detail

Repository
R32 KDevelop
Branch
common-unittest
Lint
No Linters Available
Unit
No Unit Test Coverage
qi437103 updated this revision to Diff 4693.Jun 23 2016, 7:46 PM
qi437103 retitled this revision from to Improve gdb plugin unit tests.
qi437103 updated this object.
qi437103 edited the test plan for this revision. (Show Details)
qi437103 added a reviewer: apol.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJun 23 2016, 7:46 PM
apol added inline comments.Jun 24 2016, 7:13 PM
debuggers/common/unittest/unittest.cpp
35

That's plenty of specific code without little reason. Try to keep unit tests autocontained and leverage QtTest

kfunk requested changes to this revision.Jun 26 2016, 9:10 PM
kfunk added a reviewer: kfunk.
kfunk added a subscriber: kfunk.

See Aleix' comments

This revision now requires changes to proceed.Jun 26 2016, 9:10 PM
qi437103 added inline comments.Jun 28 2016, 1:14 AM
debuggers/common/unittest/unittest.cpp
35

Could you elaborate more on this? Did you mean findExecutable and findSourceFile (which might be possible to be replaced by QFINDTESTDATA), or the whole attempt moving debugees to common?

AFAIK, other functions (checking attach, comparing model data and session state waiting) are good candidates to be shared between lldb and gdb plugin.

apol edited edge metadata.Jul 1 2016, 11:09 AM

It's great to share MI parsing code, it's fine to share some dummy structures, but we should keep the code separate between both plugins.

For example it's fine to have the attach process code duplicated, because they will have eventually different features, especially considering the different platforms.

The actual work must be getting the features to work, not to move code around.

qi437103 updated this revision to Diff 5047.Jul 9 2016, 6:41 PM
qi437103 edited edge metadata.

Second attempt
No more code sharing between lldb and gdb unittests. Just the reliability improvement for gdb unittest.

qi437103 updated this revision to Diff 5067.Jul 10 2016, 5:44 PM
qi437103 edited edge metadata.

Rebase on latest master

Fix gdb unit test COMPARE won't stop the test if failed.

apol accepted this revision.Jul 11 2016, 11:00 AM
apol edited edge metadata.
kfunk accepted this revision.Jul 15 2016, 9:26 AM
kfunk edited edge metadata.

This looks good. And since the other patch got accepted as well: +1

This revision is now accepted and ready to land.Jul 15 2016, 9:26 AM
This revision was automatically updated to reflect the committed changes.