|
@@ -327,3 +327,116 @@ SCENARIO("Integration test of Transport layer", "[integration, transport]")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+SCENARIO("Integration test of Transport layer with mandatory transport layer", "[integration, transport]")
|
|
|
|
+{
|
|
|
|
+ GIVEN("Shellmatta up and running with one command")
|
|
|
|
+ {
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ shellmatta_retCode_t ret;
|
|
|
|
+ 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("The tansport layer is set to mandatory") {
|
|
|
|
+ ret = shellmatta_transport_configure(handle, true, false, NULL);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ AND_WHEN("manual mode is used after transport layer mode")
|
|
|
|
+ {
|
|
|
|
+ /* 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);
|
|
|
|
+ shellmatta_processData(handle, (char*)"doSomething argument\r\n", 22u);
|
|
|
|
+ THEN("The shellmatta responds only to the first command - and waits for a new telegram to start")
|
|
|
|
+ {
|
|
|
|
+ char *dummyData = (char*)"\x01\x01\x00\x2f\x00\x00\x01\x01"
|
|
|
|
+ "doSomething argument - length: 20"
|
|
|
|
+ "\r\n"
|
|
|
|
+ "shellmatta->"
|
|
|
|
+ "\xc8\xae\xc0\x56";
|
|
|
|
+
|
|
|
|
+ CHECK(write_length == 59);
|
|
|
|
+ CHECK(memcmp(write_data, dummyData, write_length) == 0);
|
|
|
|
+ REQUIRE(inst.transportLayer.state == SHELLMATTA_TRANSPORT_STATE_WAIT);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+SCENARIO("Integration test of Transport layer - reset transport layer", "[integration, transport]")
|
|
|
|
+{
|
|
|
|
+ GIVEN("Shellmatta up and running with one command")
|
|
|
|
+ {
|
|
|
|
+ shellmatta_instance_t inst;
|
|
|
|
+ shellmatta_handle_t handle;
|
|
|
|
+ shellmatta_retCode_t ret;
|
|
|
|
+ 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("The tansport layer is set to mandatory") {
|
|
|
|
+ ret = shellmatta_transport_configure(handle, true, false, NULL);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ AND_WHEN("A partial telegram 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", 28u);
|
|
|
|
+ THEN("The transport layer is in state SHELLMATTA_TRANSPORT_STATE_GET_PAYLOAD")
|
|
|
|
+ {
|
|
|
|
+ CHECK(write_length == 0);
|
|
|
|
+ CHECK_THAT(inst.transportLayer.inPacket.payload, Catch::Matchers::Equals("doSomething argument"));
|
|
|
|
+ REQUIRE(inst.transportLayer.state == SHELLMATTA_TRANSPORT_STATE_GET_PAYLOAD);
|
|
|
|
+
|
|
|
|
+ AND_WHEN("The transport layer is resetted")
|
|
|
|
+ {
|
|
|
|
+ ret = shellmatta_transport_reset(handle);
|
|
|
|
+ CHECK(ret == SHELLMATTA_OK);
|
|
|
|
+
|
|
|
|
+ THEN("The transport layer is in state wait again and no payload is set") {
|
|
|
|
+ CHECK(write_length == 0);
|
|
|
|
+ CHECK(inst.transportLayer.inPacket.payload[0] == '\0');
|
|
|
|
+ REQUIRE(inst.transportLayer.state == SHELLMATTA_TRANSPORT_STATE_WAIT);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|