Commit Graph

172 Commits

Author SHA1 Message Date
Johnny Chen 2a80858903 Modify lldbtest.Base.runHooks() to now take the following keyword arguments:
child=None, child_prompt=None, use_cmd_api=False

By default, expect a pexpect spawned child and child prompt to be
supplied (use_cmd_api=False).  If use_cmd_api is true, ignore the child
and child prompt and use self.runCmd() to run the hooks one by one.

Modify existing client to reflect the change.

llvm-svn: 142532
2011-10-19 16:48:07 +00:00
Johnny Chen a737ba55af Extract the run hooks functionality into the base class lldbtest.Base.
llvm-svn: 142469
2011-10-19 01:06:21 +00:00
Johnny Chen ebe51726b8 If we spawn an lldb process for test (via pexpect), do not load the init file unless told otherwise.
Set up self.lldbOption to be "--no-lldbibit" unless env variable NO_LLDBIBIT is defined and equals "NO".
Also add "-nx" to gdb spawned.

llvm-svn: 141384
2011-10-07 19:21:09 +00:00
Johnny Chen 86268e4459 o lldbtest.py:
Add a keyword argument 'endstr' to TestBase.expect() method to assert that the output
will end with 'endstr'.

Add TestBase.switch_to_thread_with_stop_reason(stop_reason) to select the thread with
the stop reason = 'stop_reason' as the current thread.

o TestWatchLocation.py:

Modified to switch to the stopped thread with stop reason = watchpoint and to evaluate
an expression with expected output for stronger assertion.

llvm-svn: 140890
2011-09-30 21:48:35 +00:00
Johnny Chen f68cc12453 Add a simple watchpoint test to exercise watchpoint creation followed by watchpoint hit events.
llvm-svn: 139847
2011-09-15 21:09:59 +00:00
Johnny Chen d890bfc962 Add a new attribute self.lldbHere, representing the fullpath to the 'lldb' executable
built locally from the source tree.  This is distinguished from self.lldbExec, which
can be used by test/benchmarks to measure the performances against other debuggers.

You can use environment variable LLDB_EXEC to specify self.lldbExec to the dotest.py
test driver, otherwise it is going to be populated with self.lldbHere.

Modify the regular tests under test dir, i.e., not test/benchmarks, to use self.lldbHere.
Also modify the benchmarks tests to use self.lldbHere when it needs an 'lldb' executable
with debug info to do the performance measurements.

llvm-svn: 138608
2011-08-26 00:00:01 +00:00
Johnny Chen b7bdd1001e Pretty print the run options for dumpSessionInfo(self) client.
llvm-svn: 138466
2011-08-24 19:48:51 +00:00
Johnny Chen b5825b82ad Minor change for the @expectedFailureClang logic. For the non-clang test failure, re-raise
the exception to get more stack trace information.

llvm-svn: 138021
2011-08-19 01:17:09 +00:00
Johnny Chen 31963cea0a Add a decorator for marking clang only expectedFailure. Use it for the test_step_over_3_times_with_dsym/dwarf()
test cases in TestThreadAPI.py by decorating it with @expectedFailureClang.

Example:

    @expectedFailureClang
    @python_api_test
    def test_step_over_3_times_with_dwarf(self):
        """Test Python SBThread.StepOver() API."""
        # We build a different executable than the default buildDwarf() does.
        d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name}
        self.buildDwarf(dictionary=d)
        self.setTearDownCleanup(dictionary=d)
        self.step_over_3_times(self.exe_name)

llvm-svn: 138019
2011-08-19 00:54:27 +00:00
Johnny Chen 0241f1441f Add comment about recent change.
llvm-svn: 137776
2011-08-16 22:06:17 +00:00
Johnny Chen bfcf37f18b Fix the test suite error of:
...

  File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 243, in __init__
    self.session = test.session if test else None
AttributeError: 'StdCXXDisassembleTestCase' object has no attribute 'session'

