|
@@ -77,6 +77,7 @@ TEST_CASE( "shellmatta help function" ) {
|
|
char historyBuffer[1024];
|
|
char historyBuffer[1024];
|
|
char *dummyData = (char*)"?\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"
|
|
|
|
+ "empty \r\n"
|
|
"help ? Print this help text help\r\n"
|
|
"help ? Print this help text help\r\n"
|
|
"\r\nshellmatta->";
|
|
"\r\nshellmatta->";
|
|
|
|
|
|
@@ -89,6 +90,7 @@ TEST_CASE( "shellmatta help function" ) {
|
|
"shellmatta->",
|
|
"shellmatta->",
|
|
NULL,
|
|
NULL,
|
|
writeFct);
|
|
writeFct);
|
|
|
|
+ shellmatta_addCmd(handle, &emptyCmd);
|
|
shellmatta_addCmd(handle, &doSomethingCmd);
|
|
shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
|
|
|
write_callCnt = 0u;
|
|
write_callCnt = 0u;
|
|
@@ -97,11 +99,9 @@ TEST_CASE( "shellmatta help function" ) {
|
|
|
|
|
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
|
shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
|
|
- CHECK( write_length == 123u);
|
|
|
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
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;
|
|
@@ -228,9 +228,157 @@ TEST_CASE( "shellmatta remove function" ) {
|
|
"help ? 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);
|
|
|
|
-
|
|
|
|
CHECK( write_length == 72u);
|
|
CHECK( write_length == 72u);
|
|
REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST_CASE( "shellmatta reset no prompt" ) {
|
|
|
|
+
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ char buffer[1024];
|
|
|
|
+ char historyBuffer[1024];
|
|
|
|
+ char *dummyData = (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh glkd?\r\n"
|
|
|
|
+ "doSomething do Function does something use me, please\r\n"
|
|
|
|
+ "help ? Print this help text help\r\n"
|
|
|
|
+ "\r\nshellmatta->";
|
|
|
|
+
|
|
|
|
+ shellmatta_doInit( &inst,
|
|
|
|
+ &handle,
|
|
|
|
+ buffer,
|
|
|
|
+ sizeof(buffer),
|
|
|
|
+ historyBuffer,
|
|
|
|
+ sizeof(historyBuffer),
|
|
|
|
+ "shellmatta->",
|
|
|
|
+ NULL,
|
|
|
|
+ writeFct);
|
|
|
|
+ shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
|
+
|
|
|
|
+ write_callCnt = 0u;
|
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
|
+ write_length = 0u;
|
|
|
|
+
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh glkd", 35);
|
|
|
|
+ shellmatta_resetShell(handle, false);
|
|
|
|
+ shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
+
|
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST_CASE( "shellmatta reset with prompt" ) {
|
|
|
|
+
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ char buffer[1024];
|
|
|
|
+ char historyBuffer[1024];
|
|
|
|
+ char *dummyData = (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh glkd"
|
|
|
|
+ "\r\nshellmatta->?\r\n"
|
|
|
|
+ "doSomething do Function does something use me, please\r\n"
|
|
|
|
+ "help ? Print this help text help\r\n"
|
|
|
|
+ "\r\nshellmatta->";
|
|
|
|
+
|
|
|
|
+ shellmatta_doInit( &inst,
|
|
|
|
+ &handle,
|
|
|
|
+ buffer,
|
|
|
|
+ sizeof(buffer),
|
|
|
|
+ historyBuffer,
|
|
|
|
+ sizeof(historyBuffer),
|
|
|
|
+ "shellmatta->",
|
|
|
|
+ NULL,
|
|
|
|
+ writeFct);
|
|
|
|
+ shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
|
+
|
|
|
|
+ write_callCnt = 0u;
|
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
|
+ write_length = 0u;
|
|
|
|
+
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh glkd", 35);
|
|
|
|
+ shellmatta_resetShell(handle, true);
|
|
|
|
+ shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
+
|
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
+}
|
|
|
|
|
|
-}
|
|
|
|
|
|
+TEST_CASE( "shellmatta reset no prompt history buffer" ) {
|
|
|
|
+
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ char buffer[1024];
|
|
|
|
+ char historyBuffer[1024];
|
|
|
|
+ char *dummyData = (char*)"?\r\n"
|
|
|
|
+ "doSomething do Function does something use me, please\r\n"
|
|
|
|
+ "help ? Print this help text help\r\n"
|
|
|
|
+ "\r\nshellmatta->";
|
|
|
|
+
|
|
|
|
+ shellmatta_doInit( &inst,
|
|
|
|
+ &handle,
|
|
|
|
+ buffer,
|
|
|
|
+ sizeof(buffer),
|
|
|
|
+ historyBuffer,
|
|
|
|
+ sizeof(historyBuffer),
|
|
|
|
+ "shellmatta->",
|
|
|
|
+ NULL,
|
|
|
|
+ writeFct);
|
|
|
|
+ shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
|
+
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh gl\r\n", 35u);
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh gl\r\n", 35u);
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh gl\r\n", 35u);
|
|
|
|
+
|
|
|
|
+ write_callCnt = 0u;
|
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
|
+ write_length = 0u;
|
|
|
|
+
|
|
|
|
+ shellmatta_resetShell(handle, false);
|
|
|
|
+
|
|
|
|
+ /* process arrow key up - if reset worked this should deliver nothing */
|
|
|
|
+ shellmatta_processData(handle, (char*)"\033[A", 3u);
|
|
|
|
+ shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
+
|
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST_CASE( "shellmatta reset no prompt heredoc" ) {
|
|
|
|
+
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ char buffer[1024];
|
|
|
|
+ char historyBuffer[1024];
|
|
|
|
+ char *dummyData = (char*)"?\r\n"
|
|
|
|
+ "doSomething do Function does something use me, please\r\n"
|
|
|
|
+ "help ? Print this help text help\r\n"
|
|
|
|
+ "\r\nshellmatta->";
|
|
|
|
+
|
|
|
|
+ shellmatta_doInit( &inst,
|
|
|
|
+ &handle,
|
|
|
|
+ buffer,
|
|
|
|
+ sizeof(buffer),
|
|
|
|
+ historyBuffer,
|
|
|
|
+ sizeof(historyBuffer),
|
|
|
|
+ "shellmatta->",
|
|
|
|
+ NULL,
|
|
|
|
+ writeFct);
|
|
|
|
+ shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
|
+
|
|
|
|
+ shellmatta_processData(handle, (char*)"dummy cmd << EOF\r\n", 18u);
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh gl\r\n", 35u);
|
|
|
|
+ shellmatta_processData(handle, (char*)"dkfg hdlsfkgh ldksfjhg lkdjfsh gl\r\n", 35u);
|
|
|
|
+
|
|
|
|
+ write_callCnt = 0u;
|
|
|
|
+ memset(write_data, 0, sizeof(write_data));
|
|
|
|
+ write_length = 0u;
|
|
|
|
+
|
|
|
|
+ /* end the heredoc session by resetting the shell */
|
|
|
|
+ shellmatta_resetShell(handle, false);
|
|
|
|
+
|
|
|
|
+ /* now the new command should be processed */
|
|
|
|
+ shellmatta_processData(handle, (char*)"?\r", 2);
|
|
|
|
+
|
|
|
|
+ printf("%s", write_data);
|
|
|
|
+
|
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
|
+ REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
|
+}
|