Remove bbfdm transaction API usages

This commit is contained in:
Amin Ben Romdhane 2024-08-17 13:28:19 +00:00 committed by IOPSYS Dev
parent 3eff5b9914
commit f16a9bcb52
No known key found for this signature in database
16 changed files with 198 additions and 254 deletions

View file

@ -15,12 +15,11 @@ include:
stages:
- static_code_analysis
- unit_test
- functional_api_test
- pipeline_test
- deploy
run_unit_test:
stage: unit_test
stage: pipeline_test
image: "${COMMON_IMAGE}"
allow_failure: false
script:
@ -34,8 +33,8 @@ run_unit_test:
- unit-test-coverage.xml
run_functional_test:
stage: functional_api_test
image: "dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.31"
stage: pipeline_test
image: "${COMMON_IMAGE}"
services:
- name: dev.iopsys.eu:5050/lcm/swmodd/acs:latest
alias: acs

View file

@ -1,11 +1,3 @@
[program:ubusd]
priority=1
command=/bin/bash -c "/usr/sbin/ubusd"
[program:rpcd]
priority=2
command=/bin/bash -c "/usr/sbin/rpcd"
[program:download]
priority=3
command=/bin/bash -c "cd /tmp/firmware/ && python3 -m http.server 80"

View file

@ -4,7 +4,6 @@ echo "preparation script"
pwd
[ -d "/opt/dev/bbfdm" ] && cd /opt/dev/bbfdm && ./gitlab-ci/setup.sh && cd -
rm -rf /etc/supervisor/conf.d/*.conf
cp -rf ./test/files/* /
echo "set ACS url in cwmp uci"
@ -25,7 +24,7 @@ if=/dev/zero of=/tmp/firmware/invalid_firmware_v1.0.bin bs=25MB count=1 >/dev/nu
echo "Invalid" > /tmp/firmware/invalid_firmware_v1.0.bin
echo "Starting base services"
cp ./gitlab-ci/service-base.conf /etc/supervisor/conf.d/
cp ./gitlab-ci/icwmp-base.conf /etc/supervisor/conf.d/
supervisorctl reread
supervisorctl update
sleep 5

View file

@ -32,9 +32,10 @@ bool cwmp_stop = false;
unsigned int flashsize = 256000000;
struct cwmp *cwmp_main = NULL;
struct session_timer_event *global_session_event = NULL;
LIST_HEAD(critical_service_list);
LIST_HEAD(cwmp_memory_list);
LIST_HEAD(services_reload);
static LIST_HEAD(critical_service_list);
static LIST_HEAD(cwmp_memory_list);
static bool reload_pending = false;
struct cwmp_mem {
struct list_head list;
@ -46,6 +47,12 @@ struct cwmp_services {
char *service;
};
struct bbf_config {
bool is_commit;
bool monitor;
int type;
};
struct option cwmp_long_options[] = {
{ "boot-event", no_argument, NULL, 'b' },
{ "get-rpc-methods", no_argument, NULL, 'g' },
@ -732,82 +739,125 @@ bool icwmp_critical_service(const char *service)
return ret;
}
int icwmp_add_service(char *service)
bool end_session_reload_pending()
{
if (CWMP_STRLEN(service) == 0)
return -1;
struct cwmp_services *serv = malloc(sizeof(struct cwmp_services));
if (serv == NULL)
return -1;
serv->service = CWMP_STRDUP(service);
list_add(&serv->list, &services_reload);
return 0;
return reload_pending;
}
void icwmp_free_list_services()
static void apply_cwmp_changes(bool is_commit)
{
struct cwmp_services *serv = NULL, *node = NULL;
struct blob_buf b = {0};
list_for_each_entry_safe(serv, node, &services_reload, list) {
list_del(&serv->list);
FREE(serv->service);
free(serv);
memset(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0);
void *array = blobmsg_open_array(&b, "services");
blobmsg_add_string(&b, NULL, "cwmp");
blobmsg_close_array(&b, array);
blobmsg_add_u8(&b, "monitor", false);
blobmsg_add_u8(&b, "reload", false);
blobmsg_add_string(&b, "proto", "cwmp");
icwmp_ubus_invoke("bbf.config", is_commit ? "commit" : "revert", b.head, NULL, NULL);
blob_buf_free(&b);
}
static void __apply_services(struct bbf_config *args, struct list_head *service_list)
{
path_list_t *iter = NULL, *node;
struct blob_buf bb = {0};
memset(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0);
void *array = blobmsg_open_array(&bb, "services");
list_for_each_entry_safe(iter, node, service_list, list) {
char *config_name = iter->path;
// If RELOAD_IMMIDIATE then only reload the non-critical services
// otherwise reload all services in the list
if ((args->type == RELOAD_IMMIDIATE) && (icwmp_critical_service(config_name) == true)) {
reload_pending = true;
continue;
}
CWMP_LOG(DEBUG, "Detected service: %s will be restarted", config_name);
if (CWMP_STRCMP(config_name, "cwmp") == 0) {
apply_cwmp_changes(args->is_commit);
continue;
}
blobmsg_add_string(&bb, NULL, config_name);
}
blobmsg_close_array(&bb, array);
blobmsg_add_string(&bb, "proto", "cwmp");
blobmsg_add_u8(&bb, "monitor", args->monitor);
icwmp_ubus_invoke("bbf.config", args->is_commit ? "commit" : "revert", bb.head, NULL, NULL);
blob_buf_free(&bb);
if (args->type == RELOAD_END_SESSION) {
reload_pending = false;
}
}
bool end_session_reload_pending()
static void _updated_services_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
return !list_empty(&services_reload);
struct blob_attr *cur, *tb[1] = {0};
const struct blobmsg_policy p[1] = {
{ "configs", BLOBMSG_TYPE_ARRAY }
};
int rem = 0;
if (msg == NULL || req == NULL)
return;
struct list_head *service_list = (struct list_head *)req->priv;
blobmsg_parse(p, 1, tb, blobmsg_data(msg), blobmsg_len(msg));
if (!tb[0])
return;
blobmsg_for_each_attr(cur, tb[0], rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
continue;
char *config_name = blobmsg_get_string(cur);
if (CWMP_STRLEN(config_name)) {
add_path_list(service_list, config_name);
}
}
}
void icwmp_restart_services(int type)
void icwmp_restart_services(int type, bool is_commit, bool monitor)
{
struct blob_buf bb = {0};
struct cwmp_services *serv = NULL, *node = NULL;
struct bbf_config args = {
.is_commit = is_commit,
.monitor = monitor,
.type = type
};
LIST_HEAD(service_list);
memset(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0);
void *array = blobmsg_open_array(&bb, "services");
blobmsg_add_string(&bb, "proto", "cwmp");
list_for_each_entry_safe(serv, node, &services_reload, list) {
if (CWMP_STRLEN(serv->service) == 0) {
list_del(&serv->list);
FREE(serv->service);
free(serv);
continue;
}
// If RELOAD_IMMIDIATE then only reload the non-critical services and delete from the list
// otherwise reload all services in the list and clear the list
if ((type == RELOAD_IMMIDIATE) && (icwmp_critical_service(serv->service) == true)) {
continue;
}
CWMP_LOG(DEBUG, "Detected service: %s will be restarted", serv->service);
if (CWMP_STRCMP(serv->service, "cwmp") == 0) {
list_del(&serv->list);
FREE(serv->service);
free(serv);
commit_uci_package("cwmp");
continue;
}
blobmsg_add_string(&bb, NULL, serv->service);
list_del(&serv->list);
FREE(serv->service);
free(serv);
}
blobmsg_close_array(&bb, array);
icwmp_ubus_invoke("bbf.config", "commit", bb.head, NULL, NULL);
icwmp_ubus_invoke("bbf.config", "changes", bb.head, _updated_services_cb, &service_list);
__apply_services(&args, &service_list);
free_path_list(&service_list);
blob_buf_free(&bb);
}
@ -1136,6 +1186,35 @@ void add_day_to_time(struct tm *time)
time->tm_mday = time->tm_mday + 1;
}
void add_path_list(struct list_head *list, char *str)
{
if (str == NULL) {
return;
}
path_list_t *node;
node = (path_list_t *)calloc(1, sizeof(*node));
if (!node) {
CWMP_LOG(ERROR, "Out of memory!");
return;
}
INIT_LIST_HEAD(&node->list);
CWMP_STRNCPY(node->path, str, 1024);
list_add_tail(&node->list, list);
}
void free_path_list(struct list_head *list)
{
path_list_t *iter = NULL, *node;
list_for_each_entry_safe(iter, node, list, list) {
list_del(&iter->list);
FREE(iter);
}
}
void add_bin_list(struct list_head *list, uint8_t *str, size_t len)
{
bin_list_t *node;

View file

@ -620,6 +620,11 @@ typedef struct force_inform_node {
struct list_head list;
} force_inform_node;
typedef struct {
char path[1024];
struct list_head list;
} path_list_t;
extern struct cwmp *cwmp_main;
extern unsigned int flashsize;
extern struct FAULT_CPE FAULT_CPE_ARRAY[];
@ -655,9 +660,7 @@ char *icwmp_strdup(const char *s);
int icwmp_asprintf(char **s, const char *format, ...);
void icwmp_free(void *m);
void icwmp_cleanmem();
int icwmp_add_service(char *service);
void icwmp_free_list_services(void);
void icwmp_restart_services(int type);
void icwmp_restart_services(int type, bool is_commit, bool monitor);
bool icwmp_validate_string_length(char *arg, int max_length);
bool icwmp_validate_boolean_value(char *arg);
bool icwmp_validate_unsignedint(char *arg);
@ -698,4 +701,6 @@ void icwmp_init_critical_services(void);
void icwmp_free_critical_services(void);
bool end_session_reload_service(const char *service);
bool end_session_reload_pending(void);
void add_path_list(struct list_head *list, char *str);
void free_path_list(struct list_head *list);
#endif

View file

@ -254,7 +254,6 @@ static void cwmp_free()
rpc_exit();
clean_cwmp_session_structure();
icwmp_free_critical_services();
icwmp_free_list_services();
FREE(cwmp_main);
CWMP_LOG(INFO, "EXIT ICWMP");
closelog();

View file

@ -94,11 +94,16 @@ char *cmd_set_exec_func(struct cmd_input in, union cmd_result *res)
cwmp_free_all_list_param_fault(&faults_list);
icwmp_asprintf(&fault, "%d", res->obj_res.fault_code);
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return fault;
}
set_rpc_parameter_key(in.third_input);
icwmp_restart_services(RELOAD_END_SESSION, true, false);
return NULL;
}
@ -126,11 +131,16 @@ char *cmd_add_exec_func(struct cmd_input in, union cmd_result *res)
char *fault = NULL;
icwmp_asprintf(&fault, "%d", res->obj_res.fault_code);
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return fault;
}
set_rpc_parameter_key(in.second_input);
icwmp_restart_services(RELOAD_END_SESSION, true, false);
return NULL;
}
@ -171,11 +181,16 @@ char *cmd_del_exec_func(struct cmd_input in, union cmd_result *res)
char *fault = NULL;
icwmp_asprintf(&fault, "%d", res->obj_res.fault_code);
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return fault;
}
set_rpc_parameter_key(in.second_input);
icwmp_restart_services(RELOAD_END_SESSION, true, false);
return NULL;
}

View file

@ -16,8 +16,6 @@
#include "ubus_utils.h"
#include "log.h"
unsigned int transaction_id = 0;
struct list_params_result {
struct list_head *parameters_list;
struct list_head *alias_list;
@ -54,106 +52,9 @@ static void prepare_optional_table(struct blob_buf *b)
void *table = blobmsg_open_table(b, "optional");
bb_add_string(b, "proto", "cwmp");
bb_add_string(b, "format", "raw");
blobmsg_add_u32(b, "transaction_id", transaction_id);
blobmsg_close_table(b, table);
}
/*
* Transaction Functions
*/
static void ubus_transaction_callback(struct ubus_request *req, int type __attribute__((unused)), struct blob_attr *msg)
{
struct blob_attr *tb[3] = {0};
const struct blobmsg_policy p[3] = {
{ "status", BLOBMSG_TYPE_BOOL },
{ "transaction_id", BLOBMSG_TYPE_INT32 },
{ "updated_services", BLOBMSG_TYPE_ARRAY }
};
if (msg == NULL || req == NULL)
return;
bool *status = (bool *)req->priv;
blobmsg_parse(p, 3, tb, blobmsg_data(msg), blobmsg_len(msg));
if (!tb[0]) {
*status = false;
return;
}
*status = blobmsg_get_u8(tb[0]);
if (*status == false)
return;
if (tb[1]) {
transaction_id = blobmsg_get_u32(tb[1]);
}
if (tb[2]) {
struct blob_attr *updated_services = tb[2];
struct blob_attr *service = NULL;
size_t rem;
blobmsg_for_each_attr(service, updated_services, rem) {
char *service_name = blobmsg_get_string(service);
if (CWMP_STRLEN(service_name) == 0)
continue;
icwmp_add_service(service_name);
}
}
}
bool cwmp_transaction(const char *cmd)
{
struct blob_buf b = {0};
bool status = false;
if (CWMP_STRLEN(cmd) == 0)
return false;
int start_cmp = CWMP_STRCMP(cmd, "start");
int commit_cmp = CWMP_STRCMP(cmd, "commit");
int abort_cmp = CWMP_STRCMP(cmd, "abort");
if (start_cmp != 0 && commit_cmp != 0 && abort_cmp != 0)
return false;
if ((start_cmp == 0 && transaction_id != 0) ||
((commit_cmp == 0 || abort_cmp == 0) && transaction_id == 0))
return false;
CWMP_LOG(INFO, "Transaction %s ...", cmd);
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0);
bb_add_string(&b, "cmd", cmd);
blobmsg_add_u8(&b, "restart_services", false);
prepare_optional_table(&b);
int e = icwmp_ubus_invoke(BBFDM_OBJECT_NAME, "transaction", b.head, ubus_transaction_callback, &status);
blob_buf_free(&b);
if (commit_cmp == 0 || abort_cmp == 0)
transaction_id = 0;
if (e != 0) {
CWMP_LOG(INFO, "Transaction %s failed: Ubus err code: %d", cmd, e);
return false;
}
if (!status) {
CWMP_LOG(INFO, "Transaction %s failed: Status => false", cmd);
return false;
}
return true;
}
static int get_instance_mode(void)
{
int mode = INSTANCE_MODE_NUMBER;
@ -656,7 +557,6 @@ char *cwmp_validate_multi_instance_path(const char *object, struct list_head *pa
void *table = blobmsg_open_table(&b, "optional");
bb_add_string(&b, "proto", "usp");
bb_add_string(&b, "format", "raw");
blobmsg_add_u32(&b, "transaction_id", transaction_id);
blobmsg_close_table(&b, table);
int e = icwmp_ubus_invoke(BBFDM_OBJECT_NAME, "schema", b.head, ubus_get_parameter_callback, &get_result);

View file

@ -21,9 +21,6 @@ struct object_result {
int fault_code;
};
extern unsigned int transaction_id;
bool cwmp_transaction(const char *cmd);
int instantiate_param_name(const char *param, char **inst_path);
bool cwmp_get_parameter_value(const char *parameter_name, struct cwmp_dm_parameter *dm_parameter);

View file

@ -1100,12 +1100,6 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
xml_data_list_to_dm_parameter_list(&xml_list_set_param_value, &list_set_param_value);
if (!cwmp_transaction("start")) {
fault_code = FAULT_CPE_INTERNAL_ERROR;
err_msg = "Failed to start new transaction";
goto fault;
}
/* Before set check if exists Device.ManagementServer.InformParameter.{i}.ParameterName with ForcedInform Parameter */
fault_code = validate_inform_parameter_name(&list_set_param_value);
if (fault_code != FAULT_CPE_NO_FAULT) {
@ -1130,13 +1124,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
cwmp_free_all_xml_data_list(&xml_list_set_param_value);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
if (!cwmp_transaction("commit")) {
fault_code = FAULT_CPE_INTERNAL_ERROR;
err_msg = "Failed to commit the transaction";
goto fault;
}
icwmp_restart_services(RELOAD_IMMIDIATE);
icwmp_restart_services(RELOAD_IMMIDIATE, true, false);
int status = 0;
if (end_session_reload_pending() == true) {
@ -1172,7 +1160,7 @@ fault:
cwmp_free_all_list_param_fault(rpc->list_set_value_fault);
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return ret;
}
@ -1268,11 +1256,6 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
goto fault;
}
if (!cwmp_transaction("start")) {
err_msg = "Failed to start new transaction";
goto fault;
}
if (object_name) {
bool err = cwmp_add_object(object_name, &res);
if (!err) {
@ -1313,11 +1296,6 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
goto fault;
}
if (!cwmp_transaction("commit")) {
err_msg = "Failed to commit the transaction";
goto fault;
}
char object_path[1024] = {0};
snprintf(object_path, sizeof(object_path), "%s%s.", object_name, res.instance);
cwmp_set_parameter_attributes(object_path, 0);
@ -1334,7 +1312,7 @@ fault:
if (cwmp_create_fault_message(rpc, fault_code, err_msg))
ret = -1;
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return ret;
}
@ -1364,11 +1342,6 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
goto fault;
}
if (!cwmp_transaction("start")) {
err_msg = "Failed to start new transaction";
goto fault;
}
if (object_name) {
bool err = cwmp_delete_object(object_name, &res);
if (!err) {
@ -1400,11 +1373,6 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
goto fault;
}
if (!cwmp_transaction("commit")) {
fault_code = FAULT_CPE_INTERNAL_ERROR;
err_msg = "Failed to commit the transaction";
goto fault;
}
FREE(object_name);
FREE(parameter_key);
FREE(res.instance);
@ -1418,7 +1386,7 @@ fault:
if (cwmp_create_fault_message(rpc, fault_code, err_msg))
ret = -1;
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
return ret;
}

View file

@ -645,7 +645,7 @@ int run_session_end_func(void)
if (end_session_flag & END_SESSION_RESTART_SERVICES) {
CWMP_LOG(INFO, "Restart modified services");
icwmp_restart_services(RELOAD_END_SESSION);
icwmp_restart_services(RELOAD_END_SESSION, true, true);
}
if (cwmp_apply_acs_changes() != CWMP_OK) {

View file

@ -973,7 +973,7 @@ exit:
return ret;
}
int commit_uci_package(char *package)
int commit_uci_package(char *package, const char *conf_dir, const char *save_dir)
{
struct uci_context *uci_ctx = NULL;
struct uci_ptr ptr = {0};
@ -986,6 +986,15 @@ int commit_uci_package(char *package)
goto exit;
}
if (conf_dir) {
uci_set_confdir(uci_ctx, conf_dir);
}
if (save_dir) {
uci_set_savedir(uci_ctx, save_dir);
}
if (uci_lookup_ptr(uci_ctx, &ptr, package, true) != UCI_OK) {
ret = -1;
goto exit;

View file

@ -28,8 +28,6 @@ struct strNode {
char path[BUF_SIZE_256];
};
void add_str_list(struct list_head *head, char *str);
void free_str_list(struct list_head *head);
int export_uci_package(char *package, const char *output_path);
int export_std_uci(const char *output_path);
int import_uci_package(char *package_name, const char *input_path);
@ -39,7 +37,7 @@ int set_uci_path_value(const char *conf_dir, char *path, char *value);
int set_uci_list_value(const char *conf_dir, char *path, char *value);
int del_uci_list_value(const char *conf_dir, char *path, char *value);
int get_inform_parameters_uci(struct list_head *inform_head);
int commit_uci_package(char *package);
int commit_uci_package(char *package, const char *conf_dir, const char *save_dir);
int get_global_config();

View file

@ -58,7 +58,6 @@ static int cwmp_cli_unit_tests_init(void **state)
static int cwmp_cli_unit_tests_clean(void **state)
{
icwmp_free_list_services();
cwmp_session_exit();
FREE(cwmp_main->session);
FREE(cwmp_main);

View file

@ -39,7 +39,6 @@ static int dm_iface_unit_tests_init(void **state)
static int dm_iface_unit_tests_clean(void **state)
{
icwmp_free_list_services();
cwmp_free_all_list_param_fault(&faults_array);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_session_exit();
@ -110,17 +109,15 @@ static void dm_set_multiple_parameter_values_test(void **state)
* Test of one valid parameter
*/
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alias", "wifi_alias_1", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_int_equal(fault, 0);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
add_dm_parameter_to_list(&list_set_param_value, "Device.ManagementServer.Username", "iopsys_user", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_int_equal(fault, 0);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
fault = 0;
@ -128,7 +125,6 @@ static void dm_set_multiple_parameter_values_test(void **state)
* Test of non valid parameter path
*/
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alis", "wifi_alias_1", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_non_null(fault);
list_for_each_entry (param_fault, &faults_array, list) {
@ -139,7 +135,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
assert_int_not_equal(fault, 0);
assert_int_equal(fault_code, 9005);
assert_non_null(fault_name);
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_free_all_list_param_fault(&faults_array);
fault_code = 0;
@ -151,7 +147,6 @@ static void dm_set_multiple_parameter_values_test(void **state)
* Test of non writable, valid parameter path
*/
add_dm_parameter_to_list(&list_set_param_value, "Device.DeviceInfo.UpTime", "1234", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value,&faults_array);
assert_int_not_equal(fault, 0);
list_for_each_entry (param_fault, &faults_array, list) {
@ -162,7 +157,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
assert_int_not_equal(fault, 0);
assert_int_equal(fault_code, 9008);
assert_non_null(fault_name);
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_free_all_list_param_fault(&faults_array);
fault = 0;
@ -174,7 +169,6 @@ static void dm_set_multiple_parameter_values_test(void **state)
* Test of writable, valid parameter path wrong value
*/
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Enable", "tre", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_non_null(fault);
list_for_each_entry (param_fault, &faults_array, list) {
@ -185,7 +179,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
assert_int_not_equal(fault, 0);
assert_int_equal(fault_code, 9007);
assert_non_null(fault_name);
cwmp_transaction("abort");
icwmp_restart_services(RELOAD_END_SESSION, false, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_free_all_list_param_fault(&faults_array);
fault_code = 0;
@ -199,10 +193,9 @@ static void dm_set_multiple_parameter_values_test(void **state)
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alias", "wifi_alias1_1", NULL, 0, false);
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.SSID", "wifi_ssid_2", NULL, 0, false);
add_dm_parameter_to_list(&list_set_param_value, "Device.ManagementServer.Username", "iopsys_user_1", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_int_equal(fault, 0);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
cwmp_free_all_list_param_fault(&faults_array);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
@ -213,13 +206,12 @@ static void dm_set_multiple_parameter_values_test(void **state)
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Enable", "tre", NULL, 0, false);
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.2.Alis", "wifi_2", NULL, 0, false);
add_dm_parameter_to_list(&list_set_param_value, "Device.DeviceInfo.UpTime", "123", NULL, 0, false);
cwmp_transaction("start");
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
assert_int_not_equal(fault, 0);
list_for_each_entry (param_fault, &faults_array, list) {
assert_in_set(param_fault->fault_code, faults_values, 3);
}
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
}
@ -234,11 +226,10 @@ static void dm_add_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_add_object("Device.WiFi.SSID.", &res);
assert_non_null(res.instance);
assert_true(status);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
FREE(res.instance);
/*
@ -247,12 +238,11 @@ static void dm_add_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_add_object("Device.WiFi.SIDl.", &res);
assert_false(status);
assert_int_equal(res.fault_code, FAULT_9005);
assert_null(res.instance);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
FREE(res.instance);
/*
@ -261,12 +251,11 @@ static void dm_add_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_add_object("Device.DeviceInfo.Processor.", &res);
assert_false(status);
assert_int_equal(res.fault_code, FAULT_9005);
assert_null(res.instance);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
FREE(res.instance);
}
@ -281,10 +270,9 @@ static void dm_delete_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_delete_object("Device.WiFi.SSID.2.", &res);
assert_true(status);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
/*
* Delete not valid path object
@ -292,11 +280,10 @@ static void dm_delete_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_delete_object("Device.WiFi.SIDl.3.", &res);
assert_false(status);
assert_int_equal(res.fault_code, FAULT_9005);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
/*
* Delte valid path not writable object
@ -304,11 +291,10 @@ static void dm_delete_object_test(void **state)
memset(&res, 0, sizeof(struct object_result));
cwmp_transaction("start");
status = cwmp_delete_object("Device.DeviceInfo.Processor.2.", &res);
assert_false(status);
assert_int_equal(res.fault_code, FAULT_9005);
cwmp_transaction("commit");
icwmp_restart_services(RELOAD_END_SESSION, true, false);
}
static void dm_get_parameter_names_test(void **state)

View file

@ -85,7 +85,6 @@ static int soap_unit_tests_init(void **state)
static int soap_unit_tests_clean(void **state)
{
icwmp_free_list_services();
clean_name_space();
cwmp_session_exit();
clean_force_inform_list();
@ -299,7 +298,7 @@ static void soap_add_object_message_test(void **state)
int ret = cwmp_handle_rpc_cpe_add_object(rpc_cpe);
assert_int_equal(ret, 0);
icwmp_restart_services(RELOAD_IMMIDIATE);
icwmp_restart_services(RELOAD_IMMIDIATE, true, false);
env = mxmlFindElement(cwmp_main->session->tree_out, cwmp_main->session->tree_out, "soap_env:Envelope", NULL, NULL, MXML_DESCEND);
assert_non_null(env);
@ -451,7 +450,7 @@ static void soap_delete_object_message_test(void **state)
int ret = cwmp_handle_rpc_cpe_delete_object(rpc_cpe);
assert_int_equal(ret, 0);
icwmp_restart_services(RELOAD_IMMIDIATE);
icwmp_restart_services(RELOAD_IMMIDIATE, true, false);
env = mxmlFindElement(cwmp_main->session->tree_out, cwmp_main->session->tree_out, "soap_env:Envelope", NULL, NULL, MXML_DESCEND);
assert_non_null(env);