3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-18 17:22:50 +01:00

unit: Add M1 builder unit test

This commit is contained in:
Denis Kenzior 2016-08-16 15:28:48 -05:00
parent 5f087aa0ea
commit b8e54d2834

View File

@ -623,6 +623,25 @@ static void wsc_test_parse_m1(const void *data)
assert(!memcmp(test->public_key, m1.public_key, 192));
}
static void wsc_test_build_m1(const void *data)
{
const struct m1_data *test = data;
struct wsc_m1 m1;
uint8_t *out;
size_t out_len;
memcpy(&m1, &test->expected, sizeof(m1));
memcpy(m1.public_key, test->public_key, 192);
out = wsc_build_m1(&m1, &out_len);
assert(out);
assert(out_len == test->len);
assert(!memcmp(test->pdu, out, test->len));
l_free(out);
}
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@ -649,6 +668,7 @@ int main(int argc, char *argv[])
&dh_generate_pubkey_test_data_1);
l_test_add("/wsc/parse/m1 1", wsc_test_parse_m1, &m1_data_1);
l_test_add("/wsc/build/m1 1", wsc_test_build_m1, &m1_data_1);
return l_test_run();
}