llvm-svn: 137724
2011-08-16 17:06:45 +00:00
Johnny Chen f79b076783 Forgot to initialize the self.__skipped__ attribute lldbtest.Base.
llvm-svn: 137696
2011-08-16 00:48:58 +00:00
Johnny Chen c5cc625c79 Test driver should also report skipped tests because there were cases when tests were skipped
due to incorrect skip-logic.

llvm-svn: 137678
2011-08-15 23:09:08 +00:00
Johnny Chen 9f4f5d94cd Add TestInferiorChanged.py to test that lldb reloads the inferior after it was changed during the debug session.
First, main.c causes a crash, the inferior then gets re-built with main2.c which is not crashing.

Add Base.cleanup(self, dictionary=None) for platform specfic way to do cleanup after build.
This plugin method is used by the above test case to cleanup the main.c build before rebuild for main2.c.

llvm-svn: 137500
2011-08-12 20:19:22 +00:00
Johnny Chen 8082a00dcb When a benchmarks test fails, the re-run command should include the '+b' option instead of the '-t' option.
llvm-svn: 137285
2011-08-11 00:16:28 +00:00
Johnny Chen 36c5eb1327 o modify-python-lldb.py:
Add the rich comparison methods (__eq__, __ne__) to SBType, too.

o lldbtest.py:

  Add debug utility method TestBase.DebugSBType().

o test/python_api/type:

  Add tests for exercising SBType/SBTypeList API, including the SBTarget.FindTypes(type_name)
  API which returns a SBTypeList matching the type_name.

llvm-svn: 136975
2011-08-05 20:17:27 +00:00
Johnny Chen aaa82ff9ad Add the real benchmarks comparing lldb against gdb for repeated expression evaluations.
Modify lldbbench.py so that lldbtest.line_number() utility function is available to
BenchBase client as just line_number(), and modify lldbtest.py so that self.lldbExec
(the full path for the 'lldb' executable) is available to BenchBase client as well.

An example run of the test case on my MacBook Pro running Lion:

1: test_compare_lldb_to_gdb (TestRepeatedExprs.RepeatedExprsCase)
   Test repeated expressions with lldb vs. gdb. ... 
lldb_avg: 0.204339
gdb_avg: 0.205721
lldb_avg/gdb_avg: 0.993284
ok

llvm-svn: 136740
2011-08-02 22:54:37 +00:00
Johnny Chen 985e740cd9 Add an abstract base class called BenchBase to be inherited by benchmark tests.
Modify the example TestRepeatedExprs.py to use BenchBase, instead.

llvm-svn: 136649
2011-08-01 21:13:26 +00:00
Johnny Chen fb4264c501 More refactorings to migrate logic from TestBase to its parent class.
llvm-svn: 136641
2011-08-01 19:50:58 +00:00
Johnny Chen a74bb0ae6f Start refactoring lldbtest.TestBase so that it inherits from a newly created lldbtest.Base class,
while its API clients remain unchanged.  The new lldbtest.Base class is to capture common behaviors
when working with the test driver to accomplish things.  The clients of lldbtest.Base can be
lldb command line and api tests as well as other generic tests like a benchmark test.

llvm-svn: 136636
2011-08-01 18:46:13 +00:00
Johnny Chen 5ccbccfce0 Add a @benchmarks_test decorator for test method we want to categorize as benchmarks test.
The test driver now takes an option "+b" which enables to run just the benchmarks tests.
By default, tests decorated with the @benchmarks_test decorator do not get run.

Add an example benchmarks test directory which contains nothing for the time being,
just to demonstrate the @benchmarks_test concept.

For example,

$ ./dotest.py -v benchmarks

...

----------------------------------------------------------------------
Collected 2 tests

1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with gdb. ... skipped 'benchmarks tests'
2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with lldb. ... skipped 'benchmarks tests'

----------------------------------------------------------------------
Ran 2 tests in 0.047s

OK (skipped=2)
$ ./dotest.py -v +b benchmarks

...

----------------------------------------------------------------------
Collected 2 tests

1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with gdb. ... running test_with_gdb
benchmarks result for test_with_gdb
ok
2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with lldb. ... running test_with_lldb
benchmarks result for test_with_lldb
ok

