|
@@ -52,85 +52,69 @@ 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};
|
|
|
|
|
|
-
|
|
|
-TEST_CASE( "shellmatta transport crc error" ) {
|
|
|
-
|
|
|
- shellmatta_instance_t inst;
|
|
|
- shellmatta_handle_t handle;
|
|
|
- char buffer[1024];
|
|
|
- char historyBuffer[1024];
|
|
|
- char *dummyData = (char*)"crc error\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;
|
|
|
-
|
|
|
- /* check with invalid payload */
|
|
|
- shellmatta_processData(handle, (char*)"\x01\x01\x00\x16\x00\x00\x00\x00"
|
|
|
- "doSomething argument\r\n"
|
|
|
- "\x00\x00\x00\x00", 34u);
|
|
|
-
|
|
|
- CHECK( write_length == strlen(dummyData));
|
|
|
- REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-TEST_CASE( "shellmatta transport success" ) {
|
|
|
-
|
|
|
- shellmatta_instance_t inst;
|
|
|
- shellmatta_handle_t handle;
|
|
|
- char buffer[1024];
|
|
|
- char historyBuffer[1024];
|
|
|
- char *dummyData = (char*)"\x01\x01\x00\x21\x00\x00\x01\x01"
|
|
|
- "doSomething argument - length: 20"
|
|
|
- "\xac\xf5\xe9\x4f"
|
|
|
- "\x01\x01\x00\x02\x00\x00\x01\x02"
|
|
|
- "\r\n"
|
|
|
- "\x62\xef\x22\x7a"
|
|
|
- "\x01\x01\x00\x0C\x00\x00\x01\x03"
|
|
|
- "shellmatta->"
|
|
|
- "\xd2\x0b\x8f\x3e";
|
|
|
-
|
|
|
- shellmatta_doInit( &inst,
|
|
|
- &handle,
|
|
|
- buffer,
|
|
|
- sizeof(buffer),
|
|
|
- historyBuffer,
|
|
|
- sizeof(historyBuffer),
|
|
|
- "shellmatta->",
|
|
|
- NULL,
|
|
|
- writeFct);
|
|
|
- shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\r');
|
|
|
- shellmatta_addCmd(handle, &doSomethingCmd);
|
|
|
-
|
|
|
- write_callCnt = 0u;
|
|
|
- memset(write_data, 0, sizeof(write_data));
|
|
|
- write_length = 0u;
|
|
|
-
|
|
|
- /* check with invalid payload */
|
|
|
- shellmatta_processData(handle, (char*)"\x01\x01\x00\x16\x00\x00\x00\x00"
|
|
|
- "doSomething argument\r\n"
|
|
|
- "\x7b\x49\xfa\x72", 34u);
|
|
|
-
|
|
|
- for(uint32_t i = 0; i < 83; i ++)
|
|
|
+SCENARIO("Integration test of Transport layer", "[integration, transport]")
|
|
|
+{
|
|
|
+ GIVEN("Shellmatta up and running with one command")
|
|
|
{
|
|
|
- if(dummyData[i] != write_data[i])
|
|
|
+ shellmatta_instance_t inst;
|
|
|
+ shellmatta_handle_t handle;
|
|
|
+ char buffer[1024];
|
|
|
+ char historyBuffer[1024];
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ WHEN("Invalid CRC is passed")
|
|
|
{
|
|
|
- CHECK(dummyData[i] == write_data[i]);
|
|
|
+ /* check with invalid payload */
|
|
|
+ shellmatta_processData(handle, (char*)"\x01\x01\x00\x16\x00\x00\x00\x00"
|
|
|
+ "doSomething argument\r\n"
|
|
|
+ "\x00\x00\x00\x00", 34u);
|
|
|
+
|
|
|
+ THEN("Shellmatta responds with CRC error")
|
|
|
+ {
|
|
|
+ char *dummyData = (char*)"crc error\r\n\r\nshellmatta->";
|
|
|
+
|
|
|
+ CHECK( write_length == strlen(dummyData));
|
|
|
+ REQUIRE( strcmp(dummyData, write_data) == 0);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- CHECK( write_length == 83);
|
|
|
- REQUIRE( memcmp(write_data, dummyData, 83) == 0);
|
|
|
+ WHEN("Valid CRC is passed")
|
|
|
+ {
|
|
|
+ /* check with valid payload - disable echo to reduce cluttering */
|
|
|
+ shellmatta_configure(handle, SHELLMATTA_MODE_INSERT, false, '\r');
|
|
|
+ shellmatta_processData(handle, (char*)"\x01\x01\x00\x16\x00\x00\x00\x00"
|
|
|
+ "doSomething argument\r\n"
|
|
|
+ "\x7b\x49\xfa\x72", 34u);
|
|
|
+ THEN("The shellmatta responds to the command")
|
|
|
+ {
|
|
|
+ char *dummyData = (char*)"\x01\x01\x00\x21\x00\x00\x01\x01"
|
|
|
+ "doSomething argument - length: 20"
|
|
|
+ "\xac\xf5\xe9\x4f"
|
|
|
+ "\x01\x01\x00\x02\x00\x00\x01\x02"
|
|
|
+ "\r\n"
|
|
|
+ "\x62\xef\x22\x7a"
|
|
|
+ "\x01\x01\x00\x0C\x00\x00\x01\x03"
|
|
|
+ "shellmatta->"
|
|
|
+ "\xd2\x0b\x8f\x3e";
|
|
|
+
|
|
|
+ CHECK( write_length == 83);
|
|
|
+ REQUIRE( memcmp(write_data, dummyData, 83) == 0);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|