mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
unit: Add unit test for VHT RX data rate estimation
This commit is contained in:
parent
a17745661e
commit
2686baae69
1
.gitignore
vendored
1
.gitignore
vendored
@ -54,6 +54,7 @@ unit/test-eap-mschapv2
|
||||
unit/test-eap-sim
|
||||
unit/test-client
|
||||
unit/test-p2p
|
||||
unit/test-band
|
||||
unit/cert-*.pem
|
||||
unit/cert-*.csr
|
||||
unit/cert-*.srl
|
||||
|
@ -385,7 +385,7 @@ unit_tests = unit/test-cmac-aes \
|
||||
unit/test-crypto unit/test-eapol unit/test-mpdu \
|
||||
unit/test-ie unit/test-util unit/test-ssid-security \
|
||||
unit/test-arc4 unit/test-wsc unit/test-eap-mschapv2 \
|
||||
unit/test-eap-sim unit/test-sae unit/test-p2p
|
||||
unit/test-eap-sim unit/test-sae unit/test-p2p unit/test-band
|
||||
|
||||
if CLIENT
|
||||
unit_tests += unit/test-client
|
||||
@ -442,6 +442,9 @@ unit_test_kdf_sha256_LDADD = $(ell_ldadd)
|
||||
unit_test_ie_SOURCES = unit/test-ie.c src/ie.h src/ie.c
|
||||
unit_test_ie_LDADD = $(ell_ldadd)
|
||||
|
||||
unit_test_band_SOURCES = unit/test-band.c src/band.h src/band.c
|
||||
unit_test_band_LDADD = $(ell_ldadd)
|
||||
|
||||
unit_test_crypto_SOURCES = unit/test-crypto.c \
|
||||
src/crypto.h src/crypto.c
|
||||
unit_test_crypto_LDADD = $(ell_ldadd)
|
||||
|
177
unit/test-band.c
Normal file
177
unit/test-band.c
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2021 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "src/band.h"
|
||||
|
||||
static struct band *new_band()
|
||||
{
|
||||
/* Band with VHT/80, short GI, NSS:2 and VHT MCS 0-9 */
|
||||
static const uint8_t vht_mcs_set[] = {
|
||||
0xfa, 0xff, 0x00, 0x00, 0xfa, 0xff, 0x00, 0x20,
|
||||
};
|
||||
static const uint8_t vht_capabilities[] = {
|
||||
0xa0, 0x71, 0x80, 0x03,
|
||||
};
|
||||
static const uint8_t ht_mcs_set[] = {
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x2c, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const uint8_t ht_capabilities[] = {
|
||||
0xee, 0x11,
|
||||
};
|
||||
/* band + 8 basic rates */
|
||||
struct band *band = l_malloc(sizeof(struct band) + 8);
|
||||
|
||||
band->supported_rates_len = 8;
|
||||
band->supported_rates[0] = 12;
|
||||
band->supported_rates[1] = 18;
|
||||
band->supported_rates[2] = 24;
|
||||
band->supported_rates[3] = 36;
|
||||
band->supported_rates[4] = 48;
|
||||
band->supported_rates[5] = 72;
|
||||
band->supported_rates[6] = 96;
|
||||
band->supported_rates[7] = 108;
|
||||
|
||||
band->ht_supported = true;
|
||||
band->vht_supported = true;
|
||||
|
||||
memcpy(band->vht_mcs_set, vht_mcs_set, sizeof(band->vht_mcs_set));
|
||||
memcpy(band->vht_capabilities, vht_capabilities,
|
||||
sizeof(band->vht_capabilities));
|
||||
memcpy(band->ht_mcs_set, ht_mcs_set, sizeof(band->ht_mcs_set));
|
||||
memcpy(band->ht_capabilities, ht_capabilities,
|
||||
sizeof(band->ht_capabilities));
|
||||
|
||||
return band;
|
||||
}
|
||||
|
||||
static void band_test_vht_1(const void *data)
|
||||
{
|
||||
/* VHT operating on 80 Mhz */
|
||||
uint8_t vhto[] = { 192, 5, 0x01, 0x9b, 0x00, 0x00, 0x00 };
|
||||
/* VHT80, NSS:3, MCS 0-9, 80Mhz SGI */
|
||||
uint8_t vhtc[] = { 191, 12,
|
||||
0xb2, 0x59, 0x82, 0x0f, 0xea, 0xff, 0x00, 0x00,
|
||||
0xea, 0xff, 0x00, 0x00 };
|
||||
/* 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, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00 };
|
||||
struct band *band = new_band();
|
||||
uint64_t data_rate;
|
||||
int ret;
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-51, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 866666660);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-53, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 780000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-56, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 650000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-59, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 585000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-60, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 520000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-63, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 390000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-67, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 260000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-70, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 195000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-73, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 130000000);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-76, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 65000000);
|
||||
|
||||
/* We should now fall back to HT40 */
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-79, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 30000000);
|
||||
|
||||
/* And only enough for HT20 */
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-82, &data_rate);
|
||||
assert(ret == 0);
|
||||
assert(data_rate == 14444440);
|
||||
|
||||
ret = band_estimate_vht_rx_rate(band, vhtc, vhto, htc, hto,
|
||||
-83, &data_rate);
|
||||
assert(ret < 0);
|
||||
|
||||
band_free(band);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
l_test_init(&argc, &argv);
|
||||
|
||||
l_test_add("/band/VHT/test1", band_test_vht_1, NULL);
|
||||
|
||||
return l_test_run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user