----------------------------------------------------------------------
Ran 2 tests in 0.270s

OK

Also mark some Python API tests which are missing the @python_api_test decorator.

llvm-svn: 136553
2011-07-30 01:39:58 +00:00
Johnny Chen 5819ab49fd Add TestValueAPI.py to exercise the newly added/modified SBValue APIs:
o GetChildAtIndex, and
o GetValueForExpressionPath

llvm-svn: 135315
2011-07-15 22:28:10 +00:00
Johnny Chen 56b92a7b04 Update the test scenario for find_global_variables() to now start the inferior process
before issuing API calls to find the global variable and to get its value.

rdar://problem/9700873 has been updated to reflect the latest status.  The dwarf case
now does not seg fault if the inferior is not started; instead, for dwarf case, the
value retrieved from the global variable is None.

llvm-svn: 134909
2011-07-11 19:15:11 +00:00
Johnny Chen 89109ed13c Add TestPrintObj.py to go with lang/objc/print-objc, which:
Test "print object" where another thread blocks the print object from making progress.

Set a breakpoint on the line in my_pthread_routine.  Then switch threads
to the main thread, and do print the lock_me object.  Since that will
try to get the lock already gotten by my_pthread_routime thread, it will
have to switch to running all threads, and that should then succeed.

llvm-svn: 133933
2011-06-27 20:05:23 +00:00
Johnny Chen b7373c92e6 o lldbtest.py:
Assign the test method name to self.testMethodName.  This can be useful for the
test directory (see test/types for a good example) which houses a bunch of executables
compiled from different source files.  The default build action is to create a.out as
the binary executable, which can confuse the module cacheing mechanism and result in
the debugger getting a stale image as the target to be debugged, and chaos ensues.

o AbstractBase.py, TestThreadAPI.py:

Use self.testMethodName to our advantage.

o TestLoadUnload.py:

Add expected failure marker to test case test_modules_search_paths().

llvm-svn: 133768
2011-06-23 22:11:20 +00:00
Johnny Chen ed492022f4 For now, insert some delays between succesive test cases in the test/types directory
if not already specified by the test driver (via ./dotest -w).  Remove the AbstractBase.setUp()
method definition when/if we find out the cause of the failures if no delays are inserted
between these test cases.

llvm-svn: 133495
2011-06-21 00:53:00 +00:00
Peter Collingbourne 19f48d51f6 Add a builder module for Linux (plus some refactoring)
llvm-svn: 133457
2011-06-20 19:06:20 +00:00
Johnny Chen 5b67ca8cc4 Simplify the base test class. Remove keyword argument setCookie from TestBase.runCmd() and
remove the self.runStarted attribute since the automatic shutdown of processes associated
with the targets are now performed automatically.

llvm-svn: 133092
2011-06-15 21:38:39 +00:00
Johnny Chen 3794ad95a7 Add an API to SBDebugger class:
bool SBDebugger::DeleteTarget(lldb::SBTarget &target);

which is used in the test tearDown() phase to cleanup the debugger's target list
so that it won't grow larger and larger as test cases are executed.  This is also
a good opportunity to get rid of the arcane requirement that test cases exercising
the Python API must assign the process object to self.process so that it gets
shutdown gracefully.  Instead, the shutdown of the process associated with each
target is now being now automatically.

Also get rid of an API from SBTarget class:

    SBTarget::DeleteTargetFromList(lldb_private::TargetList *list);

llvm-svn: 133091
2011-06-15 21:24:24 +00:00
Johnny Chen 143b39fba4 Removed unneeded method breakAfterLaunch() from the TestBase class to simplify our base class.
It was introduced to work around some debugger infrastructure bug which has long since been fixed.

llvm-svn: 132951
2011-06-13 23:19:35 +00:00
Johnny Chen f5fe34ff9c Remove extra whitespace.
llvm-svn: 132692
2011-06-06 21:36:56 +00:00
Johnny Chen 4533dada39 Fix out-dated module docstring for lldbtest.py. Also wrap some lldb attribute references
inside a try-except block in case the test is not invoked through the dotest.py test driver.

