[all-commits] [llvm/llvm-project] 54c268: [lldb] Introduce createTestTarget for creating a v...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Mon May 24 07:19:36 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 54c2687292da54a2d7964a47b0e334155385f084
      https://github.com/llvm/llvm-project/commit/54c2687292da54a2d7964a47b0e334155385f084
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2021-05-24 (Mon, 24 May 2021)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/lldbtest.py
    M lldb/test/API/android/platform/TestDefaultCacheLineSize.py
    M lldb/test/API/api/listeners/TestListener.py
    M lldb/test/API/assert_messages_test/TestAssertMessages.py
    M lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
    M lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py
    M lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
    M lldb/test/API/commands/expression/completion/TestExprCompletion.py
    M lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
    M lldb/test/API/commands/expression/expr-in-syscall/TestExpressionInSyscall.py
    M lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py
    M lldb/test/API/commands/expression/test/TestExprs.py
    M lldb/test/API/commands/frame/language/TestGuessLanguage.py
    M lldb/test/API/commands/frame/var/TestFrameVar.py
    M lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
    M lldb/test/API/commands/process/launch/TestProcessLaunch.py
    M lldb/test/API/commands/register/register/register_command/TestRegisters.py
    M lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
    M lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py
    M lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
    M lldb/test/API/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
    M lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
    M lldb/test/API/functionalities/asan/TestMemoryHistory.py
    M lldb/test/API/functionalities/asan/TestReportData.py
    M lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
    M lldb/test/API/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_by_file_colon_line/TestBreakpointByFileColonLine.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
    M lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
    M lldb/test/API/sample_test/TestSampleTest.py
    M lldb/test/API/sample_test/main.c

  Log Message:
  -----------
  [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




More information about the All-commits mailing list