forked from OSchip/llvm-project
Moved the test code for Python commands out of the test case for aliases, into its own dedicated test case
llvm-svn: 138444
This commit is contained in:
parent
523004145e
commit
cb2921dbd3
|
@ -130,44 +130,6 @@ class AliasTestCase(TestBase):
|
|||
substrs = [ "use of undeclared identifier 'f'",
|
||||
"1 errors parsing expression" ])
|
||||
|
||||
self.runCmd("command source py_import")
|
||||
|
||||
self.expect('welcome Enrico',
|
||||
substrs = ['Hello Enrico, welcome to LLDB']);
|
||||
|
||||
self.expect("help welcome",
|
||||
substrs = ['Just a docstring for welcome_impl',
|
||||
'A command that says hello to LLDB users'])
|
||||
|
||||
self.runCmd("command script delete welcome");
|
||||
|
||||
self.expect('welcome Enrico', matching=False, error=True,
|
||||
substrs = ['Hello Enrico, welcome to LLDB']);
|
||||
|
||||
self.expect('targetname',
|
||||
substrs = ['a.out'])
|
||||
|
||||
self.expect('targetname fail', error=True,
|
||||
substrs = ['a test for error in command'])
|
||||
|
||||
self.expect('command script list',
|
||||
substrs = ['targetname',
|
||||
'Run Python function welcome.target_name_impl'])
|
||||
|
||||
self.expect("help targetname",
|
||||
substrs = ['Run Python function welcome.target_name_imp',
|
||||
'This command takes \'raw\' input',
|
||||
'quote stuff'])
|
||||
|
||||
self.expect("longwait",
|
||||
substrs = ['Done; if you saw the delays I am doing OK'])
|
||||
|
||||
self.runCmd("command script clear")
|
||||
|
||||
self.expect('command script list', matching=False,
|
||||
substrs = ['targetname',
|
||||
'longwait'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
LEVEL = ../../make
|
||||
|
||||
CXX_SOURCES := main.cpp
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -0,0 +1,71 @@
|
|||
"""
|
||||
Test lldb Python commands.
|
||||
"""
|
||||
|
||||
import os, time
|
||||
import unittest2
|
||||
import lldb
|
||||
from lldbtest import *
|
||||
|
||||
class CmdPythonTestCase(TestBase):
|
||||
|
||||
mydir = os.path.join("functionalities", "command_python")
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
def test_with_dsym (self):
|
||||
self.buildDsym ()
|
||||
self.pycmd_tests ()
|
||||
|
||||
def test_with_dwarf (self):
|
||||
self.buildDwarf ()
|
||||
self.pycmd_tests ()
|
||||
|
||||
def pycmd_tests (self):
|
||||
exe = os.path.join (os.getcwd(), "a.out")
|
||||
self.expect("file " + exe,
|
||||
patterns = [ "Current executable set to .*a.out" ])
|
||||
|
||||
self.runCmd("command source py_import")
|
||||
|
||||
self.expect('welcome Enrico',
|
||||
substrs = ['Hello Enrico, welcome to LLDB']);
|
||||
|
||||
self.expect("help welcome",
|
||||
substrs = ['Just a docstring for welcome_impl',
|
||||
'A command that says hello to LLDB users'])
|
||||
|
||||
self.runCmd("command script delete welcome");
|
||||
|
||||
self.expect('welcome Enrico', matching=False, error=True,
|
||||
substrs = ['Hello Enrico, welcome to LLDB']);
|
||||
|
||||
self.expect('targetname',
|
||||
substrs = ['a.out'])
|
||||
|
||||
self.expect('targetname fail', error=True,
|
||||
substrs = ['a test for error in command'])
|
||||
|
||||
self.expect('command script list',
|
||||
substrs = ['targetname',
|
||||
'Run Python function welcome.target_name_impl'])
|
||||
|
||||
self.expect("help targetname",
|
||||
substrs = ['Run Python function welcome.target_name_imp',
|
||||
'This command takes \'raw\' input',
|
||||
'quote stuff'])
|
||||
|
||||
self.expect("longwait",
|
||||
substrs = ['Done; if you saw the delays I am doing OK'])
|
||||
|
||||
self.runCmd("command script clear")
|
||||
|
||||
self.expect('command script list', matching=False,
|
||||
substrs = ['targetname',
|
||||
'longwait'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
//===-- main.cpp ------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
product (int x, int y)
|
||||
{
|
||||
int result = x * y;
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
sum (int a, int b)
|
||||
{
|
||||
int result = a + b;
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
strange_max (int m, int n)
|
||||
{
|
||||
if (m > n)
|
||||
return m;
|
||||
else if (n > m)
|
||||
return n;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
foo (int i, int j)
|
||||
{
|
||||
if (strange_max (i, j) == i)
|
||||
return product (i, j);
|
||||
else if (strange_max (i, j) == j)
|
||||
return sum (i, j);
|
||||
else
|
||||
return product (sum (i, i), sum (j, j));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char const *argv[])
|
||||
{
|
||||
|
||||
int array[3];
|
||||
|
||||
array[0] = foo (1238, 78392);
|
||||
array[1] = foo (379265, 23674);
|
||||
array[2] = foo (872934, 234);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
script import sys, os
|
||||
script sys.path.append(os.path.join(os.getcwd(), os.pardir))
|
||||
script import welcome
|
||||
command script add welcome --function welcome.welcome_impl
|
||||
command script add targetname --function welcome.target_name_impl
|
||||
command script add longwait --function welcome.print_wait_impl
|
Loading…
Reference in New Issue