llvm-svn: 132372
2011-05-31 23:21:42 +00:00
Johnny Chen aacf92ebb4 Move some comments to the docstrings.
llvm-svn: 132367
2011-05-31 22:16:51 +00:00
Johnny Chen 61c79c0ba4 Fix some comments.
llvm-svn: 132232
2011-05-27 23:42:45 +00:00
Johnny Chen f359cf2c84 Add comment headers describing some method groups of our TestBase class.
Remove an unnecessary __import__() function call.

llvm-svn: 132231
2011-05-27 23:36:52 +00:00
Johnny Chen 3cd1e55103 Convert these two modules to use the compact truth value testing as well.
llvm-svn: 132072
2011-05-25 19:06:18 +00:00
Johnny Chen 7209d84f1c Add an API test script file for SBCommandInterpreter.
llvm-svn: 131035
2011-05-06 23:26:12 +00:00
Johnny Chen 44932b6805 For a test with unexpected success status, we also dump its session info into a unique file.
llvm-svn: 131011
2011-05-06 20:30:22 +00:00
Johnny Chen 3f620ed8ab Comment.
llvm-svn: 130965
2011-05-05 23:28:17 +00:00
Johnny Chen 87e8dd1077 Add comment for self.child_in_script_interpreter.
llvm-svn: 130963
2011-05-05 23:18:53 +00:00
Johnny Chen b79646cb2e Use standard lldb enum -- lldb.eStopReasonBreakpoint.
llvm-svn: 130960
2011-05-05 22:17:31 +00:00
Johnny Chen 0bade020a0 Add a test script for verifying that the convenience variables:
o lldb.debugger
o lldb.target
o lldb.process
o lldb.thread
o lldb.frame

"just works" when we stop at a breakpoint.

llvm-svn: 130904
2011-05-05 00:36:31 +00:00
Johnny Chen 0934268ee1 Use a more gentle way of shutting down the child process spawned during the test execution using pexpect.
Change some child.expect() to child.expect_exact() as they try to match the string, not a regular expression.

llvm-svn: 130797
2011-05-03 22:14:19 +00:00
Johnny Chen b2a27481c1 A more robust pexpect-based test case for testing against the firing of stop hooks.
Change one test sequence to detect the '** End Stop Hooks **' marker emitted by the
stop hooks mechanism and check for whether the 'expr ptr' stop-hook has been run.

Also, change the TestBase.tearDown() to wait for 2 seocnds before forcefully kill
the pexpect-spawned child lldb process.

llvm-svn: 130767
2011-05-03 17:38:06 +00:00
Johnny Chen de90f1dd93 Change the rest of lldbutil.py's function names to all lower case formats to be consistent.
And modify the test cases accordingly.

llvm-svn: 130314
2011-04-27 17:43:07 +00:00
Johnny Chen 9ee96e7b40 Add a HideStdout() method to our TestBase class and call it from TestAbbreviations.py
and TestAliases.py.  Pass the keyword argument 'check=False' to:

    self.runCmd("script my.date()", check=False)

since we want to restore sys.stdout no matter what the outcome of the runCmd is.

llvm-svn: 129949
2011-04-21 22:50:23 +00:00
Johnny Chen ff4a08372e Modify docstring.
llvm-svn: 129786
2011-04-19 19:12:24 +00:00
Johnny Chen f1251cc820 Add a TraceOn(self) method to the base test class, which returns True if we are
currently in trace mode (-t to dotest.py), i.e., tracing the lldb command execution.
Change TestInferiorCrashing.inferior_crashing_python(self) to check this flag in
order to print the stack trace of the inferior thread.

llvm-svn: 129785
2011-04-19 19:04:38 +00:00
Johnny Chen 1ee61a7f3b Add a test script for exercising the "taregt create", "target list", and "target select" commands.
llvm-svn: 129717
2011-04-18 21:08:05 +00:00
Johnny Chen 1691a1676c Forgot to check in this change with http://llvm.org/viewvc/llvm-project?view=rev&revision=129542.
llvm-svn: 129574
2011-04-15 16:44:48 +00:00