summaryrefslogtreecommitdiff
path: root/gruel/src/lib/test_gruel.cc
diff options
context:
space:
mode:
authorBen Reynwar2011-01-30 09:50:36 -0700
committerBen Reynwar2011-01-30 09:50:36 -0700
commitd1d4c8fd9dcf852cef9c274363182209c6761145 (patch)
tree54ddbd617c5ffffbbfc4e766f2d2281669919a73 /gruel/src/lib/test_gruel.cc
parentf6547e103e6cae44ff2a81b0f83675ccc897f2e9 (diff)
parent023167ca8a85ab597f9e59302733f71809a8afbd (diff)
downloadgnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.gz
gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.bz2
gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.zip
Merged upstream from next
Diffstat (limited to 'gruel/src/lib/test_gruel.cc')
-rw-r--r--gruel/src/lib/test_gruel.cc56
1 files changed, 9 insertions, 47 deletions
diff --git a/gruel/src/lib/test_gruel.cc b/gruel/src/lib/test_gruel.cc
index f4b9fc4e2..7ef3520e6 100644
--- a/gruel/src/lib/test_gruel.cc
+++ b/gruel/src/lib/test_gruel.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2009,2010 Free Software Foundation, Inc.
+ * Copyright 2006,2009,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -28,16 +28,19 @@
#include "pmt/qa_pmt.h"
-static void get_unittest_path (const char *filename, char *fullpath, size_t pathsize);
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
int
main(int argc, char **argv)
{
- char path[200];
- get_unittest_path ("gruel.xml", path, 200);
-
+ fs::path path = fs::current_path() / ".unittests";
+ if (!fs::is_directory(path)) fs::create_directory(path);
+ path = path / "gruel.xml";
+
CppUnit::TextTestRunner runner;
- std::ofstream xmlfile(path);
+ std::ofstream xmlfile(path.string().c_str());
CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile);
runner.addTest(qa_pmt::suite ());
@@ -47,44 +50,3 @@ 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);
-}
-