1
# Copyright (c) 2013, Kevin Greenan (kmgreen2@gmail.com)
4
# Redistribution and use in source and binary forms, with or without
5
# modification, are permitted provided that the following conditions are met:
7
# Redistributions of source code must retain the above copyright notice, this
8
# list of conditions and the following disclaimer.
10
# Redistributions in binary form must reproduce the above copyright notice,
11
# this list of conditions and the following disclaimer in the documentation
12
# and/or other materials provided with the distribution. THIS SOFTWARE IS
13
# PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
14
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16
# NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
17
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
run_under_valgrind = False
30
log_filename_prefix = ""
33
class TestCore(unittest.TestCase):
35
def __init__(self, *args):
36
self.pyeclib_core_test = "test_pyeclib_c.py"
37
self.pyeclib_iface_test = "test_pyeclib_api.py"
39
unittest.TestCase.__init__(self, *args)
42
# Determine which directory we're in
43
dirs = os.getcwd().split('/')
44
if dirs[-1] == 'test':
45
self.pyeclib_test_dir = "."
47
self.pyeclib_test_dir = "./test"
49
# Create the array of tests to run
51
(self.pyeclib_test_dir, self.pyeclib_core_test),
52
(self.pyeclib_test_dir, self.pyeclib_iface_test)
62
for (dir, test) in self.py_test_dirs:
63
sys.stdout.write("Running test %s ... " % test)
66
if os.path.isfile(test):
68
"%s python %s >%s/%s.%s.out 2>&1" %
69
(test_cmd_prefix, test, cur_dir,
70
log_filename_prefix, test))
72
self.assertEqual(0, ret)
73
os.system("rm -f *.pyc")
77
self.assertTrue(False)
81
# Invoke this script as "python test_core_valgrind.py"
82
# for the "valgrind" variant
83
# (test_core_valgrind.py is a symlink to test_core.py)
84
if __name__ == "__main__":
85
if '_valgrind' in sys.argv[0]:
86
if (0 != os.system("which valgrind")):
87
print("You don't appear to have 'valgrind' installed")
89
run_under_valgrind = True
90
test_cmd_prefix = "valgrind --leak-check=full "
91
log_filename_prefix = "valgrind"
92
if sys.version_info<(2,7,0):
95
unittest.main(verbosity=2)