]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / expression_command / call-function / TestCallUserDefinedFunction.py
1 """
2 Test calling user defined functions using expression evaluation.
3
4 Note:
5   LLDBs current first choice of evaluating functions is using the IR interpreter,
6   which is only supported on Hexagon. Otherwise JIT is used for the evaluation.
7
8 """
9
10 from __future__ import print_function
11
12
13
14 import lldb
15 from lldbsuite.test.decorators import *
16 from lldbsuite.test.lldbtest import *
17 from lldbsuite.test import lldbutil
18
19 class ExprCommandCallUserDefinedFunction(TestBase):
20
21     mydir = TestBase.compute_mydir(__file__)
22
23     def setUp(self):
24         # Call super's setUp().
25         TestBase.setUp(self)
26         # Find the line number to break for main.c.
27         self.line = line_number('main.cpp',
28                                 '// Please test these expressions while stopped at this line:')
29     @expectedFlakeyDsym("llvm.org/pr20274")
30     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
31     def test(self):
32         """Test return values of user defined function calls."""
33         self.build()
34
35         # Set breakpoint in main and run exe
36         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
37         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
38
39         self.runCmd("run", RUN_SUCCEEDED)
40
41         # Test recursive function call.
42         self.expect("expr fib(5)", substrs = ['$0 = 5'])
43
44         # Test function with more than one paramter
45         self.expect("expr add(4,8)", substrs = ['$1 = 12'])
46
47         # Test nesting function calls in function paramters
48         self.expect("expr add(add(5,2),add(3,4))", substrs = ['$2 = 14'])
49         self.expect("expr add(add(5,2),fib(5))", substrs = ['$3 = 12'])
50
51         # Test function with pointer paramter
52         self.expect("exp stringCompare((const char*) \"Hello world\")", substrs = ['$4 = true'])
53         self.expect("exp stringCompare((const char*) \"Hellworld\")", substrs = ['$5 = false'])