mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
unit: Refactor IE reader test
Use real beacon frame data when testing the IE reader API.
This commit is contained in:
parent
999ba12f31
commit
8cb16f41a8
@ -44,7 +44,7 @@ struct ie {
|
||||
unsigned char value[];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static void ie_test(const void *data)
|
||||
static void ie_test_reader(const void *data)
|
||||
{
|
||||
const struct test_data *test = data;
|
||||
struct ie_tlv_iter iter;
|
||||
@ -71,22 +71,54 @@ static void ie_test(const void *data)
|
||||
assert(count == test->num_ie);
|
||||
}
|
||||
|
||||
static struct ie ie_ssid = {
|
||||
.type = IE_TYPE_SSID,
|
||||
.len = 10,
|
||||
.value = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' },
|
||||
};
|
||||
|
||||
static struct ie ie_supp_channels = {
|
||||
.type = IE_TYPE_SUPPORTED_CHANNELS,
|
||||
.len = 2,
|
||||
.value = "\x01\x02",
|
||||
};
|
||||
static unsigned char beacon_frame[] = {
|
||||
/* IEEE 802.11 Beacon frame */
|
||||
0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xc8, 0xd7, 0x19, 0x39, 0xbe, 0x77,
|
||||
0xc8, 0xd7, 0x19, 0x39, 0xbe, 0x77, 0x50, 0xa2,
|
||||
|
||||
static struct ie ie_qos = {
|
||||
.type = IE_TYPE_QOS_CAPABILITY,
|
||||
.len = 1,
|
||||
.value = "\x81",
|
||||
/* IEEE 802.11 wireless LAN managment frame
|
||||
* - Fixed parameters (12 bytes)
|
||||
*/
|
||||
0x87, 0x81, 0x31, 0xe6, 0x29, 0x02, 0x00, 0x00,
|
||||
0x64, 0x00, 0x11, 0x00,
|
||||
|
||||
/* - Tagged parameters (TLV format, 252 bytes).
|
||||
* This starts at byte position 36
|
||||
*/
|
||||
0x00, 0x0c, 0x57, 0x65, 0x73, 0x31, 0x4f, 0x70,
|
||||
0x65, 0x6e, 0x57, 0x4c, 0x41, 0x4e, 0x01, 0x08,
|
||||
0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c,
|
||||
0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x30, 0x14,
|
||||
0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00,
|
||||
0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f,
|
||||
0xac, 0x02, 0x0c, 0x00, 0x0b, 0x05, 0x02, 0x00,
|
||||
0x02, 0x00, 0x00, 0x2d, 0x1a, 0x6f, 0x08, 0x17,
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d,
|
||||
0x16, 0x24, 0x0d, 0x16, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a,
|
||||
0x0e, 0x14, 0x00, 0x0a, 0x00, 0x2c, 0x01, 0xc8,
|
||||
0x00, 0x14, 0x00, 0x05, 0x00, 0x19, 0x00, 0x7f,
|
||||
0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0xbf, 0x0c, 0x32, 0x58, 0x82, 0x0f, 0xea,
|
||||
0xff, 0x00, 0x00, 0xea, 0xff, 0x00, 0x00, 0xc0,
|
||||
0x05, 0x01, 0x2a, 0x00, 0x00, 0x00, 0xc3, 0x04,
|
||||
0x02, 0x02, 0x02, 0x02, 0xdd, 0x31, 0x00, 0x50,
|
||||
0xf2, 0x04, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10,
|
||||
0x44, 0x00, 0x01, 0x02, 0x10, 0x47, 0x00, 0x10,
|
||||
0x98, 0x42, 0x13, 0x05, 0x23, 0x6e, 0xde, 0x3a,
|
||||
0xfa, 0x13, 0x0a, 0x79, 0x44, 0x0f, 0xab, 0x43,
|
||||
0x10, 0x3c, 0x00, 0x01, 0x03, 0x10, 0x49, 0x00,
|
||||
0x06, 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20, 0xdd,
|
||||
0x09, 0x00, 0x10, 0x18, 0x02, 0x02, 0x00, 0x1c,
|
||||
0x00, 0x00, 0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02,
|
||||
0x01, 0x01, 0x80, 0x00, 0x03, 0xa4, 0x00, 0x00,
|
||||
0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00,
|
||||
0x62, 0x32, 0x2f, 0x00, 0x01, 0x9a, 0xc1, 0xc8,
|
||||
};
|
||||
|
||||
static unsigned char *append_data(unsigned char *buf, struct ie *ie,
|
||||
@ -107,18 +139,14 @@ static unsigned char *append_data(unsigned char *buf, struct ie *ie,
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct test_data tc1;
|
||||
struct test_data tc1 = { 0 };
|
||||
|
||||
l_test_init(&argc, &argv);
|
||||
|
||||
memset(&tc1, 0, sizeof(tc1));
|
||||
tc1.buf = append_data(tc1.buf, &ie_ssid, &tc1.len);
|
||||
tc1.num_ie++;
|
||||
tc1.buf = append_data(tc1.buf, &ie_supp_channels, &tc1.len);
|
||||
tc1.num_ie++;
|
||||
tc1.buf = append_data(tc1.buf, &ie_qos, &tc1.len);
|
||||
tc1.num_ie++;
|
||||
l_test_add("/ie/IE", ie_test, &tc1);
|
||||
tc1.buf = &beacon_frame[36];
|
||||
tc1.num_ie = 15;
|
||||
tc1.len = 252;
|
||||
l_test_add("/ie/reader/static", ie_test_reader, &tc1);
|
||||
|
||||
return l_test_run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user