Skip to content

Implement devtest tool for testing in cli #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AswiniViswanathan
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Apr 16, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ soumyasmunshi
❌ AswiniViswanathan


AswiniViswanathan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -201,7 +203,20 @@ int em_cmd_cli_t::execute(char *result)
case em_cmd_type_dev_test:
bevt->type = em_bus_event_type_dev_test;
info = &bevt->u.subdoc;
snprintf(info->name, sizeof(info->name), "%s", param->u.args.fixed_args);
strncpy(info->name, param->u.args.fixed_args, strlen(param->u.args.fixed_args) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3rd parameter should be the size of the destination i.e. info->name's length so that there will be no buffer overflow while copying, not the source's string length.

}
bevt->type = em_bus_event_type_set_dev_test;
info = &bevt->u.subdoc;
strncpy(info->name, param->u.args.fixed_args, strlen(param->u.args.fixed_args) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

@@ -485,7 +500,8 @@ int em_cmd_cli_t::execute(char *result)

/* Receive result. */
if ((ret = recv(dsock, (unsigned char *)result, EM_MAX_EVENT_DATA_LEN, 0)) <= 0) {
printf("%s:%d: result read error on socket, err:%d\n", __func__, __LINE__, errno);
snprintf(result, sizeof(em_long_string_t), "%s:%d: result read error on socket, err:%d\n", __func__, __LINE__, errno);
//g_cli.dump_lib_dbg(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented line

if ((tmp = strstr(cmd->m_param.u.args.fixed_args, "DevTest")) != NULL) {
*tmp = 0;
}
if (strncmp(args[num_args - 1], "1", strlen("1")) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this strncmp check for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DevTest can have 2 type of argument 0 or 1, 0

teststatus = m_orch->get_dev_test_status();
dev_test.encode(&evt->u.subdoc, m_em_map, false, teststatus);
}
printf("%s:%d ASH %s\n", __func__, __LINE__,evt->u.subdoc.buff);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this printf

@@ -291,8 +332,8 @@ void em_ctrl_t::handle_get_dm_data(em_bus_event_t *evt)
m_ctrl_cmd->copy_bus_event(evt);
m_ctrl_cmd->send_result(em_cmd_out_status_success);
}

void em_ctrl_t::handle_dev_test(em_bus_event_t *evt)
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out? Are we not requiring this fucntion?

switch (evt->type) {
case em_bus_event_type_reset:
handle_reset(evt);
break;

case em_bus_event_type_dev_test:
handle_get_dev_test(evt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is commented above.

if ((tmp = cJSON_GetObjectItem(obj, "Num_of_iteration_completed")) != NULL) {
dev_test_info.num_of_iteration_completed[index] = static_cast<unsigned int> (tmp->valuedouble);
}
if ((tmp = cJSON_GetObjectItem(obj, "Haul_type:[Fronthault=0,IOT:2]")) != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we supporting only two haul_types? Why is this restriction? Also the value seems to be 0 or 2 what about 1?

}
}

/* Need to be implemented
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a TBD as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants