summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorTom Rondeau2010-10-06 21:15:54 -0400
committerTom Rondeau2010-10-06 21:15:54 -0400
commitd74b45e2b4b5ad5ed772fd452541c2ad7429c0db (patch)
treee90a731ad1037d225695c04de57af58067ad05ed /gnuradio-core/src
parent3ac56587df80ee257b36a7c088d0ede8d1c7a18c (diff)
downloadgnuradio-d74b45e2b4b5ad5ed772fd452541c2ad7429c0db.tar.gz
gnuradio-d74b45e2b4b5ad5ed772fd452541c2ad7429c0db.tar.bz2
gnuradio-d74b45e2b4b5ad5ed772fd452541c2ad7429c0db.zip
Checks to make sure XML path is writable before making the XML runner. Ignores it if directory is now writable.
Diffstat (limited to 'gnuradio-core/src')
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr_unittest.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr_unittest.py b/gnuradio-core/src/python/gnuradio/gr_unittest.py
index 8ecd83d54..50d484a76 100755
--- a/gnuradio-core/src/python/gnuradio/gr_unittest.py
+++ b/gnuradio-core/src/python/gnuradio/gr_unittest.py
@@ -117,23 +117,36 @@ def run(PUT, filename=None):
# Run this is given a file name
if(filename is not None):
- path = os.getenv("HOME") + "/.gnuradio/unittests/python"
+ homepath = os.getenv("HOME")
+ basepath = homepath + "/.gnuradio"
+ path = homepath + "/.gnuradio/unittests/python"
+
+ xmlrunner = None
+ if os.path.exists(basepath):
+ # only proceed if $HOME/.gnuradio is writable
+ st = os.stat(basepath)[stat.ST_MODE]
+ if(st & stat.S_IWUSR > 0):
+ # Test if path exists; if not, build it
+ if not os.path.exists(path):
+ os.makedirs(path, 0750)
+
+ # Just for safety: make sure we can write here, too
+ st = os.stat(path)[stat.ST_MODE]
+ if(st & stat.S_IWUSR > 0):
+ # Create an XML runner to filename
+ fout = file(path+"/"+filename, "w")
+ xmlrunner = gr_xmlrunner.XMLTestRunner(fout)
- # Test if path exists; if not, build it
- try:
- st = os.stat(path)
- except OSError:
- os.makedirs(path, 0750)
-
- # Create an XML runner to filename
- fout = file(path+"/"+filename, "w")
- xmlrunner = gr_xmlrunner.XMLTestRunner(fout)
txtrunner = TextTestRunner(verbosity=1)
# Run the test; runner also creates XML output file
# FIXME: make xmlrunner output to screen so we don't have to do run and main
suite = TestLoader().loadTestsFromTestCase(PUT)
- xmlrunner.run(suite)
+
+ # use the xmlrunner if we can write the the directory
+ if(xmlrunner is not None):
+ xmlrunner.run(suite)
+
main()
# This will run and fail make check if problem