Modifying the unittest output. XML files are no longer written outside of the build...
authorTom Rondeau <trondeau@vt.edu>
Thu, 23 Dec 2010 23:31:28 +0000 (18:31 -0500)
committerTom Rondeau <trondeau@vt.edu>
Thu, 23 Dec 2010 23:31:28 +0000 (18:31 -0500)
gnuradio-core/src/lib/runtime/gr_unittests.h
gnuradio-core/src/python/gnuradio/gr_unittest.py
gruel/src/lib/test_gruel.cc

index 680e59ca44d5a2317cfdb6b897fda61f173b032c..70aa6f294b3f50112bbcf89c02f5bff946053aca 100644 (file)
  */
 
 static void
  */
 
 static void
-ensure_unittest_path (const char *grpath, const char *path)
+ensure_unittest_path (const char *path)
 {
   struct stat statbuf;
   if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
     return;
 
   // blindly try to make it    // FIXME make this robust. C++ SUCKS!
 {
   struct stat statbuf;
   if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
     return;
 
   // blindly try to make it    // FIXME make this robust. C++ SUCKS!
-  gr_mkdir (grpath, 0750);
   gr_mkdir (path, 0750);
 }
 
   gr_mkdir (path, 0750);
 }
 
@@ -60,11 +59,9 @@ static void
 get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
 {
   char path[200];
 get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
 {
   char path[200];
-  char grpath[200];
-  snprintf (grpath, sizeof(grpath), "%s/.gnuradio", getenv ("HOME"));
-  snprintf (path, sizeof(path), "%s/unittests", grpath);
+  snprintf (path, sizeof(path), "./.unittests");
   snprintf (fullpath, pathsize, "%s/%s", path, filename);
 
   snprintf (fullpath, pathsize, "%s/%s", path, filename);
 
-  ensure_unittest_path(grpath, path);
+  ensure_unittest_path(path);
 }
 
 }
 
index 50d484a76e69c79688a47536022f1ae164a87f95..c2c4df2ba5f7a0fd4d26bfe7bdd4cf5329299bb2 100755 (executable)
@@ -38,7 +38,7 @@ class TestCase(unittest.TestCase):
 
            Note that decimal places (from zero) is usually not the same
            as significant digits (measured from the most signficant digit).
 
            Note that decimal places (from zero) is usually not the same
            as significant digits (measured from the most signficant digit).
-        """
+       """
         if round(second.real-first.real, places) != 0:
             raise self.failureException, \
                   (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
         if round(second.real-first.real, places) != 0:
             raise self.failureException, \
                   (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
@@ -112,30 +112,31 @@ def run(PUT, filename=None):
     Runs the unittest on a TestCase and produces an optional XML report
     PUT:      the program under test and should be a gr_unittest.TestCase
     filename: an optional filename to save the XML report of the tests
     Runs the unittest on a TestCase and produces an optional XML report
     PUT:      the program under test and should be a gr_unittest.TestCase
     filename: an optional filename to save the XML report of the tests
-              this will live in $HOME/.gnuradio/unittests/python
+              this will live in ./.unittests/python
     '''
 
     # Run this is given a file name
     if(filename is not None):
     '''
 
     # Run this is given a file name
     if(filename is not None):
-        homepath = os.getenv("HOME")
-        basepath = homepath + "/.gnuradio"
-        path = homepath + "/.gnuradio/unittests/python"
+        basepath = "./.unittests"
+        path = basepath + "/python"
+
+        if not os.path.exists(basepath):
+            os.makedirs(basepath, 0750)
 
         xmlrunner = None
 
         xmlrunner = None
-        if os.path.exists(basepath):
-            # only proceed if $HOME/.gnuradio is writable
-            st = os.stat(basepath)[stat.ST_MODE]
+        # only proceed if .unittests 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):
             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)
+                # Create an XML runner to filename
+                fout = file(path+"/"+filename, "w")
+                xmlrunner = gr_xmlrunner.XMLTestRunner(fout)
 
         txtrunner = TextTestRunner(verbosity=1)
 
 
         txtrunner = TextTestRunner(verbosity=1)
 
index f4b9fc4e2d7d03ebb23a53c3285d6a1cc6a85ade..2c9528b0ab192905deb3da1189e47505e0ea97db 100644 (file)
@@ -65,14 +65,13 @@ main(int argc, char **argv)
  */
 
 static void
  */
 
 static void
-ensure_unittest_path (const char *grpath, const char *path)
+ensure_unittest_path (const char *path)
 {
   struct stat statbuf;
   if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
     return;
 
   // blindly try to make it    // FIXME make this robust. C++ SUCKS!
 {
   struct stat statbuf;
   if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
     return;
 
   // blindly try to make it    // FIXME make this robust. C++ SUCKS!
-  gr_mkdir (grpath, 0750);
   gr_mkdir (path, 0750);
 }
 
   gr_mkdir (path, 0750);
 }
 
@@ -80,11 +79,9 @@ static void
 get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
 {
   char path[200];
 get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
 {
   char path[200];
-  char grpath[200];
-  snprintf (grpath, sizeof(grpath), "%s/.gnuradio", getenv ("HOME"));
-  snprintf (path, sizeof(path), "%s/unittests", grpath);
+  snprintf (path, sizeof(path), "./.unittests");
   snprintf (fullpath, pathsize, "%s/%s", path, filename);
 
   snprintf (fullpath, pathsize, "%s/%s", path, filename);
 
-  ensure_unittest_path(grpath, path);
+  ensure_unittest_path(path);
 }
 
 }