From e9d151057d461f6fcc3d0504166cf7b27d6f7e93 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 6 Mar 2017 21:52:56 +0900 Subject: [PATCH] Implement test case for 'device' category Signed-off-by: saerome.kim --- test/mesh_device.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/test/mesh_device.c b/test/mesh_device.c index a6e2c0f..c6377c9 100644 --- a/test/mesh_device.c +++ b/test/mesh_device.c @@ -30,8 +30,6 @@ extern mesh_h mesh; extern void event_cb(mesh_event_e event_type, void* param); -static char data_mesh_interface[MENU_DATA_SIZE + 1] = "mesh0"; - static int run_mesh_create(MManager *mm, struct menu_data *menu) { int ret; @@ -92,16 +90,37 @@ static int run_mesh_disable(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } -static struct menu_data menu_mesh_enable[] = { - { "1", "interface", NULL, NULL, data_mesh_interface }, - { "2", "enable", NULL, run_mesh_enable, NULL }, +static char mesh_interface[MENU_DATA_SIZE + 1] = "wlan0"; +static char gate_interface[MENU_DATA_SIZE + 1] = "eth0"; +static char softap_interface[MENU_DATA_SIZE + 1] = "wlan1"; +static int run_mesh_set_interface(MManager *mm, struct menu_data *menu) +{ + int ret; + msg("set_interfaces"); + + ret = mesh_set_interface(mesh, mesh_interface, gate_interface, softap_interface); + if (ret != 0) { + msg("Failed to set interface: [%s(0x%X)]", + mesh_error_to_string(ret), ret); + return RET_FAILURE; + } + + return RET_SUCCESS; +} + +static struct menu_data menu_mesh_interface[] = { + { "1", "mesh", NULL, NULL, mesh_interface }, + { "2", "gate", NULL, NULL, gate_interface }, + { "3", "softap", NULL, NULL, softap_interface }, + { "4", "run", NULL, run_mesh_set_interface, NULL }, { NULL, NULL, }, }; struct menu_data menu_mesh_device[] = { - { "1", "create", NULL, run_mesh_create, NULL }, - { "2", "destroy", NULL, run_mesh_destroy, NULL }, - { "3", "enable", menu_mesh_enable, NULL, NULL }, + { "1", "initialize", NULL, run_mesh_create, NULL }, + { "2", "deinitialize", NULL, run_mesh_destroy, NULL }, + { "3", "enable", NULL, run_mesh_enable, NULL }, { "4", "disable", NULL, run_mesh_disable, NULL }, + { "5", "set_inteface", menu_mesh_interface, NULL, NULL}, { NULL, NULL, }, }; -- 2.34.1