How/where to add test cases in LLDB.

Hello Everyone,

I’ve wrote a patch for extending support for new forms[DWARFv5] in macro section. Planning to file a review soon.

But I’m stuck with writing test case for this. My feature works well when using LLDB in interactively, but I need to write a test case to accompany my patch.

To put things in perspective:
here’ s how I tested it interactively:

$lldb a.out
$display MACRO1 – macro defined in source/a.out
$ b main
$ run
LLDB output

  • Hook 1 (expr – MACRO1)
    (int) $0 = 4

Process 18381 stopped

  • thread #1, name = ‘a.out’, stop reason = breakpoint 1.1

Need to write/add test case for this so that it will be run by “make check-lldb”, any ideas/pointers how to proceed forward from here.

Thanks in anticipation!
Sourabh Singh Tomar

Hey Sourabh,

You'll want to take a look at the existing tests in `test/Shell`.
These tests run one or more shell commands and uses FileCheck to
verify that the output match what you expect. These tests use lldb's
batch mode, where lldb commands are executed one after another, rather
than interactively.

A good example is test/Shell/Commands/command-backtrace.test

More info about lit and FileCheck:
https://llvm.org/docs/TestingGuide.html
https://llvm.org/docs/CommandGuide/FileCheck.html

Cheers,
Jonas

Please note that when you are testing for a DWARF 5 feature specifically, you should think about using either Assembler or yaml2obj as input to lock down the binary encoding. If you do this, it would be best to not require a living process in your test, so the test can run even on platforms that cannot run that code. In these cases lldb-test is often useful.

Alternatively/additionally, you can write an end-to-end test that compiles from source; these are the python-based tests found in packages/.

-- adrian