diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-06-25 21:14:08 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-06-25 21:14:08 +0000 |
commit | a765c28db3199f9511e1206d1addc3621d688cff (patch) | |
tree | bbb886478a0e2654c24117fa3e4d089b10fc24bc /lldb/test/example/TestSequenceFunctions.py | |
parent | 07b0a6e4d639f365114cd7d23a193a8450263724 (diff) | |
download | bcm5719-llvm-a765c28db3199f9511e1206d1addc3621d688cff.tar.gz bcm5719-llvm-a765c28db3199f9511e1206d1addc3621d688cff.zip |
A simple testing framework for lldb using python's unit testing framework.
Tests for lldb are written as python scripts which take advantage of the script
bridging provided by LLDB.framework to interact with lldb core.
A specific naming pattern is followed by the .py script to be recognized as
a module which implements a test scenario, namely, Test*.py.
To specify the directories where "Test*.py" python test scripts are located,
you need to pass in a list of directory names. By default, the current
working directory is searched if nothing is specified on the command line.
An example:
[14:10:20] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v example
test_choice (TestSequenceFunctions.TestSequenceFunctions) ... ok
test_sample (TestSequenceFunctions.TestSequenceFunctions) ... ok
test_shuffle (TestSequenceFunctions.TestSequenceFunctions) ... ok
----------------------------------------------------------------------
Ran 3 tests in 0.000s
OK
llvm-svn: 106890
Diffstat (limited to 'lldb/test/example/TestSequenceFunctions.py')
-rw-r--r-- | lldb/test/example/TestSequenceFunctions.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lldb/test/example/TestSequenceFunctions.py b/lldb/test/example/TestSequenceFunctions.py new file mode 100644 index 00000000000..29ebfe6cefe --- /dev/null +++ b/lldb/test/example/TestSequenceFunctions.py @@ -0,0 +1,34 @@ +"""An example unittest copied from python tutorial.""" + +import random +import unittest +import traceback + +class TestSequenceFunctions(unittest.TestCase): + + def setUp(self): + #traceback.print_stack() + self.seq = range(10) + + def tearDown(self): + #traceback.print_stack() + pass + + def test_shuffle(self): + # make sure the shuffled sequence does not lose any elements + random.shuffle(self.seq) + self.seq.sort() + self.assertEqual(self.seq, range(10)) + + def test_choice(self): + element = random.choice(self.seq) + self.assertTrue(element in self.seq) + + def test_sample(self): + self.assertRaises(ValueError, random.sample, self.seq, 20) + for element in random.sample(self.seq, 5): + self.assertTrue(element in self.seq) + + +if __name__ == '__main__': + unittest.main() |