close #31 - made all command parameter except the command name optional + added and fixed tests
This commit is contained in:
parent
c807372bce
commit
d2617a4f86
21
.vscode/launch.json
vendored
21
.vscode/launch.json
vendored
@ -24,6 +24,27 @@
|
|||||||
],
|
],
|
||||||
"preLaunchTask": "make test",
|
"preLaunchTask": "make test",
|
||||||
"miDebuggerPath": "/usr/bin/gdb"
|
"miDebuggerPath": "/usr/bin/gdb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debug integrationtest",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/output/test/integrationtest/integrationtest",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "make integrationtest",
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
16
.vscode/tasks.json
vendored
16
.vscode/tasks.json
vendored
@ -28,6 +28,22 @@
|
|||||||
"label": "make unittest",
|
"label": "make unittest",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "make unittest",
|
"command": "make unittest",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "make integrationtest",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make integrationtest",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "make test",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make test",
|
||||||
"problemMatcher": [
|
"problemMatcher": [
|
||||||
"$gcc"
|
"$gcc"
|
||||||
],
|
],
|
||||||
|
@ -125,19 +125,23 @@ shellmatta_retCode_t shellmatta_doInit( shellmatta_instance_t *inst,
|
|||||||
const char *prompt,
|
const char *prompt,
|
||||||
const shellmatta_cmd_t *cmdList,
|
const shellmatta_cmd_t *cmdList,
|
||||||
shellmatta_write_t writeFct);
|
shellmatta_write_t writeFct);
|
||||||
shellmatta_retCode_t shellmatta_addCmd( shellmatta_handle_t handle,
|
|
||||||
shellmatta_cmd_t *cmd);
|
shellmatta_retCode_t shellmatta_addCmd( shellmatta_handle_t handle,
|
||||||
|
shellmatta_cmd_t *cmd);
|
||||||
|
|
||||||
shellmatta_retCode_t shellmatta_removeCmd( shellmatta_handle_t handle,
|
shellmatta_retCode_t shellmatta_removeCmd( shellmatta_handle_t handle,
|
||||||
shellmatta_cmd_t *cmd);
|
shellmatta_cmd_t *cmd);
|
||||||
|
|
||||||
shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
||||||
char *data,
|
char *data,
|
||||||
uint32_t size);
|
uint32_t size);
|
||||||
shellmatta_retCode_t shellmatta_write( shellmatta_handle_t handle,
|
|
||||||
char *data,
|
shellmatta_retCode_t shellmatta_write( shellmatta_handle_t handle,
|
||||||
uint32_t length);
|
char *data,
|
||||||
|
uint32_t length);
|
||||||
#ifndef SHELLMATTA_STRIP_PRINTF
|
#ifndef SHELLMATTA_STRIP_PRINTF
|
||||||
shellmatta_retCode_t shellmatta_printf( shellmatta_handle_t handle,
|
shellmatta_retCode_t shellmatta_printf( shellmatta_handle_t handle,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...);
|
...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -85,6 +85,17 @@ static shellmatta_retCode_t quit(shellmatta_handle_t handle, const char *argumen
|
|||||||
}
|
}
|
||||||
shellmatta_cmd_t quitCommand = {"quit", "q", "Function quits the shell", "", quit, NULL};
|
shellmatta_cmd_t quitCommand = {"quit", "q", "Function quits the shell", "", quit, NULL};
|
||||||
|
|
||||||
|
static shellmatta_retCode_t empty(shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
||||||
|
{
|
||||||
|
(void)arguments;
|
||||||
|
(void)length;
|
||||||
|
|
||||||
|
shellmatta_printf(handle, "empty function called\r\n");
|
||||||
|
|
||||||
|
return SHELLMATTA_OK;
|
||||||
|
}
|
||||||
|
shellmatta_cmd_t emptyCommand = {"empty", NULL, NULL, NULL, empty, NULL};
|
||||||
|
|
||||||
|
|
||||||
shellmatta_retCode_t writeFct(const char* data, uint32_t length)
|
shellmatta_retCode_t writeFct(const char* data, uint32_t length)
|
||||||
{
|
{
|
||||||
@ -128,6 +139,7 @@ int main(int argc, char **argv)
|
|||||||
shellmatta_addCmd(handle, &doSomeCmd);
|
shellmatta_addCmd(handle, &doSomeCmd);
|
||||||
shellmatta_addCmd(handle, &quitCommand);
|
shellmatta_addCmd(handle, &quitCommand);
|
||||||
shellmatta_addCmd(handle, &removeCommand);
|
shellmatta_addCmd(handle, &removeCommand);
|
||||||
|
shellmatta_addCmd(handle, &emptyCommand);
|
||||||
|
|
||||||
while(exitRequest == false)
|
while(exitRequest == false)
|
||||||
{
|
{
|
||||||
|
@ -118,6 +118,9 @@ shellmatta_retCode_t shellmatta_doInit(
|
|||||||
* @return errorcode #SHELLMATTA_OK
|
* @return errorcode #SHELLMATTA_OK
|
||||||
* #SHELLMATTA_USE_FAULT (param err)
|
* #SHELLMATTA_USE_FAULT (param err)
|
||||||
* SHELLMATTA_DUPLICATE
|
* SHELLMATTA_DUPLICATE
|
||||||
|
*
|
||||||
|
* The cmd name is mandatory, the rest of the command parameters (alias, helpText and usageText) are optional
|
||||||
|
* and can be set to NULL if not used.
|
||||||
*/
|
*/
|
||||||
shellmatta_retCode_t shellmatta_addCmd(shellmatta_handle_t handle, shellmatta_cmd_t *cmd)
|
shellmatta_retCode_t shellmatta_addCmd(shellmatta_handle_t handle, shellmatta_cmd_t *cmd)
|
||||||
{
|
{
|
||||||
@ -132,7 +135,9 @@ shellmatta_retCode_t shellmatta_addCmd(shellmatta_handle_t handle, shellmatta_cm
|
|||||||
/** -# check parameters for plausibility */
|
/** -# check parameters for plausibility */
|
||||||
if( (NULL != inst)
|
if( (NULL != inst)
|
||||||
&& (SHELLMATTA_MAGIC == inst->magic)
|
&& (SHELLMATTA_MAGIC == inst->magic)
|
||||||
&& (false == inst->cmdListIsConst))
|
&& (false == inst->cmdListIsConst)
|
||||||
|
&& (NULL != cmd)
|
||||||
|
&& (NULL != cmd->cmd))
|
||||||
{
|
{
|
||||||
tempCmd = inst->cmdList;
|
tempCmd = inst->cmdList;
|
||||||
prevCmd = &inst->cmdList;
|
prevCmd = &inst->cmdList;
|
||||||
@ -147,8 +152,16 @@ shellmatta_retCode_t shellmatta_addCmd(shellmatta_handle_t handle, shellmatta_cm
|
|||||||
{
|
{
|
||||||
while ((false == cmdPlaced) && (SHELLMATTA_OK == ret))
|
while ((false == cmdPlaced) && (SHELLMATTA_OK == ret))
|
||||||
{
|
{
|
||||||
cmdDiff = strcmp(tempCmd->cmd, cmd->cmd);
|
cmdDiff = strcmp(tempCmd->cmd, cmd->cmd);
|
||||||
aliasDiff = strcmp(tempCmd->cmdAlias, cmd->cmdAlias);
|
if(NULL != cmd->cmdAlias)
|
||||||
|
{
|
||||||
|
aliasDiff = strcmp(tempCmd->cmdAlias, cmd->cmdAlias);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aliasDiff = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/** -# check for a duplicate command */
|
/** -# check for a duplicate command */
|
||||||
if((0u == cmdDiff) || (0u == aliasDiff))
|
if((0u == cmdDiff) || (0u == aliasDiff))
|
||||||
{
|
{
|
||||||
@ -200,7 +213,9 @@ shellmatta_retCode_t shellmatta_removeCmd(shellmatta_handle_t handle, shellmatta
|
|||||||
/** -# check parameters for plausibility */
|
/** -# check parameters for plausibility */
|
||||||
if( (NULL != inst)
|
if( (NULL != inst)
|
||||||
&& (SHELLMATTA_MAGIC == inst->magic)
|
&& (SHELLMATTA_MAGIC == inst->magic)
|
||||||
&& (false == inst->cmdListIsConst))
|
&& (false == inst->cmdListIsConst)
|
||||||
|
&& (NULL != cmd)
|
||||||
|
&& (NULL != cmd->cmd))
|
||||||
{
|
{
|
||||||
tempCmd = inst->cmdList;
|
tempCmd = inst->cmdList;
|
||||||
prevCmd = NULL;
|
prevCmd = NULL;
|
||||||
@ -406,14 +421,23 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
|
|||||||
while (NULL != cmd)
|
while (NULL != cmd)
|
||||||
{
|
{
|
||||||
/** -# compare command string and length */
|
/** -# compare command string and length */
|
||||||
if ( ((0 == strncmp( argumentString,
|
if ((0 == strncmp( argumentString,
|
||||||
cmd->cmd,
|
cmd->cmd,
|
||||||
cmdLen))
|
cmdLen))
|
||||||
&& (cmdLen == strlen(cmd->cmd)))
|
&& (cmdLen == strlen(cmd->cmd)))
|
||||||
|| ((0 == strncmp( argumentString,
|
{
|
||||||
cmd->cmdAlias,
|
inst->write("\r\n", 2u);
|
||||||
cmdLen))
|
|
||||||
&& (cmdLen == strlen(cmd->cmdAlias))))
|
cmdExecuted = 1u;
|
||||||
|
cmd->cmdFct(inst, argumentString, argumentLength);
|
||||||
|
cmd = NULL;
|
||||||
|
}
|
||||||
|
/** -# compare command alias if any and length */
|
||||||
|
else if((NULL != cmd->cmdAlias)
|
||||||
|
&& ((0 == strncmp( argumentString,
|
||||||
|
cmd->cmdAlias,
|
||||||
|
cmdLen))
|
||||||
|
&& (cmdLen == strlen(cmd->cmdAlias))))
|
||||||
{
|
{
|
||||||
inst->write("\r\n", 2u);
|
inst->write("\r\n", 2u);
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@ void autocomplete_run(shellmatta_instance_t *inst)
|
|||||||
printedLen += 4u;
|
printedLen += 4u;
|
||||||
}
|
}
|
||||||
/** -# check if command alias matches the input */
|
/** -# check if command alias matches the input */
|
||||||
if( (strlen(cmd->cmdAlias) >= inst->cursor)
|
if( (NULL != cmd->cmdAlias)
|
||||||
|
&& (strlen(cmd->cmdAlias) >= inst->cursor)
|
||||||
&& (0u == memcmp(cmd->cmdAlias, inst->buffer, inst->cursor)))
|
&& (0u == memcmp(cmd->cmdAlias, inst->buffer, inst->cursor)))
|
||||||
{
|
{
|
||||||
/** -# add newline on first find */
|
/** -# add newline on first find */
|
||||||
@ -123,7 +124,8 @@ void autocomplete_run(shellmatta_instance_t *inst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** -# check if command Alias matches the input */
|
/** -# check if command Alias matches the input */
|
||||||
if( (strlen(cmd->cmdAlias) >= inst->cursor)
|
if( (NULL != cmd->cmdAlias)
|
||||||
|
&& (strlen(cmd->cmdAlias) >= inst->cursor)
|
||||||
&& (0u == memcmp(cmd->cmdAlias, inst->buffer, inst->cursor)))
|
&& (0u == memcmp(cmd->cmdAlias, inst->buffer, inst->cursor)))
|
||||||
{
|
{
|
||||||
/** -# store first match */
|
/** -# store first match */
|
||||||
|
@ -290,8 +290,14 @@ static shellmatta_retCode_t helpCmdFct(shellmatta_handle_t handle, const char *a
|
|||||||
while(NULL != cmd)
|
while(NULL != cmd)
|
||||||
{
|
{
|
||||||
maxCmdLen = SHELLMATTA_MAX(maxCmdLen, strlen(cmd->cmd));
|
maxCmdLen = SHELLMATTA_MAX(maxCmdLen, strlen(cmd->cmd));
|
||||||
maxCmdAliasLen = SHELLMATTA_MAX(maxCmdAliasLen, strlen(cmd->cmdAlias));
|
if(NULL != cmd->cmdAlias)
|
||||||
maxCmdHelpLen = SHELLMATTA_MAX(maxCmdHelpLen, strlen(cmd->helpText));
|
{
|
||||||
|
maxCmdAliasLen = SHELLMATTA_MAX(maxCmdAliasLen, strlen(cmd->cmdAlias));
|
||||||
|
}
|
||||||
|
if(NULL != cmd->helpText)
|
||||||
|
{
|
||||||
|
maxCmdHelpLen = SHELLMATTA_MAX(maxCmdHelpLen, strlen(cmd->helpText));
|
||||||
|
}
|
||||||
cmd = cmd->next;
|
cmd = cmd->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,22 +307,31 @@ static shellmatta_retCode_t helpCmdFct(shellmatta_handle_t handle, const char *a
|
|||||||
{
|
{
|
||||||
/** -# determine the length of each field to add padding */
|
/** -# determine the length of each field to add padding */
|
||||||
cmdLen = strlen(cmd->cmd);
|
cmdLen = strlen(cmd->cmd);
|
||||||
cmdAliasLen = strlen(cmd->cmdAlias);
|
cmdAliasLen = (NULL != cmd->cmdAlias) ? strlen(cmd->cmdAlias) : 0u;
|
||||||
cmdHelpLen = strlen(cmd->helpText);
|
cmdHelpLen = (NULL != cmd->helpText) ? strlen(cmd->helpText) : 0u;
|
||||||
|
|
||||||
inst->write(cmd->cmd, strlen(cmd->cmd));
|
inst->write(cmd->cmd, strlen(cmd->cmd));
|
||||||
tabCnt = (maxCmdLen - cmdLen) + 2u;
|
tabCnt = (maxCmdLen - cmdLen) + 2u;
|
||||||
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
||||||
|
|
||||||
inst->write(cmd->cmdAlias, strlen(cmd->cmdAlias));
|
if(NULL != cmd->cmdAlias)
|
||||||
|
{
|
||||||
|
inst->write(cmd->cmdAlias, cmdAliasLen);
|
||||||
|
}
|
||||||
tabCnt = (maxCmdAliasLen - cmdAliasLen) + 2u;
|
tabCnt = (maxCmdAliasLen - cmdAliasLen) + 2u;
|
||||||
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
||||||
|
|
||||||
inst->write(cmd->helpText, strlen(cmd->helpText));
|
if(NULL != cmd->helpText)
|
||||||
|
{
|
||||||
|
inst->write(cmd->helpText, cmdHelpLen);
|
||||||
|
}
|
||||||
tabCnt = (maxCmdHelpLen - cmdHelpLen) + 2u;
|
tabCnt = (maxCmdHelpLen - cmdHelpLen) + 2u;
|
||||||
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
SHELLMATTA_PRINT_BUFFER(tabBuffer, tabCnt, inst->write);
|
||||||
|
|
||||||
inst->write(cmd->usageText, strlen(cmd->usageText));
|
if(NULL != cmd->usageText)
|
||||||
|
{
|
||||||
|
inst->write(cmd->usageText, strlen(cmd->usageText));
|
||||||
|
}
|
||||||
inst->write("\r\n", 2u);
|
inst->write("\r\n", 2u);
|
||||||
|
|
||||||
cmd = cmd->next;
|
cmd = cmd->next;
|
||||||
|
@ -33,6 +33,12 @@ static shellmatta_retCode_t doSomething(shellmatta_handle_t handle, const char *
|
|||||||
}
|
}
|
||||||
shellmatta_cmd_t doSomethingCmd = {(char*)"doSomething", (char*)"do", (char*)"Function does something", (char*)"use me, please", doSomething, NULL};
|
shellmatta_cmd_t doSomethingCmd = {(char*)"doSomething", (char*)"do", (char*)"Function does something", (char*)"use me, please", doSomething, NULL};
|
||||||
|
|
||||||
|
static shellmatta_retCode_t empty(shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
||||||
|
{
|
||||||
|
shellmatta_printf(handle, "empty - %s - length: %u", arguments, length);
|
||||||
|
return SHELLMATTA_OK;
|
||||||
|
}
|
||||||
|
shellmatta_cmd_t emptyCmd = {(char*)"empty", NULL, NULL, NULL, empty, NULL};
|
||||||
|
|
||||||
TEST_CASE( "shellmatta empty function" ) {
|
TEST_CASE( "shellmatta empty function" ) {
|
||||||
|
|
||||||
@ -69,9 +75,9 @@ TEST_CASE( "shellmatta help function" ) {
|
|||||||
shellmatta_handle_t handle;
|
shellmatta_handle_t handle;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char historyBuffer[1024];
|
char historyBuffer[1024];
|
||||||
char *dummyData = (char*)"h\r\n"
|
char *dummyData = (char*)"?\r\n"
|
||||||
"doSomething do Function does something use me, please\r\n"
|
"doSomething do Function does something use me, please\r\n"
|
||||||
"help h Print this help text help\r\n"
|
"help ? Print this help text help\r\n"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
shellmatta_doInit( &inst,
|
shellmatta_doInit( &inst,
|
||||||
@ -89,24 +95,26 @@ TEST_CASE( "shellmatta help function" ) {
|
|||||||
memset(write_data, 0, sizeof(write_data));
|
memset(write_data, 0, sizeof(write_data));
|
||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
shellmatta_processData(handle, (char*)"h\r", 2);
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
||||||
|
|
||||||
CHECK( write_length == 123u);
|
CHECK( write_length == 123u);
|
||||||
CHECK( strcmp(dummyData, write_data) == 0);
|
CHECK( strcmp(dummyData, write_data) == 0);
|
||||||
|
|
||||||
|
shellmatta_addCmd(handle, &emptyCmd);
|
||||||
|
|
||||||
write_callCnt = 0u;
|
write_callCnt = 0u;
|
||||||
memset(write_data, 0, sizeof(write_data));
|
memset(write_data, 0, sizeof(write_data));
|
||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||||
"doSomething do Function does something use me, please\r\n"
|
"doSomething do Function does something use me, please\r\n"
|
||||||
"help h Print this help text help\r\n"
|
"empty \r\n"
|
||||||
|
"help ? Print this help text help\r\n"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||||
|
|
||||||
CHECK( write_length == 141u);
|
CHECK( write_length == strlen(dummyData));
|
||||||
CHECK( strcmp(dummyData, write_data) == 0);
|
CHECK( strcmp(dummyData, write_data) == 0);
|
||||||
|
|
||||||
|
|
||||||
@ -114,11 +122,11 @@ TEST_CASE( "shellmatta help function" ) {
|
|||||||
memset(write_data, 0, sizeof(write_data));
|
memset(write_data, 0, sizeof(write_data));
|
||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
dummyData = (char*)"hr\r\n"
|
dummyData = (char*)"?r\r\n"
|
||||||
"Command: hr not found"
|
"Command: ?r not found"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
shellmatta_processData(handle, (char*)"hr\r", 3);
|
shellmatta_processData(handle, (char*)"?r\r", 3);
|
||||||
|
|
||||||
CHECK( write_length == 39u);
|
CHECK( write_length == 39u);
|
||||||
REQUIRE( strcmp(dummyData, write_data) == 0);
|
REQUIRE( strcmp(dummyData, write_data) == 0);
|
||||||
@ -169,9 +177,9 @@ TEST_CASE( "shellmatta remove function" ) {
|
|||||||
shellmatta_handle_t handle;
|
shellmatta_handle_t handle;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char historyBuffer[1024];
|
char historyBuffer[1024];
|
||||||
char *dummyData = (char*)"h\r\n"
|
char *dummyData = (char*)"?\r\n"
|
||||||
"doSomething do Function does something use me, please\r\n"
|
"doSomething do Function does something use me, please\r\n"
|
||||||
"help h Print this help text help\r\n"
|
"help ? Print this help text help\r\n"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
shellmatta_doInit( &inst,
|
shellmatta_doInit( &inst,
|
||||||
@ -189,7 +197,7 @@ TEST_CASE( "shellmatta remove function" ) {
|
|||||||
memset(write_data, 0, sizeof(write_data));
|
memset(write_data, 0, sizeof(write_data));
|
||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
shellmatta_processData(handle, (char*)"h\r", 2);
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
||||||
|
|
||||||
CHECK( write_length == 123u);
|
CHECK( write_length == 123u);
|
||||||
CHECK( strcmp(dummyData, write_data) == 0);
|
CHECK( strcmp(dummyData, write_data) == 0);
|
||||||
@ -199,12 +207,12 @@ TEST_CASE( "shellmatta remove function" ) {
|
|||||||
memset(write_data, 0, sizeof(write_data));
|
memset(write_data, 0, sizeof(write_data));
|
||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||||
"doSomething do Function does something use me, please\r\n"
|
"doSomething do Function does something use me, please\r\n"
|
||||||
"help h Print this help text help\r\n"
|
"help ? Print this help text help\r\n"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||||
|
|
||||||
CHECK( write_length == 141u);
|
CHECK( write_length == 141u);
|
||||||
CHECK( strcmp(dummyData, write_data) == 0);
|
CHECK( strcmp(dummyData, write_data) == 0);
|
||||||
@ -214,10 +222,10 @@ TEST_CASE( "shellmatta remove function" ) {
|
|||||||
write_length = 0u;
|
write_length = 0u;
|
||||||
|
|
||||||
shellmatta_removeCmd(handle, &doSomethingCmd);
|
shellmatta_removeCmd(handle, &doSomethingCmd);
|
||||||
shellmatta_processData(handle, (char*)"h 564 321 56 465 46\r", 20);
|
shellmatta_processData(handle, (char*)"? 564 321 56 465 46\r", 20);
|
||||||
|
|
||||||
dummyData = (char*)"h 564 321 56 465 46\r\n"
|
dummyData = (char*)"? 564 321 56 465 46\r\n"
|
||||||
"help h Print this help text help\r\n"
|
"help ? Print this help text help\r\n"
|
||||||
"\r\nshellmatta->";
|
"\r\nshellmatta->";
|
||||||
|
|
||||||
printf("sdfsd sdf sdf sdf sdf sd fds\n%s", write_data);
|
printf("sdfsd sdf sdf sdf sdf sd fds\n%s", write_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user