X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gruel%2Fsrc%2Flib%2Ftest_gruel.cc;h=f4b9fc4e2d7d03ebb23a53c3285d6a1cc6a85ade;hb=2b8bd0d2fa7c76282a772b75cb99e7bd5f2be13f;hp=669303447c6d5dad78831d363a495f5f33b40710;hpb=f7bc7ed21decef03737effa69402d127e1cb54d9;p=debian%2Fgnuradio diff --git a/gruel/src/lib/test_gruel.cc b/gruel/src/lib/test_gruel.cc index 66930344..f4b9fc4e 100644 --- a/gruel/src/lib/test_gruel.cc +++ b/gruel/src/lib/test_gruel.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. + * Copyright 2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,17 +21,70 @@ */ #include +#include + +#include +#include + #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; + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_pmt::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run("", false); 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); +} +