diff options
author | Tom Rondeau | 2010-10-02 17:16:04 -0400 |
---|---|---|
committer | Tom Rondeau | 2010-10-02 17:16:04 -0400 |
commit | 2b8bd0d2fa7c76282a772b75cb99e7bd5f2be13f (patch) | |
tree | 6b50d3098332428f32a7a051e8abe8db1f446a9f /gruel/src/lib | |
parent | 036a42c08eadbd0a2c462ca61d9d883996be8042 (diff) | |
download | gnuradio-2b8bd0d2fa7c76282a772b75cb99e7bd5f2be13f.tar.gz gnuradio-2b8bd0d2fa7c76282a772b75cb99e7bd5f2be13f.tar.bz2 gnuradio-2b8bd0d2fa7c76282a772b75cb99e7bd5f2be13f.zip |
Moving XML output files from cppunit tests to $HOME/.gnuradio/unittests.
This also adds a new utility gr_unittests.h, which sets up the path for output files.
Diffstat (limited to 'gruel/src/lib')
-rw-r--r-- | gruel/src/lib/test_gruel.cc | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/gruel/src/lib/test_gruel.cc b/gruel/src/lib/test_gruel.cc index cb5f2d36b..f4b9fc4e2 100644 --- a/gruel/src/lib/test_gruel.cc +++ b/gruel/src/lib/test_gruel.cc @@ -22,14 +22,22 @@ #include <cppunit/TextTestRunner.h> #include <cppunit/XmlOutputter.h> + +#include <stdlib.h> +#include <sys/stat.h> + #include "pmt/qa_pmt.h" +static void get_unittest_path (const char *filename, char *fullpath, size_t pathsize); + int main(int argc, char **argv) { + char path[200]; + get_unittest_path ("gruel.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile("cppunit_gruel.xml"); + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_pmt::suite ()); @@ -39,3 +47,44 @@ main(int argc, char **argv) return was_successful ? 0 : 1; } + + +// NOTE: These are defined in gr_unittest.h for the rest of the project; +// rewriting here since we don't depend on gnuradio-core in gruel + +#ifdef MKDIR_TAKES_ONE_ARG +#define gr_mkdir(pathname, mode) mkdir(pathname) +#else +#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) +#endif + +/* + * Mostly taken from gr_preferences.cc/h + * The simplest thing that could possibly work: + * the key is the filename; the value is the file contents. + */ + +static void +ensure_unittest_path (const char *grpath, 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! + gr_mkdir (grpath, 0750); + gr_mkdir (path, 0750); +} + +static void +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 (fullpath, pathsize, "%s/%s", path, filename); + + ensure_unittest_path(grpath, path); +} + |