aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2015-03-05 14:16:04 -0800
committerDmitry Shmidt <dimitrysh@google.com>2015-03-10 11:04:48 -0700
commit203eadb9eda41a1dde4a583edb4684319e3f399e (patch)
tree3b91f63844f16aeca8e1e122ef4c6d49f8164b17 /src/utils
parent34c1202b3e71c63661a850aad81f663e40e48ca1 (diff)
downloadandroid_external_wpa_supplicant_8-203eadb9eda41a1dde4a583edb4684319e3f399e.tar.gz
android_external_wpa_supplicant_8-203eadb9eda41a1dde4a583edb4684319e3f399e.tar.bz2
android_external_wpa_supplicant_8-203eadb9eda41a1dde4a583edb4684319e3f399e.zip
Cumulative patch from commit 6e9023ea499ea9a89b0e858c85e32b455d57264c
6e9023e DFS: Allow wpa_supplicant AP mode to use non-offloaded DFS 02e42ab nl80211: Add vendor event parsing for DFS offload events bd0f68c DFS: wpa_supplicant event processing d7f1aa8 DFS offload: P2P changes for autonomous GO 1e2aaff DFS offload: Indicate AP-CSA-FINISHED for DFS offloaded case c13578c DFS offload: Add main DFS handler for offloaded case 5de81d7 DFS offload: Skip user space processing for CAC operations 192ad3d Interworking: Clear SCANNING state if no match found 95d7b86 P2P: Consider 5 GHz channels also for auto GO a51c40a P2P: Fix regression in start-GO/AP through a "fake" scan dd5c155 eap_proxy: Callback to notify any updates from eap_proxy 9a05d98 atheros: Add a new flag for OSEN support 9feadba Remove unnecessary NULL check to make function more consistent 1772d34 P2P: Fix interface deinit for failed group interface initialization 3f9ebc4 P2P: Allow AP/GO interface to be started while P2P-in-progress b4a9292 RADIUS client: Fix server failover on return-to-primary on error case 9836cb5 Add option to force a specific RADIUS client address to be used 1a7ed38 RADIUS client: Fix a copy-paste error in accounting server failover de7c06e P2P: Continue find in GO-Neg-Resp-fail status corner cases c280590 Do not add blacklist entries based on normal disconnect request cases bdf0518 P2P: Direct P2P_CONNECT command to proper interface 44b9ea5 P2P: Do not allow scan or normal association on cfg80211 P2P Device 9542f21 Clean up p2p_find command parsing and execution fa9f381 P2P: Allow a specific channel to be specified in P2P_FIND eb78a8d P2P: Restore P2P_SCAN_SPECIFIC d988ff7 hostapd: Disable VHT caps for STAs when no valid VHT MCS found 70fd828 RADIUS client: Fix previous failover change c3dabf5 Fix merge issue with IBSS VHT support 8b2b718 Fix minor issue in HT40 max rate determination 347c55e RADIUS client: Re-try connection if socket is closed on retransmit 94b39e5 RADIUS client: Fix server connection recovery after initial failure bbee36e Allow RADIUS server address to be replaced efb4008 TLS: Remove placeholders for SIGN_ALG_DSA support Change-Id: I8e5d0dfd5fddb6de2f8d8211b708c3bb6674098b Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/utils_module_tests.c159
1 files changed, 158 insertions, 1 deletions
diff --git a/src/utils/utils_module_tests.c b/src/utils/utils_module_tests.c
index 9a9ec400..4b97dadd 100644
--- a/src/utils/utils_module_tests.c
+++ b/src/utils/utils_module_tests.c
@@ -1,6 +1,6 @@
/*
* utils module tests
- * Copyright (c) 2014, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2014-2015, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -12,6 +12,7 @@
#include "utils/bitfield.h"
#include "utils/ext_password.h"
#include "utils/trace.h"
+#include "utils/base64.h"
struct printf_test_data {
@@ -84,6 +85,15 @@ static int printf_encode_decode_tests(void)
}
}
+ if (printf_decode(bin, 3, "abcde") != 2)
+ errors++;
+
+ if (printf_decode(bin, 3, "\\xa") != 1 || bin[0] != 10)
+ errors++;
+
+ if (printf_decode(bin, 3, "\\a") != 1 || bin[0] != 'a')
+ errors++;
+
if (errors) {
wpa_printf(MSG_ERROR, "%d printf test(s) failed", errors);
return -1;
@@ -167,6 +177,17 @@ static int bitfield_tests(void)
bitfield_free(bf);
+ bf = bitfield_alloc(8);
+ if (bf == NULL)
+ return -1;
+ if (bitfield_get_first_zero(bf) != 0)
+ errors++;
+ for (i = 0; i < 8; i++)
+ bitfield_set(bf, i);
+ if (bitfield_get_first_zero(bf) != -1)
+ errors++;
+ bitfield_free(bf);
+
if (errors) {
wpa_printf(MSG_ERROR, "%d bitfield test(s) failed", errors);
return -1;
@@ -249,6 +270,140 @@ static int trace_tests(void)
}
+static int base64_tests(void)
+{
+ int errors = 0;
+ unsigned char *res;
+ size_t res_len;
+
+ wpa_printf(MSG_INFO, "base64 tests");
+
+ res = base64_encode((const unsigned char *) "", ~0, &res_len);
+ if (res) {
+ errors++;
+ os_free(res);
+ }
+
+ res = base64_encode((const unsigned char *) "=", 1, &res_len);
+ if (!res || res_len != 5 || res[0] != 'P' || res[1] != 'Q' ||
+ res[2] != '=' || res[3] != '=' || res[4] != '\n')
+ errors++;
+ os_free(res);
+
+ res = base64_encode((const unsigned char *) "=", 1, NULL);
+ if (!res || res[0] != 'P' || res[1] != 'Q' ||
+ res[2] != '=' || res[3] != '=' || res[4] != '\n')
+ errors++;
+ os_free(res);
+
+ res = base64_decode((const unsigned char *) "", 0, &res_len);
+ if (res) {
+ errors++;
+ os_free(res);
+ }
+
+ res = base64_decode((const unsigned char *) "a", 1, &res_len);
+ if (res) {
+ errors++;
+ os_free(res);
+ }
+
+ res = base64_decode((const unsigned char *) "====", 4, &res_len);
+ if (res) {
+ errors++;
+ os_free(res);
+ }
+
+ res = base64_decode((const unsigned char *) "PQ==", 4, &res_len);
+ if (!res || res_len != 1 || res[0] != '=')
+ errors++;
+ os_free(res);
+
+ res = base64_decode((const unsigned char *) "P.Q-=!=*", 8, &res_len);
+ if (!res || res_len != 1 || res[0] != '=')
+ errors++;
+ os_free(res);
+
+ if (errors) {
+ wpa_printf(MSG_ERROR, "%d base64 test(s) failed", errors);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int common_tests(void)
+{
+ char buf[3];
+ u8 addr[ETH_ALEN] = { 1, 2, 3, 4, 5, 6 };
+ u8 bin[3];
+ int errors = 0;
+ struct wpa_freq_range_list ranges;
+
+ wpa_printf(MSG_INFO, "common tests");
+
+ if (hwaddr_mask_txt(buf, 3, addr, addr) != -1)
+ errors++;
+
+ if (wpa_scnprintf(buf, 0, "hello") != 0 ||
+ wpa_scnprintf(buf, 3, "hello") != 2)
+ errors++;
+
+ if (wpa_snprintf_hex(buf, 0, addr, ETH_ALEN) != 0 ||
+ wpa_snprintf_hex(buf, 3, addr, ETH_ALEN) != 2)
+ errors++;
+
+ if (merge_byte_arrays(bin, 3, addr, ETH_ALEN, NULL, 0) != 3 ||
+ merge_byte_arrays(bin, 3, NULL, 0, addr, ETH_ALEN) != 3)
+ errors++;
+
+ if (dup_binstr(NULL, 0) != NULL)
+ errors++;
+
+ if (freq_range_list_includes(NULL, 0) != 0)
+ errors++;
+
+ os_memset(&ranges, 0, sizeof(ranges));
+ if (freq_range_list_parse(&ranges, "") != 0 ||
+ freq_range_list_includes(&ranges, 0) != 0 ||
+ freq_range_list_str(&ranges) != NULL)
+ errors++;
+
+ if (utf8_unescape(NULL, 0, buf, sizeof(buf)) != 0 ||
+ utf8_unescape("a", 1, NULL, 0) != 0 ||
+ utf8_unescape("a\\", 2, buf, sizeof(buf)) != 0 ||
+ utf8_unescape("abcde", 5, buf, sizeof(buf)) != 0 ||
+ utf8_unescape("abc", 3, buf, 3) != 3)
+ errors++;
+
+ if (utf8_unescape("a", 0, buf, sizeof(buf)) != 1 || buf[0] != 'a')
+ errors++;
+
+ if (utf8_unescape("\\b", 2, buf, sizeof(buf)) != 1 || buf[0] != 'b')
+ errors++;
+
+ if (utf8_escape(NULL, 0, buf, sizeof(buf)) != 0 ||
+ utf8_escape("a", 1, NULL, 0) != 0 ||
+ utf8_escape("abcde", 5, buf, sizeof(buf)) != 0 ||
+ utf8_escape("a\\bcde", 6, buf, sizeof(buf)) != 0 ||
+ utf8_escape("ab\\cde", 6, buf, sizeof(buf)) != 0 ||
+ utf8_escape("abc\\de", 6, buf, sizeof(buf)) != 0 ||
+ utf8_escape("abc", 3, buf, 3) != 3)
+ errors++;
+
+ if (utf8_escape("a", 0, buf, sizeof(buf)) != 1 || buf[0] != 'a')
+ errors++;
+
+ if (errors) {
+ wpa_printf(MSG_ERROR, "%d common test(s) failed", errors);
+ return -1;
+ }
+
+ return 0;
+}
+
+
int utils_module_tests(void)
{
int ret = 0;
@@ -259,6 +414,8 @@ int utils_module_tests(void)
ext_password_tests() < 0 ||
trace_tests() < 0 ||
bitfield_tests() < 0 ||
+ base64_tests() < 0 ||
+ common_tests() < 0 ||
int_array_tests() < 0)
ret = -1;