aboutsummaryrefslogtreecommitdiffstats
path: root/host/test
diff options
context:
space:
mode:
Diffstat (limited to 'host/test')
-rw-r--r--host/test/addr_test.cpp45
-rw-r--r--host/test/gain_handler_test.cpp28
-rw-r--r--host/test/module_test.cpp4
-rw-r--r--host/test/wax_test.cpp19
4 files changed, 70 insertions, 26 deletions
diff --git a/host/test/addr_test.cpp b/host/test/addr_test.cpp
index 148aee015..a5d2d4c06 100644
--- a/host/test/addr_test.cpp
+++ b/host/test/addr_test.cpp
@@ -16,13 +16,52 @@
//
#include <boost/test/unit_test.hpp>
-#include <uhd/device_addr.hpp>
+#include <uhd/types/mac_addr.hpp>
+#include <uhd/types/device_addr.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/foreach.hpp>
+#include <algorithm>
+#include <iostream>
BOOST_AUTO_TEST_CASE(test_mac_addr){
std::cout << "Testing mac addr..." << std::endl;
const std::string mac_addr_str("00:01:23:45:67:89");
- uhd::mac_addr_t mac_addr(mac_addr_str);
+ uhd::mac_addr_t mac_addr = uhd::mac_addr_t::from_string(mac_addr_str);
std::cout << "Input: " << mac_addr_str << std::endl;
- std::cout << "Output: " << mac_addr << std::endl;
+ std::cout << "Output: " << mac_addr.to_string() << std::endl;
BOOST_CHECK_EQUAL(mac_addr_str, mac_addr.to_string());
}
+
+BOOST_AUTO_TEST_CASE(test_device_addr){
+ std::cout << "Testing device addr..." << std::endl;
+
+ //load the device address with something
+ uhd::device_addr_t dev_addr;
+ dev_addr["key1"] = "val1";
+ dev_addr["key2"] = "val2";
+
+ //convert to and from args string
+ std::cout << "Pretty Print: " << std::endl << dev_addr.to_string();
+ std::string args_str = dev_addr.to_args_str();
+ std::cout << "Args String: " << args_str << std::endl;
+ uhd::device_addr_t new_dev_addr = uhd::device_addr_t::from_args_str(args_str);
+
+ //they should be the same size
+ BOOST_CHECK_EQUAL(dev_addr.size(), new_dev_addr.size());
+
+ //the keys should match
+ std::vector<std::string> old_dev_addr_keys = dev_addr.get_keys();
+ std::vector<std::string> new_dev_addr_keys = new_dev_addr.get_keys();
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ old_dev_addr_keys.begin(), old_dev_addr_keys.end(),
+ new_dev_addr_keys.begin(), new_dev_addr_keys.end()
+ );
+
+ //the vals should match
+ std::vector<std::string> old_dev_addr_vals = dev_addr.get_vals();
+ std::vector<std::string> new_dev_addr_vals = new_dev_addr.get_vals();
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ old_dev_addr_vals.begin(), old_dev_addr_vals.end(),
+ new_dev_addr_vals.begin(), new_dev_addr_vals.end()
+ );
+}
diff --git a/host/test/gain_handler_test.cpp b/host/test/gain_handler_test.cpp
index 47acb30f0..76b065ce2 100644
--- a/host/test/gain_handler_test.cpp
+++ b/host/test/gain_handler_test.cpp
@@ -16,10 +16,10 @@
//
#include <boost/test/unit_test.hpp>
-#include <uhd/gain_handler.hpp>
-#include <uhd/types.hpp>
+#include <uhd/utils/gain_handler.hpp>
+#include <uhd/types/ranges.hpp>
+#include <uhd/types/dict.hpp>
#include <uhd/props.hpp>
-#include <uhd/dict.hpp>
#include <boost/bind.hpp>
#include <iostream>
@@ -46,8 +46,8 @@ public:
);
_gain_values["g0"] = 0;
_gain_values["g1"] = 0;
- _gain_ranges["g0"] = gain_range_t(-10, 0, .1);
- _gain_ranges["g1"] = gain_range_t(0, 100, 1.5);
+ _gain_ranges["g0"] = gain_range_t(-10, 0, float(.1));
+ _gain_ranges["g1"] = gain_range_t(0, 100, float(1.5));
}
~gainful_obj(void){}
@@ -84,7 +84,7 @@ private:
//handle the get request conditioned on the key
switch(key.as<prop_t>()){
case PROP_GAIN_VALUE:
- _gain_values[name] = val.as<gain_t>();
+ _gain_values[name] = val.as<float>();
return;
case PROP_GAIN_RANGE:
@@ -94,7 +94,7 @@ private:
}
gain_handler::sptr _gain_handler;
- uhd::dict<std::string, gain_t> _gain_values;
+ uhd::dict<std::string, float> _gain_values;
uhd::dict<std::string, gain_range_t> _gain_ranges;
};
@@ -104,18 +104,18 @@ BOOST_AUTO_TEST_CASE(test_gain_handler){
gainful_obj go0;
BOOST_CHECK_THROW(
- go0[named_prop_t(PROP_GAIN_VALUE, "fail")].as<gain_t>(),
+ go0[named_prop_t(PROP_GAIN_VALUE, "fail")].as<float>(),
std::exception
);
std::cout << "verifying the overall min, max, step" << std::endl;
gain_range_t gain = go0[PROP_GAIN_RANGE].as<gain_range_t>();
- BOOST_CHECK_EQUAL(gain.min, gain_t(-10));
- BOOST_CHECK_EQUAL(gain.max, gain_t(100));
- BOOST_CHECK_EQUAL(gain.step, gain_t(1.5));
+ BOOST_CHECK_EQUAL(gain.min, float(-10));
+ BOOST_CHECK_EQUAL(gain.max, float(100));
+ BOOST_CHECK_EQUAL(gain.step, float(1.5));
std::cout << "verifying the overall gain" << std::endl;
- go0[named_prop_t(PROP_GAIN_VALUE, "g0")] = gain_t(-5);
- go0[named_prop_t(PROP_GAIN_VALUE, "g1")] = gain_t(30);
- BOOST_CHECK_EQUAL(go0[PROP_GAIN_VALUE].as<gain_t>(), gain_t(25));
+ go0[named_prop_t(PROP_GAIN_VALUE, "g0")] = float(-5);
+ go0[named_prop_t(PROP_GAIN_VALUE, "g1")] = float(30);
+ BOOST_CHECK_EQUAL(go0[PROP_GAIN_VALUE].as<float>(), float(25));
}
diff --git a/host/test/module_test.cpp b/host/test/module_test.cpp
index 71721ef90..47a0e1af9 100644
--- a/host/test/module_test.cpp
+++ b/host/test/module_test.cpp
@@ -15,10 +15,10 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include <uhd/utils.hpp>
+#include <uhd/utils/static.hpp>
#include <iostream>
-STATIC_BLOCK(module_test){
+UHD_STATIC_BLOCK(module_test){
std::cout << "---------------------------------------" << std::endl;
std::cout << "-- Good news, everyone!" << std::endl;
std::cout << "-- The test module has been loaded." << std::endl;
diff --git a/host/test/wax_test.cpp b/host/test/wax_test.cpp
index cb3b12052..731f470ed 100644
--- a/host/test/wax_test.cpp
+++ b/host/test/wax_test.cpp
@@ -16,6 +16,7 @@
//
#include <boost/test/unit_test.hpp>
+#include <boost/shared_ptr.hpp>
#include <uhd/wax.hpp>
#include <iostream>
@@ -32,26 +33,29 @@ BOOST_AUTO_TEST_CASE(test_enums){
* demo class for wax framework
**********************************************************************/
class wax_demo : public wax::obj{
-private:
- std::vector<float> d_nums;
- std::vector<wax_demo> d_subs;
public:
+ typedef boost::shared_ptr<wax_demo> sptr;
+
wax_demo(size_t sub_demos, size_t len){
d_nums = std::vector<float>(len);
if (sub_demos != 0){
for (size_t i = 0; i < len; i++){
- d_subs.push_back(wax_demo(sub_demos-1, len));
+ d_subs.push_back(sptr(new wax_demo(sub_demos-1, len)));
}
}
}
~wax_demo(void){
/* NOP */
}
+private:
+ std::vector<float> d_nums;
+ std::vector<sptr> d_subs;
+
void get(const wax::obj &key, wax::obj &value){
if (d_subs.size() == 0){
value = d_nums[key.as<size_t>()];
}else{
- value = d_subs[key.as<size_t>()].get_link();
+ value = d_subs[key.as<size_t>()]->get_link();
}
}
void set(const wax::obj &key, const wax::obj &value){
@@ -63,9 +67,8 @@ public:
}
};
-static wax_demo wd(2, 10);
-
BOOST_AUTO_TEST_CASE(test_chaining){
+ wax_demo wd(2, 1);
std::cout << "chain 1" << std::endl;
wd[size_t(0)];
std::cout << "chain 2" << std::endl;
@@ -75,6 +78,7 @@ BOOST_AUTO_TEST_CASE(test_chaining){
}
BOOST_AUTO_TEST_CASE(test_set_get){
+ wax_demo wd(2, 10);
std::cout << "set and get all" << std::endl;
for (size_t i = 0; i < 10; i++){
for (size_t j = 0; j < 10; j++){
@@ -89,6 +93,7 @@ BOOST_AUTO_TEST_CASE(test_set_get){
}
BOOST_AUTO_TEST_CASE(test_proxy){
+ wax_demo wd(2, 1);
std::cout << "store proxy" << std::endl;
wax::obj p = wd[size_t(0)][size_t(0)];
p[size_t(0)] = float(5);