From 2e222f4a77df389551d08b42a1bf947487d1442f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 3 May 2010 11:30:17 +0000 Subject: spi working, talked to ad9522 --- host/test/error_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'host/test') diff --git a/host/test/error_test.cpp b/host/test/error_test.cpp index c5b0af45e..3f2479f99 100644 --- a/host/test/error_test.cpp +++ b/host/test/error_test.cpp @@ -17,7 +17,7 @@ #include #include -#include +//#include #include #include @@ -30,11 +30,12 @@ BOOST_AUTO_TEST_CASE(test_assert_has){ //verify the std::has utility BOOST_CHECK(std::has(vec, 2)); BOOST_CHECK(not std::has(vec, 1)); - +/* std::cout << "The output of the assert_has error:" << std::endl; try{ uhd::assert_has(vec, 1, "prime"); }catch(const boost::exception &e){ std::cout << boost::diagnostic_information(e) << std::endl; } +*/ } -- cgit v1.2.3 From 77b9aaf5bdb9c50a2456f1aa5e3498ec228ab679 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 4 May 2010 09:46:02 +0000 Subject: fix files before pull --- host/include/uhd/utils/assert.hpp | 32 ++++++++++---------------------- host/include/uhd/utils/props.hpp | 17 +++-------------- host/include/uhd/utils/safe_main.hpp | 5 +---- host/test/error_test.cpp | 17 ++++++++++++----- 4 files changed, 26 insertions(+), 45 deletions(-) (limited to 'host/test') diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert.hpp index 577050aff..2f0ed4ff1 100644 --- a/host/include/uhd/utils/assert.hpp +++ b/host/include/uhd/utils/assert.hpp @@ -19,37 +19,24 @@ #define INCLUDED_UHD_UTILS_ASSERT_HPP #include +#include #include #include #include #include -#include -#include #include #include -#ifndef BOOST_THROW_EXCEPTION - #include - #include - #define BOOST_THROW_EXCEPTION(x)\ - ::boost::throw_exception( ::boost::enable_error_info(x) <<\ - ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\ - ::boost::throw_file(__FILE__) <<\ - ::boost::throw_line((int)__LINE__) ) - -#endif - namespace uhd{ //! The exception to throw when assertions fail - struct UHD_API assert_error : virtual std::exception, virtual boost::exception{}; - - //! The assertion info, the code that failed - typedef boost::error_info assert_info; + struct UHD_API assert_error : std::runtime_error{ + assert_error(const std::string &what); + }; //! Throw an assert error with throw-site information #define UHD_ASSERT_THROW(_x) if (not (_x)) \ - BOOST_THROW_EXCEPTION(uhd::assert_error() << uhd::assert_info(#_x)) + throw uhd::assert_error(UHD_THROW_SITE_INFO("assertion failed: " + std::string(#_x))) /*! * Check that an element is found in a container. @@ -74,13 +61,14 @@ namespace uhd{ if (i++ > 0) possible_values += ", "; possible_values += boost::lexical_cast(v); } - boost::throw_exception(uhd::assert_error() << assert_info(str(boost::format( - "Error: %s is not a valid %s. " - "Possible values are: [%s]." + throw uhd::assert_error(str(boost::format( + "assertion failed:\n" + " %s is not a valid %s.\n" + " possible values are: [%s].\n" ) % boost::lexical_cast(value) % what % possible_values - ))); + )); } }//namespace uhd diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp index 6c40c32e0..f376d2612 100644 --- a/host/include/uhd/utils/props.hpp +++ b/host/include/uhd/utils/props.hpp @@ -20,17 +20,12 @@ #include #include +#include #include -#include -#include #include #include #include -#ifndef BOOST_THROW_EXCEPTION -#define BOOST_THROW_EXCEPTION(x) throw std::runtime_error("") -#endif - namespace uhd{ //! The type for a vector of property names @@ -63,25 +58,19 @@ namespace uhd{ const std::string &name = "" ); - //! The exception to throw for property errors - struct UHD_API prop_error : virtual std::exception, virtual boost::exception{}; - - //! The property error info (verbose or message) - typedef boost::error_info prop_info; - /*! * Throw when getting a not-implemented or write-only property. * Throw-site information will be included with this error. */ #define UHD_THROW_PROP_GET_ERROR() \ - BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot get this property")) + throw std::runtime_error(UHD_THROW_SITE_INFO("cannot get this property")) /*! * Throw when setting a not-implemented or read-only property. * Throw-site information will be included with this error. */ #define UHD_THROW_PROP_SET_ERROR() \ - BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot set this property")) + throw std::runtime_error(UHD_THROW_SITE_INFO("cannot set this property")) } //namespace uhd diff --git a/host/include/uhd/utils/safe_main.hpp b/host/include/uhd/utils/safe_main.hpp index 39d2282cd..b682aa540 100644 --- a/host/include/uhd/utils/safe_main.hpp +++ b/host/include/uhd/utils/safe_main.hpp @@ -19,7 +19,6 @@ #define INCLUDED_UHD_UTILS_SAFE_MAIN_HPP #include -//#include #include #include @@ -34,9 +33,7 @@ int main(int argc, char *argv[]){ \ try { \ return _main(argc, argv); \ - } /*catch(const boost::exception &e){ \ - std::cerr << "Error: " << boost::diagnostic_information(e) << std::endl; \ - }*/ catch(const std::exception &e) { \ + } catch(const std::exception &e) { \ std::cerr << "Error: " << e.what() << std::endl; \ } catch(...) { \ std::cerr << "Error: unknown exception" << std::endl; \ diff --git a/host/test/error_test.cpp b/host/test/error_test.cpp index 3f2479f99..c76a15ab7 100644 --- a/host/test/error_test.cpp +++ b/host/test/error_test.cpp @@ -17,7 +17,6 @@ #include #include -//#include #include #include @@ -30,12 +29,20 @@ BOOST_AUTO_TEST_CASE(test_assert_has){ //verify the std::has utility BOOST_CHECK(std::has(vec, 2)); BOOST_CHECK(not std::has(vec, 1)); -/* + std::cout << "The output of the assert_has error:" << std::endl; try{ uhd::assert_has(vec, 1, "prime"); - }catch(const boost::exception &e){ - std::cout << boost::diagnostic_information(e) << std::endl; + }catch(const std::exception &e){ + std::cout << e.what() << std::endl; + } +} + +BOOST_AUTO_TEST_CASE(test_assert_throw){ + std::cout << "The output of the assert throw error:" << std::endl; + try{ + UHD_ASSERT_THROW(2 + 2 == 5); + }catch(const std::exception &e){ + std::cout << e.what() << std::endl; } -*/ } -- cgit v1.2.3 From 136e507182085fc5e666c08a0099103caba19c24 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Fri, 10 Sep 2010 10:07:37 -0400 Subject: Install main_test so we can test cross compiled uhd. --- host/test/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'host/test') diff --git a/host/test/CMakeLists.txt b/host/test/CMakeLists.txt index c620fd641..0d4607f68 100644 --- a/host/test/CMakeLists.txt +++ b/host/test/CMakeLists.txt @@ -40,3 +40,8 @@ ADD_TEST(test main_test) # demo of a loadable module ######################################################################## ADD_LIBRARY(module_test MODULE module_test.cpp) + +INSTALL(TARGETS + main_test + RUNTIME DESTINATION ${PKG_DATA_DIR}/tests +) -- cgit v1.2.3 From c347ad973f4b51b00f66d7422cd03e8790de9be3 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 21 Oct 2010 13:57:50 -0400 Subject: usrp_e: Do not install main_test anymore. --- host/test/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'host/test') diff --git a/host/test/CMakeLists.txt b/host/test/CMakeLists.txt index 59a550f98..2cc987f0c 100644 --- a/host/test/CMakeLists.txt +++ b/host/test/CMakeLists.txt @@ -52,6 +52,5 @@ ENDFOREACH(test_source) ADD_LIBRARY(module_test MODULE module_test.cpp) INSTALL(TARGETS - main_test RUNTIME DESTINATION ${PKG_DATA_DIR}/tests ) -- cgit v1.2.3