Commit 3c07e85a authored by Omar Kallel's avatar Omar Kallel

add logs

parent 76d8564e
Pipeline #11818 passed with stages
in 2 minutes and 47 seconds
......@@ -9,6 +9,7 @@
#include "event.h"
#include "xml.h"
#include "session.h"
#include "log.h"
struct cwmp cwmp_main_test = {0};
struct cwmp *cwmp_test;
......@@ -20,6 +21,10 @@ void dm_delete_object_test(void **state);
void dm_get_parameter_names_test(void **state);
void dm_get_parameter_attributes_test(void **state);
void dm_set_parameter_attributes_test(void **state);
void get_config_test(void **state);
void get_deviceid_test(void **state);
void add_event_test(void **state);
void soap_inform_message_test(void **state);
/*
* datamodel interface tests
......@@ -34,6 +39,7 @@ void dm_get_parameter_values_test(void **state)
*/
fault = cwmp_get_parameter_values("Device.DeviceInfo.UpTime",
&parameters);
CWMP_LOG(INFO, "%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
assert_non_null(parameters);
first_parameter = json_object_array_get_idx(parameters, 0);
......@@ -90,6 +96,7 @@ void dm_set_multiple_parameter_values_test(void **state)
cwmp_add_list_param_value("Device.WiFi.SSID.1.Alias", "wifi_alias_1", &list_set_param_value);
cwmp_transaction_start("cwmp");
fault = cwmp_set_multiple_parameters_values(list_set_param_value, "set_wifi_ssid_alias", &flag, &faults_array);
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
assert_in_set(flag, flag_values, 15);
assert_null(faults_array);
......@@ -221,7 +228,9 @@ void dm_add_object_test(void **state)
cwmp_transaction_start("cwmp");
fault = cwmp_add_object("Device.WiFi.SSID.", "add_ssid", &instance);
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, instance);
assert_non_null(instance);
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
cwmp_transaction_commit();
......@@ -247,6 +256,7 @@ void dm_delete_object_test(void **state)
cwmp_transaction_start("cwmp");
fault = cwmp_delete_object("Device.WiFi.SSID.3.", "del_ssid");
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_non_null(instance);
assert_null(fault);
cwmp_transaction_commit();
......@@ -275,7 +285,9 @@ void dm_get_parameter_names_test(void **state)
* Valid multi-instance object path
*/
fault = cwmp_get_parameter_names("Device.WiFi.SSID.", true, &parameters);
printf("%s:%s line %d %p\n", __FILE__, __FUNCTION__, __LINE__, parameters);
assert_non_null(parameters);
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
first_object = json_object_array_get_idx(parameters, 0);
assert_non_null(first_object);
......@@ -320,6 +332,7 @@ void dm_set_parameter_attributes_test(void **state)
*/
cwmp_transaction_start("cwmp");
fault = cwmp_set_parameter_attributes("Device.DeviceInfo.UpTime", "1");
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
cwmp_transaction_commit();
......@@ -349,6 +362,7 @@ void dm_get_parameter_attributes_test(void **state)
* Test of valid parameter path
*/
fault = cwmp_get_parameter_attributes("Device.DeviceInfo.ProvisioningCode", &parameters);
printf("%s:%s line %d %s\n", __FILE__, __FUNCTION__, __LINE__, fault);
assert_null(fault);
assert_non_null(parameters);
first_parameter = json_object_array_get_idx(parameters, 0);
......@@ -391,6 +405,70 @@ void dm_get_parameter_attributes_test(void **state)
assert_string_equal(fault, "9005");
}
/*
* SOAP TESTS
*/
void get_config_test(void **state)
{
struct cwmp *cwmp_test = &cwmp_main_test;
int error = get_global_config(&(cwmp_test->conf));
assert_int_equal(error, CWMP_OK);
}
void get_deviceid_test(void **state)
{
struct cwmp *cwmp_test = &cwmp_main_test;
int error = cwmp_get_deviceid(cwmp_test);
assert_int_equal(error, CWMP_OK);
}
void add_event_test(void **state)
{
struct event_container *event_container;
event_container = cwmp_add_event_container(cwmp_test, EVENT_IDX_1BOOT, "");
assert_non_null(event_container);
assert_string_equal(EVENT_CONST[event_container->code].CODE, "1 BOOT");
}
void soap_inform_message_test(void **state)
{
struct session *session;
mxml_node_t *env = NULL, *n = NULL, *device_id = NULL, *cwmp_inform = NULL;
memcpy(&(cwmp_test->env), &cwmp_test, sizeof(struct env));
INIT_LIST_HEAD(&(session->head_event_container));
session = list_entry((&(cwmp_test->head_session_queue))->next, struct session, list);
struct rpc *rpc_acs;
rpc_acs = list_entry(&(session->head_rpc_acs), struct rpc, list);
cwmp_rpc_acs_prepare_message_inform(cwmp_test, session, rpc_acs);
env = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Envelope", NULL, NULL, MXML_DESCEND);
assert_non_null(env);
n = mxmlFindElement(env, env, "soap_env:Header", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(n, n, "cwmp:ID", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(env, env, "soap_env:Body", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
cwmp_inform = mxmlFindElement(env, env, "cwmp:Inform", NULL, NULL, MXML_DESCEND);
assert_non_null(cwmp_inform);
device_id = mxmlFindElement(cwmp_inform, cwmp_inform, "DeviceId", NULL, NULL, MXML_DESCEND);
assert_non_null(device_id);
n = mxmlFindElement(device_id, device_id, "Manufacturer", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(device_id, device_id, "OUI", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(device_id, device_id, "ProductClass", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(device_id, device_id, "SerialNumber", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(cwmp_inform, cwmp_inform, "Event", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
n = mxmlFindElement(cwmp_inform, cwmp_inform, "ParameterList", NULL, NULL, MXML_DESCEND);
assert_non_null(n);
}
int main(void)
{
cwmp_test = &cwmp_main_test;
......@@ -403,6 +481,10 @@ int main(void)
cmocka_unit_test(dm_get_parameter_names_test),
cmocka_unit_test(dm_set_parameter_attributes_test),
cmocka_unit_test(dm_get_parameter_attributes_test),
cmocka_unit_test(get_config_test),
cmocka_unit_test(get_deviceid_test),
cmocka_unit_test(add_event_test),
cmocka_unit_test(soap_inform_message_test),
};
return cmocka_run_group_tests(tests, NULL, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment