tests: Add a module test integration to hwsim tests

CONFIG_MODULE_TESTS=y build option can now be used to build in module
tests into hostapd and wpa_supplicant binaries. These test cases will be
used to get better testing coverage for various details that are
difficult to test otherwise through the control interface control. A
single control interface command is used to executed these tests within
the hwsim test framework. This commit adds just the new mechanism, but no
module tests are yet integrated into this mechanism.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-02-21 00:14:30 +02:00
parent da179bd0e1
commit ea449b5bfe
9 changed files with 78 additions and 0 deletions

View file

@ -70,6 +70,11 @@ NEED_SHA1=y
OBJS += ../src/drivers/drivers.o
CFLAGS += -DHOSTAPD
ifdef CONFIG_MODULE_TESTS
CFLAGS += -DCONFIG_MODULE_TESTS
OBJS += hapd_module_tests.o
endif
ifdef CONFIG_WPA_TRACE
CFLAGS += -DWPA_TRACE
OBJS += ../src/utils/trace.o

View file

@ -1650,6 +1650,12 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
} else if (os_strncmp(buf, "REMOVE ", 7) == 0) {
if (hostapd_ctrl_iface_remove(interfaces, buf + 7) < 0)
reply_len = -1;
#ifdef CONFIG_MODULE_TESTS
} else if (os_strcmp(buf, "MODULE_TESTS") == 0) {
int hapd_module_tests(void);
if (hapd_module_tests() < 0)
reply_len = -1;
#endif /* CONFIG_MODULE_TESTS */
} else {
wpa_printf(MSG_DEBUG, "Unrecognized global ctrl_iface command "
"ignored");

View file

@ -0,0 +1,17 @@
/*
* hostapd module tests
* Copyright (c) 2014, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "utils/includes.h"
#include "utils/common.h"
int hapd_module_tests(void)
{
wpa_printf(MSG_INFO, "hostapd module tests");
return 0;
}

View file

@ -70,3 +70,4 @@ CONFIG_SAE=y
CFLAGS += -DALL_DH_GROUPS
CONFIG_TESTING_OPTIONS=y
CONFIG_MODULE_TESTS=y

View file

@ -111,3 +111,4 @@ CFLAGS += -DALL_DH_GROUPS
CONFIG_WNM=y
CONFIG_TESTING_OPTIONS=y
CONFIG_MODULE_TESTS=y

View file

@ -0,0 +1,20 @@
#!/usr/bin/python
#
# Module tests
# Copyright (c) 2014, Jouni Malinen <j@w1.fi>
#
# This software may be distributed under the terms of the BSD license.
# See README for more details.
import hostapd
def test_module_wpa_supplicant(dev):
"""wpa_supplicant module tests"""
if "OK" not in dev[0].global_request("MODULE_TESTS"):
raise Exception("Module tests failed")
def test_module_hostapd(dev):
"""hostapd module tests"""
hapd_global = hostapd.HostapdGlobal()
if "OK" not in hapd_global.ctrl.request("MODULE_TESTS"):
raise Exception("Module tests failed")

View file

@ -97,6 +97,11 @@ OBJS += ../src/utils/os_$(CONFIG_OS).o
OBJS_p += ../src/utils/os_$(CONFIG_OS).o
OBJS_c += ../src/utils/os_$(CONFIG_OS).o
ifdef CONFIG_MODULE_TESTS
CFLAGS += -DCONFIG_MODULE_TESTS
OBJS += wpas_module_tests.o
endif
ifdef CONFIG_WPA_TRACE
CFLAGS += -DWPA_TRACE
OBJS += ../src/utils/trace.o

View file

@ -6761,6 +6761,12 @@ char * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global,
} else if (os_strcmp(buf, "STATUS") == 0) {
reply_len = wpas_global_ctrl_iface_status(global, reply,
reply_size);
#ifdef CONFIG_MODULE_TESTS
} else if (os_strcmp(buf, "MODULE_TESTS") == 0) {
int wpas_module_tests(void);
if (wpas_module_tests() < 0)
reply_len = -1;
#endif /* CONFIG_MODULE_TESTS */
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;

View file

@ -0,0 +1,17 @@
/*
* wpa_supplicant module tests
* Copyright (c) 2014, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "utils/includes.h"
#include "utils/common.h"
int wpas_module_tests(void)
{
wpa_printf(MSG_INFO, "wpa_supplicant module tests");
return 0;
}