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