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