1*5b9c547cSRui Paulo /* 2*5b9c547cSRui Paulo * wpa_supplicant module tests 3*5b9c547cSRui Paulo * Copyright (c) 2014, Jouni Malinen <j@w1.fi> 4*5b9c547cSRui Paulo * 5*5b9c547cSRui Paulo * This software may be distributed under the terms of the BSD license. 6*5b9c547cSRui Paulo * See README for more details. 7*5b9c547cSRui Paulo */ 8*5b9c547cSRui Paulo 9*5b9c547cSRui Paulo #include "utils/includes.h" 10*5b9c547cSRui Paulo 11*5b9c547cSRui Paulo #include "utils/common.h" 12*5b9c547cSRui Paulo #include "wpa_supplicant_i.h" 13*5b9c547cSRui Paulo #include "blacklist.h" 14*5b9c547cSRui Paulo 15*5b9c547cSRui Paulo 16*5b9c547cSRui Paulo static int wpas_blacklist_module_tests(void) 17*5b9c547cSRui Paulo { 18*5b9c547cSRui Paulo struct wpa_supplicant wpa_s; 19*5b9c547cSRui Paulo int ret = -1; 20*5b9c547cSRui Paulo 21*5b9c547cSRui Paulo os_memset(&wpa_s, 0, sizeof(wpa_s)); 22*5b9c547cSRui Paulo 23*5b9c547cSRui Paulo wpa_blacklist_clear(&wpa_s); 24*5b9c547cSRui Paulo 25*5b9c547cSRui Paulo if (wpa_blacklist_get(NULL, NULL) != NULL || 26*5b9c547cSRui Paulo wpa_blacklist_get(NULL, (u8 *) "123456") != NULL || 27*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, NULL) != NULL || 28*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, (u8 *) "123456") != NULL) 29*5b9c547cSRui Paulo goto fail; 30*5b9c547cSRui Paulo 31*5b9c547cSRui Paulo if (wpa_blacklist_add(NULL, NULL) == 0 || 32*5b9c547cSRui Paulo wpa_blacklist_add(NULL, (u8 *) "123456") == 0 || 33*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, NULL) == 0) 34*5b9c547cSRui Paulo goto fail; 35*5b9c547cSRui Paulo 36*5b9c547cSRui Paulo if (wpa_blacklist_del(NULL, NULL) == 0 || 37*5b9c547cSRui Paulo wpa_blacklist_del(NULL, (u8 *) "123456") == 0 || 38*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, NULL) == 0 || 39*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "123456") == 0) 40*5b9c547cSRui Paulo goto fail; 41*5b9c547cSRui Paulo 42*5b9c547cSRui Paulo if (wpa_blacklist_add(&wpa_s, (u8 *) "111111") < 0 || 43*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "111111") < 0 || 44*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "222222") < 0 || 45*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "333333") < 0 || 46*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "444444") < 0 || 47*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "333333") < 0 || 48*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "xxxxxx") == 0 || 49*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, (u8 *) "xxxxxx") != NULL || 50*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, (u8 *) "111111") == NULL || 51*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, (u8 *) "222222") == NULL || 52*5b9c547cSRui Paulo wpa_blacklist_get(&wpa_s, (u8 *) "444444") == NULL || 53*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "111111") < 0 || 54*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "222222") < 0 || 55*5b9c547cSRui Paulo wpa_blacklist_del(&wpa_s, (u8 *) "444444") < 0 || 56*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "111111") < 0 || 57*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "222222") < 0 || 58*5b9c547cSRui Paulo wpa_blacklist_add(&wpa_s, (u8 *) "333333") < 0) 59*5b9c547cSRui Paulo goto fail; 60*5b9c547cSRui Paulo 61*5b9c547cSRui Paulo ret = 0; 62*5b9c547cSRui Paulo fail: 63*5b9c547cSRui Paulo wpa_blacklist_clear(&wpa_s); 64*5b9c547cSRui Paulo 65*5b9c547cSRui Paulo if (ret) 66*5b9c547cSRui Paulo wpa_printf(MSG_ERROR, "blacklist module test failure"); 67*5b9c547cSRui Paulo 68*5b9c547cSRui Paulo return ret; 69*5b9c547cSRui Paulo } 70*5b9c547cSRui Paulo 71*5b9c547cSRui Paulo 72*5b9c547cSRui Paulo int wpas_module_tests(void) 73*5b9c547cSRui Paulo { 74*5b9c547cSRui Paulo int ret = 0; 75*5b9c547cSRui Paulo 76*5b9c547cSRui Paulo wpa_printf(MSG_INFO, "wpa_supplicant module tests"); 77*5b9c547cSRui Paulo 78*5b9c547cSRui Paulo if (wpas_blacklist_module_tests() < 0) 79*5b9c547cSRui Paulo ret = -1; 80*5b9c547cSRui Paulo 81*5b9c547cSRui Paulo #ifdef CONFIG_WPS 82*5b9c547cSRui Paulo { 83*5b9c547cSRui Paulo int wps_module_tests(void); 84*5b9c547cSRui Paulo if (wps_module_tests() < 0) 85*5b9c547cSRui Paulo ret = -1; 86*5b9c547cSRui Paulo } 87*5b9c547cSRui Paulo #endif /* CONFIG_WPS */ 88*5b9c547cSRui Paulo 89*5b9c547cSRui Paulo { 90*5b9c547cSRui Paulo int utils_module_tests(void); 91*5b9c547cSRui Paulo if (utils_module_tests() < 0) 92*5b9c547cSRui Paulo ret = -1; 93*5b9c547cSRui Paulo } 94*5b9c547cSRui Paulo 95*5b9c547cSRui Paulo { 96*5b9c547cSRui Paulo int common_module_tests(void); 97*5b9c547cSRui Paulo if (common_module_tests() < 0) 98*5b9c547cSRui Paulo ret = -1; 99*5b9c547cSRui Paulo } 100*5b9c547cSRui Paulo 101*5b9c547cSRui Paulo { 102*5b9c547cSRui Paulo int crypto_module_tests(void); 103*5b9c547cSRui Paulo if (crypto_module_tests() < 0) 104*5b9c547cSRui Paulo ret = -1; 105*5b9c547cSRui Paulo } 106*5b9c547cSRui Paulo 107*5b9c547cSRui Paulo return ret; 108*5b9c547cSRui Paulo } 109