15b9c547cSRui Paulo /* 25b9c547cSRui Paulo * wpa_supplicant module tests 35b9c547cSRui Paulo * Copyright (c) 2014, Jouni Malinen <j@w1.fi> 45b9c547cSRui Paulo * 55b9c547cSRui Paulo * This software may be distributed under the terms of the BSD license. 65b9c547cSRui Paulo * See README for more details. 75b9c547cSRui Paulo */ 85b9c547cSRui Paulo 95b9c547cSRui Paulo #include "utils/includes.h" 105b9c547cSRui Paulo 115b9c547cSRui Paulo #include "utils/common.h" 12780fb4a2SCy Schubert #include "utils/module_tests.h" 135b9c547cSRui Paulo #include "wpa_supplicant_i.h" 14*c1d255d3SCy Schubert #include "bssid_ignore.h" 155b9c547cSRui Paulo 165b9c547cSRui Paulo 17*c1d255d3SCy Schubert static int wpas_bssid_ignore_module_tests(void) 185b9c547cSRui Paulo { 195b9c547cSRui Paulo struct wpa_supplicant wpa_s; 205b9c547cSRui Paulo int ret = -1; 215b9c547cSRui Paulo 225b9c547cSRui Paulo os_memset(&wpa_s, 0, sizeof(wpa_s)); 235b9c547cSRui Paulo 24*c1d255d3SCy Schubert wpa_bssid_ignore_clear(&wpa_s); 255b9c547cSRui Paulo 26*c1d255d3SCy Schubert if (wpa_bssid_ignore_get(NULL, NULL) != NULL || 27*c1d255d3SCy Schubert wpa_bssid_ignore_get(NULL, (u8 *) "123456") != NULL || 28*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, NULL) != NULL || 29*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, (u8 *) "123456") != NULL) 305b9c547cSRui Paulo goto fail; 315b9c547cSRui Paulo 32*c1d255d3SCy Schubert if (wpa_bssid_ignore_add(NULL, NULL) == 0 || 33*c1d255d3SCy Schubert wpa_bssid_ignore_add(NULL, (u8 *) "123456") == 0 || 34*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, NULL) == 0) 355b9c547cSRui Paulo goto fail; 365b9c547cSRui Paulo 37*c1d255d3SCy Schubert if (wpa_bssid_ignore_del(NULL, NULL) == 0 || 38*c1d255d3SCy Schubert wpa_bssid_ignore_del(NULL, (u8 *) "123456") == 0 || 39*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, NULL) == 0 || 40*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "123456") == 0) 415b9c547cSRui Paulo goto fail; 425b9c547cSRui Paulo 43*c1d255d3SCy Schubert if (wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 || 44*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 || 45*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 || 46*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0 || 47*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "444444") < 0 || 48*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "333333") < 0 || 49*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "xxxxxx") == 0 || 50*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, (u8 *) "xxxxxx") != NULL || 51*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, (u8 *) "111111") == NULL || 52*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, (u8 *) "222222") == NULL || 53*c1d255d3SCy Schubert wpa_bssid_ignore_get(&wpa_s, (u8 *) "444444") == NULL || 54*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "111111") < 0 || 55*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "222222") < 0 || 56*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "444444") < 0 || 57*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 || 58*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 || 59*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0) 60*c1d255d3SCy Schubert goto fail; 61*c1d255d3SCy Schubert 62*c1d255d3SCy Schubert wpa_bssid_ignore_clear(&wpa_s); 63*c1d255d3SCy Schubert 64*c1d255d3SCy Schubert if (wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 || 65*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 || 66*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0 || 67*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "444444") < 0 || 68*c1d255d3SCy Schubert !wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111") || 69*c1d255d3SCy Schubert wpa_bssid_ignore_del(&wpa_s, (u8 *) "111111") < 0 || 70*c1d255d3SCy Schubert wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111") || 71*c1d255d3SCy Schubert wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0) 72*c1d255d3SCy Schubert goto fail; 73*c1d255d3SCy Schubert 74*c1d255d3SCy Schubert wpa_bssid_ignore_update(&wpa_s); 75*c1d255d3SCy Schubert 76*c1d255d3SCy Schubert if (!wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111")) 775b9c547cSRui Paulo goto fail; 785b9c547cSRui Paulo 795b9c547cSRui Paulo ret = 0; 805b9c547cSRui Paulo fail: 81*c1d255d3SCy Schubert wpa_bssid_ignore_clear(&wpa_s); 825b9c547cSRui Paulo 835b9c547cSRui Paulo if (ret) 84*c1d255d3SCy Schubert wpa_printf(MSG_ERROR, "bssid_ignore module test failure"); 855b9c547cSRui Paulo 865b9c547cSRui Paulo return ret; 875b9c547cSRui Paulo } 885b9c547cSRui Paulo 895b9c547cSRui Paulo 905b9c547cSRui Paulo int wpas_module_tests(void) 915b9c547cSRui Paulo { 925b9c547cSRui Paulo int ret = 0; 935b9c547cSRui Paulo 945b9c547cSRui Paulo wpa_printf(MSG_INFO, "wpa_supplicant module tests"); 955b9c547cSRui Paulo 96*c1d255d3SCy Schubert if (wpas_bssid_ignore_module_tests() < 0) 975b9c547cSRui Paulo ret = -1; 985b9c547cSRui Paulo 995b9c547cSRui Paulo #ifdef CONFIG_WPS 1005b9c547cSRui Paulo if (wps_module_tests() < 0) 1015b9c547cSRui Paulo ret = -1; 1025b9c547cSRui Paulo #endif /* CONFIG_WPS */ 1035b9c547cSRui Paulo 1045b9c547cSRui Paulo if (utils_module_tests() < 0) 1055b9c547cSRui Paulo ret = -1; 1065b9c547cSRui Paulo 1075b9c547cSRui Paulo if (common_module_tests() < 0) 1085b9c547cSRui Paulo ret = -1; 1095b9c547cSRui Paulo 1105b9c547cSRui Paulo if (crypto_module_tests() < 0) 1115b9c547cSRui Paulo ret = -1; 1125b9c547cSRui Paulo 1135b9c547cSRui Paulo return ret; 1145b9c547cSRui Paulo } 115