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>
This commit is contained in:
@@ -22,10 +22,15 @@
|
|||||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
run_under_valgrind = False
|
||||||
|
test_cmd_prefix = ""
|
||||||
|
log_filename_prefix = ""
|
||||||
|
|
||||||
class TestCoreValgrind(unittest.TestCase):
|
|
||||||
|
class TestCore(unittest.TestCase):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self.pyeclib_core_test = "test_pyeclib_c.py"
|
self.pyeclib_core_test = "test_pyeclib_c.py"
|
||||||
@@ -49,23 +54,36 @@ class TestCoreValgrind(unittest.TestCase):
|
|||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@unittest.skipUnless(0 == os.system("which valgrind"), "requires valgrind")
|
def test_core(self):
|
||||||
def test_core_valgrind(self):
|
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
cur_dir = os.getcwd()
|
cur_dir = os.getcwd()
|
||||||
|
print("\n")
|
||||||
for (dir, test) in self.py_test_dirs:
|
for (dir, test) in self.py_test_dirs:
|
||||||
|
sys.stdout.write("Running test %s ... " % test)
|
||||||
|
sys.stdout.flush()
|
||||||
os.chdir(dir)
|
os.chdir(dir)
|
||||||
if os.path.isfile(test):
|
if os.path.isfile(test):
|
||||||
ret = os.system(
|
ret = os.system(
|
||||||
"valgrind --leak-check=full python %s >%s/valgrind.%s.out 2>&1" %
|
"%s python %s >%s/%s.%s.out 2>&1" %
|
||||||
(test, cur_dir, test))
|
(test_cmd_prefix, test, cur_dir,
|
||||||
|
log_filename_prefix, test))
|
||||||
|
|
||||||
self.assertEqual(0, ret)
|
self.assertEqual(0, ret)
|
||||||
os.system("rm -f *.pyc")
|
os.system("rm -f *.pyc")
|
||||||
os.chdir(cur_dir)
|
os.chdir(cur_dir)
|
||||||
|
print('ok')
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False)
|
self.assertTrue(False)
|
||||||
|
print('failed')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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)
|
||||||
|
|||||||
1
test/test_core_valgrind.py
Symbolic link
1
test/test_core_valgrind.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
test_core.py
|
||||||
Reference in New Issue
Block a user