commit 3450bca6954e97dcd32299859f7f6f66e82c15dc
parent 575f603f8978c4bba23d4f7d0dc2947200d8f462
Author: Denis Kenzior <denkenz@gmail.com>
Date: Thu, 3 Jun 2021 15:45:57 -0500
unit: Add unit test for HT RX data rate estimation
Diffstat:
| M | unit/test-band.c | | | 62 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 62 insertions(+), 0 deletions(-)
diff --git a/unit/test-band.c b/unit/test-band.c
@@ -75,6 +75,66 @@ static struct band *new_band()
return band;
}
+static void band_test_ht_1(const void *data)
+{
+ /* HT40 */
+ uint8_t hto[] = { 61, 22,
+ 0x95, 0x0d, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ /* HT40, MCS 0-23, 40/20Mhz SGI */
+ uint8_t htc[] = { 45, 26,
+ 0xef, 0x09, 0x17, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+ struct band *band = new_band();
+ uint64_t data_rate;
+ int ret;
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -51, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 300000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -62, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 270000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -63, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 240000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -66, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 180000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -71, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 120000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -74, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 90000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -76, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 60000000);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -79, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 30000000);
+
+ /* We should now fall back to HT20 */
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -82, &data_rate);
+ assert(ret == 0);
+ assert(data_rate == 14444440);
+
+ ret = band_estimate_ht_rx_rate(band, htc, hto, -83, &data_rate);
+ assert(ret < 0);
+
+ band_free(band);
+}
+
static void band_test_vht_1(const void *data)
{
/* VHT operating on 80 Mhz */
@@ -171,6 +231,8 @@ int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
+ l_test_add("/band/HT/test1", band_test_ht_1, NULL);
+
l_test_add("/band/VHT/test1", band_test_vht_1, NULL);
return l_test_run();