+
+
+// 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);
+}
+