]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add unit tests for ext_password
authorJouni Malinen <j@w1.fi>
Mon, 26 May 2014 20:57:32 +0000 (23:57 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 26 May 2014 20:57:32 +0000 (23:57 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/utils_module_tests.c

index d514c546ebc78eebdeeffd561a2cb5d5f6d4f059..1e16090f3965caf04054da35a4feb3fda4a5beea 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "utils/common.h"
 #include "utils/bitfield.h"
+#include "utils/ext_password.h"
 
 
 struct printf_test_data {
@@ -188,6 +189,37 @@ static int int_array_tests(void)
 }
 
 
+static int ext_password_tests(void)
+{
+       struct ext_password_data *data;
+       int ret = 0;
+       struct wpabuf *pw;
+
+       wpa_printf(MSG_INFO, "ext_password tests");
+
+       data = ext_password_init("unknown", "foo");
+       if (data != NULL)
+               return -1;
+
+       data = ext_password_init("test", NULL);
+       if (data == NULL)
+               return -1;
+       pw = ext_password_get(data, "foo");
+       if (pw != NULL)
+               ret = -1;
+       ext_password_free(pw);
+
+       ext_password_deinit(data);
+
+       pw = ext_password_get(NULL, "foo");
+       if (pw != NULL)
+               ret = -1;
+       ext_password_free(pw);
+
+       return ret;
+}
+
+
 int utils_module_tests(void)
 {
        int ret = 0;
@@ -195,6 +227,7 @@ int utils_module_tests(void)
        wpa_printf(MSG_INFO, "utils module tests");
 
        if (printf_encode_decode_tests() < 0 ||
+           ext_password_tests() < 0 ||
            bitfield_tests() < 0 ||
            int_array_tests() < 0)
                ret = -1;