Easy way to change the standard output and error output
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user