aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-05-19 11:56:42 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-05-26 12:58:10 -0500
commitdbff8eaf055f8437f3db33c5f18f9fda3285d087 (patch)
treec554a17f88efddc8a271d0083a599b49902016c0 /host/tests
parent4cd86bbf2ad9db0a3fd64252f9ba2d569d48144e (diff)
downloaduhd-dbff8eaf055f8437f3db33c5f18f9fda3285d087.tar.gz
uhd-dbff8eaf055f8437f3db33c5f18f9fda3285d087.tar.bz2
uhd-dbff8eaf055f8437f3db33c5f18f9fda3285d087.zip
cal: Minor fixes in power container, add unit test
- min_power and max_power arguments were swapped. They were always called correctly, so this is more of a documentation fix. - Add a unit test for the case where power values are not regular, which is the normal case with real data.
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/cal_data_gain_pwr_test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/host/tests/cal_data_gain_pwr_test.cpp b/host/tests/cal_data_gain_pwr_test.cpp
index e066a96f3..5dd3ad8a4 100644
--- a/host/tests/cal_data_gain_pwr_test.cpp
+++ b/host/tests/cal_data_gain_pwr_test.cpp
@@ -93,6 +93,30 @@ BOOST_AUTO_TEST_CASE(test_pwr_cal_api)
BOOST_CHECK_CLOSE(gain_power_data->get_gain(-19.0, ref_freq), 1/1.1, 1e-6);
}
+BOOST_AUTO_TEST_CASE(test_pwr_cal_api_irreg)
+{
+ const std::string name = "Mock Gain/Power Data";
+ const std::string serial = "ABC1234";
+ const uint64_t timestamp = 0x12340000;
+
+ auto gain_power_data = pwr_cal::make(name, serial, timestamp);
+ constexpr int ROOM_TEMP = 20;
+ gain_power_data->set_temperature(ROOM_TEMP);
+
+ constexpr double MIN_POWER = -40;
+ constexpr double MAX_POWER = -10;
+ // Write a table...
+ gain_power_data->add_power_table(
+ {{0.0, -30.0}, {10.0, -20.0}}, MIN_POWER, MAX_POWER, 1e9);
+ // Let's say power goes down 10 dB per octave
+ gain_power_data->add_power_table(
+ {{0.0, -40.0}, {10.0, -30.0}}, MIN_POWER, MAX_POWER, 2e9);
+ // Interpolated readback:
+ BOOST_CHECK_CLOSE(gain_power_data->get_power(5.0, 1.5e9), -30.0, 1e-6);
+ BOOST_CHECK_CLOSE(gain_power_data->get_gain(-30.0, 1.5e9), 5.0, 0.1);
+
+}
+
BOOST_AUTO_TEST_CASE(test_pwr_cal_serdes)
{
const std::string name = "Mock Gain/Power Data";