diff options
author | Tushar Gohad <tushar.gohad@intel.com> | 2014-06-23 16:44:48 -0700 |
---|---|---|
committer | Tushar Gohad <tushar.gohad@intel.com> | 2014-06-23 16:45:09 -0700 |
commit | 5b23c17592a6530c0bf8f30a3bc12c5557f37c34 (patch) | |
tree | 68e0797521e217360d71208a866b21ca92fbdc30 | |
parent | dc2bf58d2148d451e003ce132691880070352ba1 (diff) | |
download | pyeclib-5b23c17592a6530c0bf8f30a3bc12c5557f37c34.tar.gz |
test_core: Make valgrind run conditional
... Also create symlink test_core_valgrind.py to
test_core.py - if script filename has '_valgrind' in
it, we run the test with valgrind.
Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
-rw-r--r-- | test/test_core.py | 32 | ||||
l--------- | test/test_core_valgrind.py | 1 |
2 files changed, 26 insertions, 7 deletions
diff --git a/test/test_core.py b/test/test_core.py index b56baa5..a49df3f 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -22,10 +22,15 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os +import sys import unittest +run_under_valgrind = False +test_cmd_prefix = "" +log_filename_prefix = "" -class TestCoreValgrind(unittest.TestCase): + +class TestCore(unittest.TestCase): def __init__(self, *args): self.pyeclib_core_test = "test_pyeclib_c.py" @@ -49,23 +54,36 @@ class TestCoreValgrind(unittest.TestCase): def tearDown(self): pass - - @unittest.skipUnless(0 == os.system("which valgrind"), "requires valgrind") - def test_core_valgrind(self): + + def test_core(self): self.assertTrue(True) cur_dir = os.getcwd() + print("\n") for (dir, test) in self.py_test_dirs: + sys.stdout.write("Running test %s ... " % test) + sys.stdout.flush() os.chdir(dir) if os.path.isfile(test): ret = os.system( - "valgrind --leak-check=full python %s >%s/valgrind.%s.out 2>&1" % - (test, cur_dir, test)) + "%s python %s >%s/%s.%s.out 2>&1" % + (test_cmd_prefix, test, cur_dir, + log_filename_prefix, test)) self.assertEqual(0, ret) os.system("rm -f *.pyc") os.chdir(cur_dir) + print('ok') else: self.assertTrue(False) + print('failed') + if __name__ == "__main__": - unittest.main() + if '_valgrind' in sys.argv[0]: + if (0 != os.system("which valgrind")): + print("--valgrind option requires valgrind program installed") + sys.exit(-1) + run_under_valgrind = True + test_cmd_prefix = "valgrind --leak-check=full " + log_filename_prefix = "valgrind" + unittest.main(verbosity=2) diff --git a/test/test_core_valgrind.py b/test/test_core_valgrind.py new file mode 120000 index 0000000..329fee4 --- /dev/null +++ b/test/test_core_valgrind.py @@ -0,0 +1 @@ +test_core.py
\ No newline at end of file |