llvm-project/lldb/test/API/commands
Raphael Isemann 54c2687292 [lldb] Introduce createTestTarget for creating a valid target in API tests
At the moment nearly every test calls something similar to
`self.dbg.CreateTarget(self.getBuildArtifact("a.out"))` and them sometimes
checks if the created target is actually valid with something like
`self.assertTrue(target.IsValid(), "some useless text")`.

Beside being really verbose the error messages generated by this pattern are
always just indicating that the target failed to be created but now why.

This patch introduces a helper function `createTestTarget` to our Test class
that creates the target with the much more verbose `CreateTarget` overload that
gives us back an SBError (with a fancy error). If the target couldn't be created
the function prints out the SBError that LLDB returned and asserts for us. It
also defaults to the "a.out" build artifact path that nearly all tests are using
to avoid to hardcode "a.out" in every test.

I converted a bunch of tests to the new function but I'll do the rest of the
test suite as follow ups.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D102771
2021-05-24 16:18:44 +02:00
..
add-dsym/uuid [lldb] Remove license headers from all test source files 2020-02-20 08:32:01 +01:00
apropos [lldb] Remove license headers from all test source files 2020-02-20 08:32:01 +01:00
breakpoint [lldb] Warn the user about starting the --func-regex parameter with an asterisk 2020-05-06 12:37:52 +02:00
command [lldb] [test] Rename '.categories' to 'categories' 2020-11-10 12:02:38 +01:00
disassemble/basic [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
expression [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
frame [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
gui [lldb/tests] Un-skip TestGuiBasicDebug.py on Arm and AArch64 2021-02-08 15:09:09 +03:00
help [lldb] Fix crash in "help memory read" 2021-01-19 09:54:17 +00:00
log [llvm] [Support] Fix segv if argv0 is null in getMainExecutable() 2020-11-09 11:35:11 +01:00
platform [lldb] Move PlatformPOSIX::ConnectToWaitingProcesses to RemoteAwarePlatform 2021-03-14 22:43:52 +01:00
process [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
quit
register/register [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
reproducer/invalid-args
session [lldb/interpreter] Move the history subcommand to session (NFCI) 2020-07-23 13:05:45 +02:00
settings [lldb/Interpreter] Add `interpreter.repeat-previous-command` setting 2021-03-05 19:33:32 +01:00
source/info
statistics/basic [lldb] Mark expressions that couldn't be parsed or executed as failed expressions 2020-03-23 15:28:17 +01:00
target [lldb] Un-XFAIL TestAutoInstallMainExecutable on Windows 2021-04-01 08:46:23 -07:00
thread/select [lldb] Replace StringConvert with llvm::to_integer when parsing integer values in CommandObjects 2020-07-01 17:19:31 +02:00
trace [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00
version
watchpoints [lldb] Introduce createTestTarget for creating a valid target in API tests 2021-05-24 16:18:44 +02:00