From 5eb7336261a50d305471b91148370573c00becaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 9 Nov 2016 16:16:43 +0100 Subject: [PATCH] Easy way to change the standard output and error output --- DRAMSys/tests/unit/unit_test.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/DRAMSys/tests/unit/unit_test.py b/DRAMSys/tests/unit/unit_test.py index b2d64341..c0b485ba 100644 --- a/DRAMSys/tests/unit/unit_test.py +++ b/DRAMSys/tests/unit/unit_test.py @@ -43,6 +43,11 @@ from mem_util import * devnull = None +# If you want to change the standard output and/or standard error output do +# that in the Top-level script environment (the '__main__' at the very bottom +# of this file. +out = None +errout = None rootdir = '../../..' tempfile.tempdir = os.getcwd() + '/' + rootdir @@ -59,9 +64,9 @@ def build_project(): os.makedirs(builddir) os.chdir(builddir) qmakeprojfile = '../DRAMSys/dram.vp.system.pro' - subprocess.call(['qmake', qmakeprojfile], stdout=devnull, stderr=devnull) + subprocess.call(['qmake', qmakeprojfile], stdout=out, stderr=errout) makejobs = '-j' + str(multiprocessing.cpu_count()) - ret = subprocess.call(['make', makejobs], stdout=devnull, stderr=devnull) + ret = subprocess.call(['make', makejobs], stdout=out, stderr=errout) return ret @@ -81,7 +86,7 @@ class TestOutput(unittest.TestCase): def test_run_without_arguments(self): """ running dramSys without arguments returns 0 """ os.chdir(simdir) - self.assertEqual(subprocess.call(['./dramSys'], stdout=devnull), 0) + self.assertEqual(subprocess.call(['./dramSys'], stdout=out), 0) def tearDown(self): shutil.rmtree(builddir) @@ -100,4 +105,8 @@ class TestDummy(unittest.TestCase): if __name__ == '__main__': with open(os.devnull, 'wb') as devnull: + out = devnull + errout = devnull + # out = sys.stdout + # errout = sys.stderr unittest.main()