diff options
-rw-r--r-- | config/gr_pwin32.m4 | 11 | ||||
-rw-r--r-- | config/mkstemp.m4 | 11 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | gcell/apps/test_all.cc | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gri_fft.cc | 33 | ||||
-rw-r--r-- | gnuradio-core/src/lib/missing/Makefile.am | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_preferences.cc | 39 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_unittests.h | 38 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_all.cc | 5 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_atsc.cc | 5 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_filter.cc | 5 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_general.cc | 5 | ||||
-rw-r--r-- | gnuradio-core/src/tests/test_runtime.cc | 5 | ||||
-rw-r--r-- | gr-atsc/src/lib/test_atsci.cc | 5 | ||||
-rw-r--r-- | gr-howto-write-a-block/config/gr_pwin32.m4 | 11 | ||||
-rw-r--r-- | gr-howto-write-a-block/config/mkstemp.m4 | 11 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/test_all.cc | 5 | ||||
-rw-r--r-- | gruel/src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | gruel/src/lib/test_gruel.cc | 51 | ||||
-rw-r--r-- | volk/config/gr_pwin32.m4 | 11 | ||||
-rw-r--r-- | volk/config/mkstemp.m4 | 11 |
21 files changed, 62 insertions, 213 deletions
diff --git a/config/gr_pwin32.m4 b/config/gr_pwin32.m4 index 495e9dd4d..85a4a1633 100644 --- a/config/gr_pwin32.m4 +++ b/config/gr_pwin32.m4 @@ -61,17 +61,6 @@ AC_TRY_LINK([ #include <windows.h> AC_MSG_RESULT(no) ) -dnl Under Win32, mkdir prototype in io.h has only one arg -AC_MSG_CHECKING(whether mkdir accepts only one arg) -AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) - AH_BOTTOM( [ /* Define missing prototypes, implemented in replacement lib */ diff --git a/config/mkstemp.m4 b/config/mkstemp.m4 index 4af0f0a9b..2d1fbee9b 100644 --- a/config/mkstemp.m4 +++ b/config/mkstemp.m4 @@ -75,15 +75,4 @@ AC_DEFUN([jm_PREREQ_TEMPNAME], AC_CHECK_FUNCS(__secure_getenv gettimeofday lstat) AC_CHECK_DECLS_ONCE(getenv) # AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) - - dnl Under Win32, mkdir prototype in io.h has only one arg - AC_MSG_CHECKING(whether mkdir accepts only one arg) - AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) ]) diff --git a/configure.ac b/configure.ac index 3de2b069e..5f0192c9f 100644 --- a/configure.ac +++ b/configure.ac @@ -304,13 +304,13 @@ dnl dnl all the rest of these call AC_SUBST(BOOST_<foo>_LIB) and define HAVE_BOOST_<foo> dnl AX_BOOST_DATE_TIME -dnl AX_BOOST_FILESYSTEM +AX_BOOST_FILESYSTEM dnl AX_BOOST_IOSTREAMS AX_BOOST_PROGRAM_OPTIONS dnl AX_BOOST_REGEX dnl AX_BOOST_SERIALIZATION dnl AX_BOOST_SIGNALS -dnl AX_BOOST_SYSTEM +AX_BOOST_SYSTEM dnl AX_BOOST_TEST_EXEC_MONITOR dnl AX_BOOST_UNIT_TEST_FRAMEWORK dnl AX_BOOST_WSERIALIZATION diff --git a/gcell/apps/test_all.cc b/gcell/apps/test_all.cc index 0b608e13b..3f6f9256d 100644 --- a/gcell/apps/test_all.cc +++ b/gcell/apps/test_all.cc @@ -29,11 +29,8 @@ int main(int argc, char **argv) { - char path[200]; - get_unittest_path ("gcell_all.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gcell_all.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_gcell_runtime::suite()); diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc index e535f28c7..37be06f09 100644 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ b/gnuradio-core/src/lib/general/gri_fft.cc @@ -29,6 +29,17 @@ #include <cassert> #include <stdexcept> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> +namespace fs = boost::filesystem; + +static std::string get_home_dir(void){ + #if defined(BOOST_WINDOWS) + return getenv ("APPDATA"); + #else + return getenv ("HOME"); + #endif +} boost::mutex & gri_fft_planner::mutex() @@ -38,26 +49,18 @@ gri_fft_planner::mutex() return s_planning_mutex; } -static char * +static const char * wisdom_filename () { - static const char *filename = ".gr_fftw_wisdom"; - - char *home = getenv ("HOME"); - if (home){ - char *p = new char[strlen (home) + strlen (filename) + 2]; - strcpy (p, home); - strcat (p, "/"); - strcat (p, filename); - return p; - } - return 0; + static fs::path path; + path = fs::path(get_home_dir()) / ".gr_fftw_wisdom"; + return path.string().c_str(); } static void gri_fftw_import_wisdom () { - char *filename = wisdom_filename (); + const char *filename = wisdom_filename (); FILE *fp = fopen (filename, "r"); if (fp != 0){ int r = fftwf_import_wisdom_from_file (fp); @@ -66,13 +69,12 @@ gri_fftw_import_wisdom () fprintf (stderr, "gri_fftw: can't import wisdom from %s\n", filename); } } - delete [] filename; } static void gri_fftw_export_wisdom () { - char *filename = wisdom_filename (); + const char *filename = wisdom_filename (); FILE *fp = fopen (filename, "w"); if (fp != 0){ fftwf_export_wisdom_to_file (fp); @@ -82,7 +84,6 @@ gri_fftw_export_wisdom () fprintf (stderr, "gri_fftw: "); perror (filename); } - delete [] filename; } // ---------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/missing/Makefile.am b/gnuradio-core/src/lib/missing/Makefile.am index bd18cf143..7c97834e0 100644 --- a/gnuradio-core/src/lib/missing/Makefile.am +++ b/gnuradio-core/src/lib/missing/Makefile.am @@ -21,7 +21,7 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(GNURADIO_INCLUDES) $(WITH_INCLUDES) +AM_CPPFLAGS = $(GRUEL_INCLUDES) $(GNURADIO_INCLUDES) $(WITH_INCLUDES) EXTRA_DIST += \ getopt.h \ diff --git a/gnuradio-core/src/lib/runtime/gr_preferences.cc b/gnuradio-core/src/lib/runtime/gr_preferences.cc index 5f7412248..21934677b 100644 --- a/gnuradio-core/src/lib/runtime/gr_preferences.cc +++ b/gnuradio-core/src/lib/runtime/gr_preferences.cc @@ -33,12 +33,17 @@ #include <unistd.h> #include <string.h> - -#ifdef MKDIR_TAKES_ONE_ARG -#define gr_mkdir(pathname, mode) mkdir(pathname) -#else -#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) -#endif +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> +namespace fs = boost::filesystem; + +static std::string get_home_dir(void){ + #if defined(BOOST_WINDOWS) + return getenv ("APPDATA"); + #else + return getenv ("HOME"); + #endif +} /* * The simplest thing that could possibly work: @@ -48,27 +53,19 @@ static const char * pathname (const char *key) { - static char buf[200]; - snprintf (buf, sizeof (buf), "%s/.gnuradio/prefs/%s", getenv ("HOME"), key); - return buf; + static fs::path path; + path = fs::path(get_home_dir()) / ".gnuradio" / "prefs" / key; + return path.string().c_str(); } static void ensure_dir_path () { - char path[200]; - struct stat statbuf; - - snprintf (path, sizeof (path), "%s/.gnuradio/prefs", getenv ("HOME")); - if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) - return; - - // blindly try to make it // FIXME make this robust. C++ SUCKS! + fs::path path = fs::path(get_home_dir()) / ".gnuradio"; + if (!fs::is_directory(path)) fs::create_directory(path); - snprintf (path, sizeof (path), "%s/.gnuradio", getenv ("HOME")); - gr_mkdir (path, 0750); - snprintf (path, sizeof (path), "%s/.gnuradio/prefs", getenv ("HOME")); - gr_mkdir (path, 0750); + path = path / "prefs"; + if (!fs::is_directory(path)) fs::create_directory(path); } const char * diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h index 70aa6f294..6e62bc7c1 100644 --- a/gnuradio-core/src/lib/runtime/gr_unittests.h +++ b/gnuradio-core/src/lib/runtime/gr_unittests.h @@ -31,37 +31,11 @@ #include <sys/stat.h> #include <unistd.h> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> -#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 *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 (path, 0750); +static std::string get_unittest_path(const std::string &filename){ + boost::filesystem::path path = boost::filesystem::current_path() / ".unittests"; + if (!boost::filesystem::is_directory(path)) boost::filesystem::create_directory(path); + return (path / filename).string(); } - -static void -get_unittest_path (const char *filename, char *fullpath, size_t pathsize) -{ - char path[200]; - snprintf (path, sizeof(path), "./.unittests"); - snprintf (fullpath, pathsize, "%s/%s", path, filename); - - ensure_unittest_path(path); -} - diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index 17ee32f34..41bb59dcd 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -34,11 +34,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_all.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_all.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); diff --git a/gnuradio-core/src/tests/test_atsc.cc b/gnuradio-core/src/tests/test_atsc.cc index 51642f81a..37386d88e 100644 --- a/gnuradio-core/src/tests/test_atsc.cc +++ b/gnuradio-core/src/tests/test_atsc.cc @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_atsc.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_atsc.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_atsc::suite ()); diff --git a/gnuradio-core/src/tests/test_filter.cc b/gnuradio-core/src/tests/test_filter.cc index 2781cfb35..3f7d70beb 100644 --- a/gnuradio-core/src/tests/test_filter.cc +++ b/gnuradio-core/src/tests/test_filter.cc @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_filter.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_filter.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_filter::suite ()); diff --git a/gnuradio-core/src/tests/test_general.cc b/gnuradio-core/src/tests/test_general.cc index 16ee9c3ad..98cece680 100644 --- a/gnuradio-core/src/tests/test_general.cc +++ b/gnuradio-core/src/tests/test_general.cc @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_general.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_general.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_general::suite ()); diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc index c7983a23e..608998df6 100644 --- a/gnuradio-core/src/tests/test_runtime.cc +++ b/gnuradio-core/src/tests/test_runtime.cc @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gnuradio_core_runtime.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gnuradio_core_runtime.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); diff --git a/gr-atsc/src/lib/test_atsci.cc b/gr-atsc/src/lib/test_atsci.cc index 184895a90..46833ab5d 100644 --- a/gr-atsc/src/lib/test_atsci.cc +++ b/gr-atsc/src/lib/test_atsci.cc @@ -28,11 +28,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gr_atsc.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gr_atsc.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_atsc::suite ()); diff --git a/gr-howto-write-a-block/config/gr_pwin32.m4 b/gr-howto-write-a-block/config/gr_pwin32.m4 index 495e9dd4d..85a4a1633 100644 --- a/gr-howto-write-a-block/config/gr_pwin32.m4 +++ b/gr-howto-write-a-block/config/gr_pwin32.m4 @@ -61,17 +61,6 @@ AC_TRY_LINK([ #include <windows.h> AC_MSG_RESULT(no) ) -dnl Under Win32, mkdir prototype in io.h has only one arg -AC_MSG_CHECKING(whether mkdir accepts only one arg) -AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) - AH_BOTTOM( [ /* Define missing prototypes, implemented in replacement lib */ diff --git a/gr-howto-write-a-block/config/mkstemp.m4 b/gr-howto-write-a-block/config/mkstemp.m4 index 4af0f0a9b..2d1fbee9b 100644 --- a/gr-howto-write-a-block/config/mkstemp.m4 +++ b/gr-howto-write-a-block/config/mkstemp.m4 @@ -75,15 +75,4 @@ AC_DEFUN([jm_PREREQ_TEMPNAME], AC_CHECK_FUNCS(__secure_getenv gettimeofday lstat) AC_CHECK_DECLS_ONCE(getenv) # AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) - - dnl Under Win32, mkdir prototype in io.h has only one arg - AC_MSG_CHECKING(whether mkdir accepts only one arg) - AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) ]) diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc index ac1e83839..c760e1eb7 100644 --- a/gr-howto-write-a-block/lib/test_all.cc +++ b/gr-howto-write-a-block/lib/test_all.cc @@ -29,11 +29,8 @@ int main (int argc, char **argv) { - char path[200]; - get_unittest_path ("gr_howto_write_a_block.xml", path, 200); - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(path); + std::ofstream xmlfile(get_unittest_path("gr_howto_write_a_block.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_howto::suite ()); diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am index 5c3302f19..876e7ab3d 100644 --- a/gruel/src/lib/Makefile.am +++ b/gruel/src/lib/Makefile.am @@ -51,6 +51,8 @@ libgruel_la_SOURCES = \ libgruel_la_LIBADD = \ $(BOOST_THREAD_LIB) \ + $(BOOST_SYSTEM_LIB) \ + $(BOOST_FILESYSTEM_LIB) \ $(PMT_LIB) \ $(MSG_LIB) \ -lstdc++ diff --git a/gruel/src/lib/test_gruel.cc b/gruel/src/lib/test_gruel.cc index 2c9528b0a..efb6cb777 100644 --- a/gruel/src/lib/test_gruel.cc +++ b/gruel/src/lib/test_gruel.cc @@ -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,41 +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 *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 (path, 0750); -} - -static void -get_unittest_path (const char *filename, char *fullpath, size_t pathsize) -{ - char path[200]; - snprintf (path, sizeof(path), "./.unittests"); - snprintf (fullpath, pathsize, "%s/%s", path, filename); - - ensure_unittest_path(path); -} - diff --git a/volk/config/gr_pwin32.m4 b/volk/config/gr_pwin32.m4 index 7b99cba6b..c75535b8e 100644 --- a/volk/config/gr_pwin32.m4 +++ b/volk/config/gr_pwin32.m4 @@ -61,17 +61,6 @@ AC_TRY_LINK([ #include <windows.h> AC_MSG_RESULT(no) ) -dnl Under Win32, mkdir prototype in io.h has only one arg -AC_MSG_CHECKING(whether mkdir accepts only one arg) -AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) - AH_BOTTOM( [ /* Define missing prototypes, implemented in replacement lib */ diff --git a/volk/config/mkstemp.m4 b/volk/config/mkstemp.m4 index 4af0f0a9b..2d1fbee9b 100644 --- a/volk/config/mkstemp.m4 +++ b/volk/config/mkstemp.m4 @@ -75,15 +75,4 @@ AC_DEFUN([jm_PREREQ_TEMPNAME], AC_CHECK_FUNCS(__secure_getenv gettimeofday lstat) AC_CHECK_DECLS_ONCE(getenv) # AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) - - dnl Under Win32, mkdir prototype in io.h has only one arg - AC_MSG_CHECKING(whether mkdir accepts only one arg) - AC_TRY_COMPILE([#include <sys/types.h> - #include <sys/stat.h> - #include <fcntl.h>], [ - mkdir("") - ], [ AC_MSG_RESULT(yes) - AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ], - [ AC_MSG_RESULT(no) - ]) ]) |