aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-17 00:41:38 -0800
committerJosh Blum <josh@joshknows.com>2010-02-17 00:41:38 -0800
commiteb7e709b7aff162cc7c8f9b8004089846839ffbe (patch)
tree7dd6527b06297d9b64e8800ffcd63001aa3159e1 /test
parentd8d783ce1b1034495dba86dab104a4f52e2fe09a (diff)
downloaduhd-eb7e709b7aff162cc7c8f9b8004089846839ffbe.tar.gz
uhd-eb7e709b7aff162cc7c8f9b8004089846839ffbe.tar.bz2
uhd-eb7e709b7aff162cc7c8f9b8004089846839ffbe.zip
moved host code into host directory for clean (unambiguous) top level
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt30
-rw-r--r--test/addr_test.cpp28
-rw-r--r--test/device_test.cpp44
-rw-r--r--test/gain_handler_test.cpp128
-rw-r--r--test/main_test.cpp3
-rw-r--r--test/usrp_dboard_test.cpp60
-rw-r--r--test/wax_test.cpp98
7 files changed, 0 insertions, 391 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
deleted file mode 100644
index 0dcd1e68e..000000000
--- a/test/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 2010 Ettus Research LLC
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-ADD_EXECUTABLE(main_test
- main_test.cpp
- addr_test.cpp
- device_test.cpp
- gain_handler_test.cpp
- usrp_dboard_test.cpp
- wax_test.cpp
-)
-
-TARGET_LINK_LIBRARIES(main_test uhd)
-
-ADD_TEST(test main_test)
diff --git a/test/addr_test.cpp b/test/addr_test.cpp
deleted file mode 100644
index 148aee015..000000000
--- a/test/addr_test.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <uhd/device_addr.hpp>
-
-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);
- std::cout << "Input: " << mac_addr_str << std::endl;
- std::cout << "Output: " << mac_addr << std::endl;
- BOOST_CHECK_EQUAL(mac_addr_str, mac_addr.to_string());
-}
diff --git a/test/device_test.cpp b/test/device_test.cpp
deleted file mode 100644
index 6373ff41b..000000000
--- a/test/device_test.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <uhd/device.hpp>
-
-using namespace uhd;
-
-BOOST_AUTO_TEST_CASE(test_device){
- device_addr_t device_addr;
- device_addr["type"] = "test";
- device_addr["num_dboards"] = "2";
- device::sptr dev = device::make(device_addr);
-
- std::cout << "Access the device" << std::endl;
- std::cout << wax::cast<std::string>((*dev)[DEVICE_PROP_NAME]) << std::endl;
-
- std::cout << "Access the mboard" << std::endl;
- wax::obj mb0 = (*dev)[DEVICE_PROP_MBOARD];
- std::cout << wax::cast<std::string>(mb0[MBOARD_PROP_NAME]) << std::endl;
- BOOST_CHECK_EQUAL(
- 2,
- wax::cast<prop_names_t>(mb0[MBOARD_PROP_RX_DBOARD_NAMES]).size()
- );
- BOOST_CHECK_EQUAL(
- 2,
- wax::cast<prop_names_t>(mb0[MBOARD_PROP_TX_DBOARD_NAMES]).size()
- );
-
-}
diff --git a/test/gain_handler_test.cpp b/test/gain_handler_test.cpp
deleted file mode 100644
index c81221aac..000000000
--- a/test/gain_handler_test.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <uhd/gain_handler.hpp>
-#include <uhd/dict.hpp>
-#include <iostream>
-
-using namespace uhd;
-
-enum prop_t{
- PROP_GAIN,
- PROP_GAIN_MIN,
- PROP_GAIN_MAX,
- PROP_GAIN_STEP,
- PROP_GAIN_NAMES
-};
-
-class gainful_obj : public wax::obj{
-public:
- gainful_obj(void){
- _gain_handler = gain_handler::sptr(new gain_handler(
- this, PROP_GAIN, PROP_GAIN_MIN, PROP_GAIN_MAX, PROP_GAIN_STEP, PROP_GAIN_NAMES
- ));
- _gains["g0"] = 0;
- _gains["g1"] = 0;
- _gains_min["g0"] = -10;
- _gains_min["g1"] = 0;
- _gains_max["g0"] = 0;
- _gains_max["g1"] = 100;
- _gains_step["g0"] = .1;
- _gains_step["g1"] = 1.5;
- }
-
- ~gainful_obj(void){}
-
-private:
- void get(const wax::obj &key_, wax::obj &val){
- if (_gain_handler->intercept_get(key_, val)) return;
-
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
-
- //handle the get request conditioned on the key
- switch(wax::cast<prop_t>(key)){
- case PROP_GAIN:
- val = _gains[name];
- return;
-
- case PROP_GAIN_MIN:
- val = _gains_min[name];
- return;
-
- case PROP_GAIN_MAX:
- val = _gains_max[name];
- return;
-
- case PROP_GAIN_STEP:
- val = _gains_step[name];
- return;
-
- case PROP_GAIN_NAMES:
- val = prop_names_t(_gains.get_keys());
- return;
- }
- }
-
- void set(const wax::obj &key_, const wax::obj &val){
- if (_gain_handler->intercept_set(key_, val)) return;
-
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
-
- //handle the get request conditioned on the key
- switch(wax::cast<prop_t>(key)){
- case PROP_GAIN:
- _gains[name] = wax::cast<gain_t>(val);
- return;
-
- case PROP_GAIN_MIN:
- case PROP_GAIN_MAX:
- case PROP_GAIN_STEP:
- case PROP_GAIN_NAMES:
- throw std::runtime_error("cannot set this property");
- }
- }
-
- gain_handler::sptr _gain_handler;
- uhd::dict<std::string, gain_t> _gains;
- uhd::dict<std::string, gain_t> _gains_min;
- uhd::dict<std::string, gain_t> _gains_max;
- uhd::dict<std::string, gain_t> _gains_step;
-
-};
-
-BOOST_AUTO_TEST_CASE(test_gain_handler){
- std::cout << "Testing the gain handler..." << std::endl;
- gainful_obj go0;
-
- BOOST_CHECK_THROW(
- wax::cast<gain_t>(go0[named_prop_t(PROP_GAIN, "fail")]),
- std::invalid_argument
- );
-
- std::cout << "verifying the overall min, max, step" << std::endl;
- BOOST_CHECK_EQUAL(wax::cast<gain_t>(go0[PROP_GAIN_MIN]), gain_t(-10));
- BOOST_CHECK_EQUAL(wax::cast<gain_t>(go0[PROP_GAIN_MAX]), gain_t(100));
- BOOST_CHECK_EQUAL(wax::cast<gain_t>(go0[PROP_GAIN_STEP]), gain_t(1.5));
-
- std::cout << "verifying the overall gain" << std::endl;
- go0[named_prop_t(PROP_GAIN, "g0")] = gain_t(-5);
- go0[named_prop_t(PROP_GAIN, "g1")] = gain_t(30);
- BOOST_CHECK_EQUAL(wax::cast<gain_t>(go0[PROP_GAIN]), gain_t(25));
-}
diff --git a/test/main_test.cpp b/test/main_test.cpp
deleted file mode 100644
index 0b47303b7..000000000
--- a/test/main_test.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
diff --git a/test/usrp_dboard_test.cpp b/test/usrp_dboard_test.cpp
deleted file mode 100644
index f0ae7a53d..000000000
--- a/test/usrp_dboard_test.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <uhd/usrp/dboard/manager.hpp>
-
-using namespace uhd::usrp::dboard;
-
-/***********************************************************************
- * dummy interface for dboards
- **********************************************************************/
-class dummy_interface : public interface{
-public:
- dummy_interface(void){}
- ~dummy_interface(void){}
- void write_aux_dac(int, int){}
- int read_aux_adc(int){return 0;}
- void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t){}
- void set_gpio_ddr(gpio_bank_t, uint16_t, uint16_t){}
- void write_gpio(gpio_bank_t, uint16_t, uint16_t){}
- uint16_t read_gpio(gpio_bank_t){return 0;}
- void write_i2c (int, const std::string &){}
- std::string read_i2c (int, size_t){return "";}
- void write_spi (spi_dev_t, spi_push_t, const std::string &){}
- std::string read_spi (spi_dev_t, spi_latch_t, size_t){return "";}
- double get_rx_clock_rate(void){return 0.0;}
- double get_tx_clock_rate(void){return 0.0;}
-};
-
-BOOST_AUTO_TEST_CASE(test_manager){
- std::cout << "Making a dummy usrp dboard interface..." << std::endl;
- interface::sptr ifc0(new dummy_interface());
-
- std::cout << "Making a usrp dboard manager..." << std::endl;
- manager::sptr mgr0(new manager(ID_BASIC_RX, ID_BASIC_TX, ifc0));
-
- std::cout << "Testing the dboard manager..." << std::endl;
- BOOST_CHECK_EQUAL(size_t(3), mgr0->get_rx_subdev_names().size());
- BOOST_CHECK_EQUAL(size_t(1), mgr0->get_tx_subdev_names().size());
-
- std::cout << "Testing access (will fail later when db code filled in)..." << std::endl;
- BOOST_CHECK_THROW(mgr0->get_rx_subdev(""), std::invalid_argument);
- BOOST_CHECK_THROW(mgr0->get_tx_subdev("x"), std::invalid_argument);
- mgr0->get_rx_subdev("a")[0];
- mgr0->get_tx_subdev("")[0];
-}
diff --git a/test/wax_test.cpp b/test/wax_test.cpp
deleted file mode 100644
index e5e1adc25..000000000
--- a/test/wax_test.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <uhd/wax.hpp>
-
-enum opt_a_t{OPTION_A_0, OPTION_A_1};
-enum opt_b_t{OPTION_B_0, OPTION_B_1};
-
-BOOST_AUTO_TEST_CASE(test_enums){
- wax::obj opta = OPTION_A_0;
- BOOST_CHECK_THROW(wax::cast<opt_b_t>(opta), wax::bad_cast);
- BOOST_CHECK_EQUAL(wax::cast<opt_a_t>(opta), OPTION_A_0);
-}
-
-/***********************************************************************
- * demo class for wax framework
- **********************************************************************/
-class wax_demo : public wax::obj{
-private:
- std::vector<float> d_nums;
- std::vector<wax_demo> d_subs;
-public:
- 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));
- }
- }
- }
- ~wax_demo(void){
- /* NOP */
- }
- void get(const wax::obj &key, wax::obj &value){
- if (d_subs.size() == 0){
- value = d_nums[wax::cast<size_t>(key)];
- }else{
- value = d_subs[wax::cast<size_t>(key)].get_link();
- }
- }
- void set(const wax::obj &key, const wax::obj &value){
- if (d_subs.size() == 0){
- d_nums[wax::cast<size_t>(key)] = wax::cast<float>(value);
- }else{
- throw std::runtime_error("cant set to a wax demo with sub demos");
- }
- }
-};
-
-static wax_demo wd(2, 10);
-
-BOOST_AUTO_TEST_CASE(test_chaining){
- std::cout << "chain 1" << std::endl;
- wd[size_t(0)];
- std::cout << "chain 2" << std::endl;
- wd[size_t(0)][size_t(0)];
- std::cout << "chain 3" << std::endl;
- wd[size_t(0)][size_t(0)][size_t(0)];
-}
-
-BOOST_AUTO_TEST_CASE(test_set_get){
- std::cout << "set and get all" << std::endl;
- for (size_t i = 0; i < 10; i++){
- for (size_t j = 0; j < 10; j++){
- for (size_t k = 0; k < 10; k++){
- float val = i * j * k + i + j + k;
- //std::cout << i << " " << j << " " << k << std::endl;
- wd[i][j][k] = val;
- BOOST_CHECK_EQUAL(val, wax::cast<float>(wd[i][j][k]));
- }
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(test_proxy){
- std::cout << "store proxy" << std::endl;
- wax::obj p = wd[size_t(0)][size_t(0)];
- p[size_t(0)] = float(5);
-
- std::cout << "assign proxy" << std::endl;
- wax::obj a = p[size_t(0)];
- BOOST_CHECK_EQUAL(wax::cast<float>(a), float(5));
-}