|
@@ -1,135 +1,450 @@
|
|
|
-
|
|
|
- ============================================================================
|
|
|
+
|
|
|
Name : check_stack.c
|
|
|
- Author :
|
|
|
- Version :
|
|
|
+ Author : uleon @ open62541
|
|
|
+ Version : 0.1
|
|
|
Copyright : Your copyright notice
|
|
|
- Description :
|
|
|
- ============================================================================
|
|
|
- */
|
|
|
+ Description : test cases to check different aspects of the
|
|
|
+ stack indication-response behavior w/o any network aspects
|
|
|
+
|
|
|
+
|
|
|
+```
|
|
|
+ Client Server
|
|
|
+
|
|
|
+request o--__
|
|
|
+ --> indication +
|
|
|
+ | <---
|
|
|
+ __--o response +
|
|
|
+confirm. <--
|
|
|
+```
|
|
|
+*****************************************************************************/
|
|
|
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include "opcua.h"
|
|
|
#include "ua_transport.h"
|
|
|
+#include "ua_transport_binary.h"
|
|
|
+#include "ua_transport_binary_secure.h"
|
|
|
#include "check.h"
|
|
|
|
|
|
+#define MAXMSG 512
|
|
|
+#define BUFFER_SIZE 8192
|
|
|
|
|
|
-
|
|
|
-START_TEST(test_getPacketType_validParameter)
|
|
|
-{
|
|
|
+
|
|
|
+typedef struct stackTestFixture {
|
|
|
+
|
|
|
+ UA_Byte respMsgBuffer[BUFFER_SIZE];
|
|
|
+
|
|
|
+ UA_ByteString respMsg;
|
|
|
+
|
|
|
+ TL_Connection connection;
|
|
|
+} stackTestFixture;
|
|
|
|
|
|
- char buf[] = {'C','L','O'};
|
|
|
- UA_Int32 pos = 0;
|
|
|
- UA_ByteString msg;
|
|
|
|
|
|
- msg.data = buf;
|
|
|
- msg.length = 3;
|
|
|
+
|
|
|
+ * ( MAX_FIXTURES needs to match the number of bytes of fixturesMap )*/
|
|
|
+#define MAX_FIXTURES 32
|
|
|
+
|
|
|
+UA_Int32 fixturesMap = 0;
|
|
|
+
|
|
|
+stackTestFixture* fixtures[MAX_FIXTURES];
|
|
|
|
|
|
- ck_assert_int_eq(TL_getPacketType(&msg, &pos),packetType_CLO);
|
|
|
+
|
|
|
+UA_Int32 stackTestFixture_getAndMarkFreeHandle() {
|
|
|
+ UA_Int32 freeFixtureHandle = 0;
|
|
|
+
|
|
|
+ for (freeFixtureHandle=0;freeFixtureHandle < MAX_FIXTURES;++freeFixtureHandle) {
|
|
|
+ if (!(fixturesMap & (1 << freeFixtureHandle))) {
|
|
|
+ fixturesMap |= (1 << freeFixtureHandle);
|
|
|
+ return freeFixtureHandle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return UA_ERR_NO_MEMORY;
|
|
|
+}
|
|
|
+
|
|
|
+UA_Int32 stackTestFixture_markHandleAsFree(UA_Int32 fixtureHandle) {
|
|
|
+ if (fixtureHandle >= 0 && fixtureHandle < MAX_FIXTURES) {
|
|
|
+ fixturesMap &= ~ (1 << fixtureHandle);
|
|
|
+ return UA_SUCCESS;
|
|
|
+ }
|
|
|
+ return UA_ERR_INVALID_VALUE;
|
|
|
}
|
|
|
-END_TEST
|
|
|
-*/
|
|
|
|
|
|
+
|
|
|
+UA_Int32 stackTestFixture_create(TL_Writer writerCallback) {
|
|
|
+ UA_UInt32 fixtureHandle = stackTestFixture_getAndMarkFreeHandle();
|
|
|
+ if (fixtureHandle < MAX_FIXTURES) {
|
|
|
+ UA_alloc((void**)&fixtures[fixtureHandle], sizeof(stackTestFixture));
|
|
|
+ stackTestFixture* fixture = fixtures[fixtureHandle];
|
|
|
+ fixture->respMsg.data = fixture->respMsgBuffer;
|
|
|
+ fixture->respMsg.length = 0;
|
|
|
+ fixture->connection.connectionState = CONNECTIONSTATE_CLOSED;
|
|
|
+ fixture->connection.writerCallback = writerCallback;
|
|
|
+ fixture->connection.localConf.maxChunkCount = 1;
|
|
|
+ fixture->connection.localConf.maxMessageSize = BUFFER_SIZE;
|
|
|
+ fixture->connection.localConf.protocolVersion = 0;
|
|
|
+ fixture->connection.localConf.recvBufferSize = BUFFER_SIZE;
|
|
|
+ fixture->connection.localConf.recvBufferSize = BUFFER_SIZE;
|
|
|
+ fixture->connection.connectionHandle = fixtureHandle;
|
|
|
+ }
|
|
|
+ return fixtureHandle;
|
|
|
+}
|
|
|
+
|
|
|
+UA_Int32 stackTestFixture_delete(UA_UInt32 fixtureHandle) {
|
|
|
+ if (fixtureHandle < MAX_FIXTURES) {
|
|
|
+ UA_free(fixtures[fixtureHandle]);
|
|
|
+ stackTestFixture_markHandleAsFree(fixtureHandle);
|
|
|
+ return UA_SUCCESS;
|
|
|
+ }
|
|
|
+ return UA_ERR_INVALID_VALUE;
|
|
|
+}
|
|
|
|
|
|
-
|
|
|
-START_TEST(decodeRequestHeader_test_validParameter)
|
|
|
-{
|
|
|
- char testMessage = {0x00,0x00,0x72,0xf1,0xdc,0xc9,0x87,0x0b,
|
|
|
+
|
|
|
+stackTestFixture* stackTestFixture_getFixture(UA_UInt32 fixtureHandle) {
|
|
|
+ if (fixtureHandle < MAX_FIXTURES && ( fixturesMap & (1 << fixtureHandle)))
|
|
|
+ return fixtures[fixtureHandle];
|
|
|
+ return UA_NULL;
|
|
|
+}
|
|
|
|
|
|
- 0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00};
|
|
|
- UA_ByteString rawMessage;
|
|
|
- rawMessage.data = &testMessage;
|
|
|
- rawMessage.length = 29;
|
|
|
- Int32 position = 0;
|
|
|
- T_RequestHeader requestHeader;
|
|
|
- decodeRequestHeader(rawMessage,&position,&requestHeader);
|
|
|
+
|
|
|
+UA_Int32 responseMsg(struct TL_Connection * c, UA_ByteString const ** gather_buf, UA_Int32 gather_len) {
|
|
|
+ UA_Int32 retval = UA_SUCCESS;
|
|
|
+ UA_UInt32 total_len = 0;
|
|
|
|
|
|
- ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
|
|
|
+ stackTestFixture* fixture = stackTestFixture_getFixture(c->connectionHandle);
|
|
|
|
|
|
- ck_assert_int_eq(requestHeader.returnDiagnostics,0);
|
|
|
+ for (UA_Int32 i=0; i<gather_len && retval == UA_SUCCESS; ++i) {
|
|
|
+ if (total_len + gather_buf[i]->length < BUFFER_SIZE) {
|
|
|
+ memcpy(&(fixture->respMsg.data[total_len]),gather_buf[i]->data,gather_buf[i]->length);
|
|
|
+ total_len += gather_buf[i]->length;
|
|
|
+ } else {
|
|
|
+ retval = UA_ERR_NO_MEMORY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fixture->respMsg.length = total_len;
|
|
|
+ return UA_SUCCESS;
|
|
|
+}
|
|
|
|
|
|
- ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
|
|
|
+void indicateMsg(UA_Int32 handle, UA_ByteString *slMessage) {
|
|
|
+ TL_Process(&(stackTestFixture_getFixture(handle)->connection), slMessage);
|
|
|
+}
|
|
|
|
|
|
+UA_Byte pkt_HEL[] = {
|
|
|
+ 0x48, 0x45, 0x4c, 0x46, 0x39, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x01, 0x88, 0x13, 0x00, 0x00, 0x19, 0x00,
|
|
|
+0x00, 0x00, 0x6f, 0x70, 0x63, 0x2e, 0x74, 0x63,
|
|
|
+0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x30, 0x2e, 0x30,
|
|
|
+0x2e, 0x35, 0x34, 0x2e, 0x37, 0x37, 0x3a, 0x34,
|
|
|
+0x38, 0x34, 0x32
|
|
|
+};
|
|
|
+UA_Byte pkt_OPN[] = {
|
|
|
+ 0x4f, 0x50, 0x4e, 0x46, 0x85, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x00,
|
|
|
+0x00, 0x00, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
|
|
+0x2f, 0x6f, 0x70, 0x63, 0x66, 0x6f, 0x75, 0x6e,
|
|
|
+0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6f,
|
|
|
+0x72, 0x67, 0x2f, 0x55, 0x41, 0x2f, 0x53, 0x65,
|
|
|
+0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x50, 0x6f,
|
|
|
+0x6c, 0x69, 0x63, 0x79, 0x23, 0x4e, 0x6f, 0x6e,
|
|
|
+0x65, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
+0xff, 0x33, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
|
|
+0x00, 0x01, 0x00, 0xbe, 0x01, 0x00, 0x00, 0x40,
|
|
|
+0xaf, 0xfc, 0xe8, 0xa1, 0x76, 0xcf, 0x01, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
|
|
+0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x80, 0xee, 0x36, 0x00
|
|
|
+};
|
|
|
+
|
|
|
+UA_Byte pkt_MSG_CreateSession[] = {
|
|
|
+0x4d, 0x53, 0x47, 0x46, 0xb4, 0x05, 0x00, 0x00,
|
|
|
+0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
+0x34, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
|
+0x01, 0x00, 0xcd, 0x01, 0x00, 0x00, 0x50, 0xd6,
|
|
|
+0xfc, 0xe8, 0xa1, 0x76, 0xcf, 0x01, 0x01, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
|
|
|
+0xff, 0xff, 0x10, 0x27, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x2d, 0x00, 0x00, 0x00, 0x75, 0x72, 0x6e,
|
|
|
+0x3a, 0x6d, 0x72, 0x74, 0x2d, 0x56, 0x69, 0x72,
|
|
|
+0x74, 0x75, 0x61, 0x6c, 0x42, 0x6f, 0x78, 0x3a,
|
|
|
+0x55, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x41,
|
|
|
+0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x6f,
|
|
|
+0x6e, 0x3a, 0x55, 0x61, 0x45, 0x78, 0x70, 0x65,
|
|
|
+0x72, 0x74, 0x1e, 0x00, 0x00, 0x00, 0x75, 0x72,
|
|
|
+0x6e, 0x3a, 0x55, 0x6e, 0x69, 0x66, 0x69, 0x65,
|
|
|
+0x64, 0x41, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74,
|
|
|
+0x69, 0x6f, 0x6e, 0x3a, 0x55, 0x61, 0x45, 0x78,
|
|
|
+0x70, 0x65, 0x72, 0x74, 0x02, 0x1b, 0x00, 0x00,
|
|
|
+0x00, 0x55, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64,
|
|
|
+0x20, 0x41, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74,
|
|
|
+0x69, 0x6f, 0x6e, 0x20, 0x55, 0x61, 0x45, 0x78,
|
|
|
+0x70, 0x65, 0x72, 0x74, 0x01, 0x00, 0x00, 0x00,
|
|
|
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
|
|
+0x19, 0x00, 0x00, 0x00, 0x6f, 0x70, 0x63, 0x2e,
|
|
|
+0x74, 0x63, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x30,
|
|
|
+0x2e, 0x30, 0x2e, 0x35, 0x34, 0x2e, 0x37, 0x37,
|
|
|
+0x3a, 0x34, 0x38, 0x34, 0x32, 0x2d, 0x00, 0x00,
|
|
|
+0x00, 0x75, 0x72, 0x6e, 0x3a, 0x6d, 0x72, 0x74,
|
|
|
+0x2d, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c,
|
|
|
+0x42, 0x6f, 0x78, 0x3a, 0x55, 0x6e, 0x69, 0x66,
|
|
|
+0x69, 0x65, 0x64, 0x41, 0x75, 0x74, 0x6f, 0x6d,
|
|
|
+0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x55, 0x61,
|
|
|
+0x45, 0x78, 0x70, 0x65, 0x72, 0x74, 0x20, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
+0x00, 0x00, 0x72, 0x04, 0x00, 0x00, 0x30, 0x82,
|
|
|
+0x04, 0x6e, 0x30, 0x82, 0x03, 0xd7, 0xa0, 0x03,
|
|
|
+0x02, 0x01, 0x02, 0x02, 0x04, 0x53, 0x1b, 0x10,
|
|
|
+0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
|
|
|
+0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00,
|
|
|
+0x30, 0x81, 0x93, 0x31, 0x0b, 0x30, 0x09, 0x06,
|
|
|
+0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x44, 0x45,
|
|
|
+0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04,
|
|
|
+0x08, 0x13, 0x08, 0x41, 0x6e, 0x79, 0x77, 0x68,
|
|
|
+0x65, 0x72, 0x65, 0x31, 0x11, 0x30, 0x0f, 0x06,
|
|
|
+0x03, 0x55, 0x04, 0x07, 0x13, 0x08, 0x41, 0x6e,
|
|
|
+0x79, 0x77, 0x68, 0x65, 0x72, 0x65, 0x31, 0x13,
|
|
|
+0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13,
|
|
|
+0x0a, 0x54, 0x55, 0x20, 0x44, 0x72, 0x65, 0x73,
|
|
|
+0x64, 0x65, 0x6e, 0x31, 0x36, 0x30, 0x34, 0x06,
|
|
|
+0x03, 0x55, 0x04, 0x0b, 0x13, 0x2d, 0x43, 0x68,
|
|
|
+0x61, 0x69, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20,
|
|
|
+0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x20,
|
|
|
+0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20,
|
|
|
+0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x20,
|
|
|
+0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x65, 0x72,
|
|
|
+0x69, 0x6e, 0x67, 0x31, 0x11, 0x30, 0x0f, 0x06,
|
|
|
+0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x55, 0x61,
|
|
|
+0x45, 0x78, 0x70, 0x65, 0x72, 0x74, 0x30, 0x1e,
|
|
|
+0x17, 0x0d, 0x31, 0x34, 0x30, 0x33, 0x30, 0x38,
|
|
|
+0x31, 0x32, 0x34, 0x34, 0x31, 0x35, 0x5a, 0x17,
|
|
|
+0x0d, 0x31, 0x34, 0x30, 0x33, 0x30, 0x38, 0x31,
|
|
|
+0x33, 0x34, 0x34, 0x31, 0x35, 0x5a, 0x30, 0x81,
|
|
|
+0x93, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
|
|
|
+0x04, 0x06, 0x13, 0x02, 0x44, 0x45, 0x31, 0x11,
|
|
|
+0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13,
|
|
|
+0x08, 0x41, 0x6e, 0x79, 0x77, 0x68, 0x65, 0x72,
|
|
|
+0x65, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55,
|
|
|
+0x04, 0x07, 0x13, 0x08, 0x41, 0x6e, 0x79, 0x77,
|
|
|
+0x68, 0x65, 0x72, 0x65, 0x31, 0x13, 0x30, 0x11,
|
|
|
+0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x54,
|
|
|
+0x55, 0x20, 0x44, 0x72, 0x65, 0x73, 0x64, 0x65,
|
|
|
+0x6e, 0x31, 0x36, 0x30, 0x34, 0x06, 0x03, 0x55,
|
|
|
+0x04, 0x0b, 0x13, 0x2d, 0x43, 0x68, 0x61, 0x69,
|
|
|
+0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x50, 0x72,
|
|
|
+0x6f, 0x63, 0x65, 0x73, 0x73, 0x20, 0x43, 0x6f,
|
|
|
+0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20, 0x53, 0x79,
|
|
|
+0x73, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x45, 0x6e,
|
|
|
+0x67, 0x69, 0x6e, 0x65, 0x65, 0x72, 0x69, 0x6e,
|
|
|
+0x67, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55,
|
|
|
+0x04, 0x03, 0x13, 0x08, 0x55, 0x61, 0x45, 0x78,
|
|
|
+0x70, 0x65, 0x72, 0x74, 0x30, 0x81, 0x9f, 0x30,
|
|
|
+0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
|
|
|
+0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81,
|
|
|
+0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81,
|
|
|
+0x00, 0xb3, 0xb3, 0xc9, 0x97, 0xb7, 0x4f, 0x6d,
|
|
|
+0x6f, 0x72, 0x48, 0xe2, 0x5f, 0x8c, 0x89, 0x0f,
|
|
|
+0xc3, 0x47, 0x17, 0x4c, 0xd2, 0x8c, 0x2a, 0x85,
|
|
|
+0xf6,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68, 0x20, 0x55, 0x6e, 0x69,
|
|
|
+0x66, 0x69, 0x65, 0x64, 0x20, 0x41, 0x75, 0x74,
|
|
|
+0x6f, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20,
|
|
|
+0x55, 0x41, 0x20, 0x42, 0x61, 0x73, 0x65, 0x20,
|
|
|
+0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x20,
|
|
|
+0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x4f, 0x70,
|
|
|
+0x65, 0x6e, 0x53, 0x53, 0x4c, 0x22, 0x30, 0x1d,
|
|
|
+0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04,
|
|
|
+0x14, 0x37, 0x39, 0x34, 0x93, 0xa2, 0x65, 0xef,
|
|
|
+0xb9, 0xd4, 0x71, 0x21, 0x4b, 0x77, 0xdb, 0x28,
|
|
|
+0xc8, 0xfa, 0x03, 0xfe, 0x05, 0x30, 0x81, 0xc3,
|
|
|
+0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x81, 0xbb,
|
|
|
+0x30, 0x81, 0xb8, 0x80, 0x14, 0x37, 0x39, 0x34,
|
|
|
+0x93, 0xa2, 0x65, 0xef, 0xb9, 0xd4, 0x71, 0x21,
|
|
|
+0x4b, 0x77, 0xdb, 0x28, 0xc8, 0xfa, 0x03, 0xfe,
|
|
|
+0x05, 0xa1, 0x81, 0x99, 0xa4, 0x81, 0x96, 0x30,
|
|
|
+0x81, 0x93, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
|
|
|
+0x55, 0x04, 0x06, 0x13, 0x02, 0x44, 0x45, 0x31,
|
|
|
+0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x08,
|
|
|
+0x13, 0x08, 0x41, 0x6e, 0x79, 0x77, 0x68, 0x65,
|
|
|
+0x72, 0x65, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03,
|
|
|
+0x55, 0x04, 0x07, 0x13, 0x08, 0x41, 0x6e, 0x79,
|
|
|
+0x77, 0x68, 0x65, 0x72, 0x65, 0x31, 0x13, 0x30,
|
|
|
+0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0a,
|
|
|
+0x54, 0x55, 0x20, 0x44, 0x72, 0x65, 0x73, 0x64,
|
|
|
+0x65, 0x6e, 0x31, 0x36, 0x30, 0x34, 0x06, 0x03,
|
|
|
+0x55, 0x04, 0x0b, 0x13, 0x2d, 0x43, 0x68, 0x61,
|
|
|
+0x69, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x50,
|
|
|
+0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x20, 0x43,
|
|
|
+0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x20, 0x53,
|
|
|
+0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x45,
|
|
|
+0x6e, 0x67, 0x69, 0x6e, 0x65, 0x65, 0x72, 0x69,
|
|
|
+0x6e, 0x67, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03,
|
|
|
+0x55, 0x04, 0x03, 0x13, 0x08, 0x55, 0x61, 0x45,
|
|
|
+0x78, 0x70, 0x65, 0x72, 0x74, 0x82, 0x04, 0x53,
|
|
|
+0x1b, 0x10, 0x9f, 0x30, 0x0e, 0x06, 0x03, 0x55,
|
|
|
+0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03,
|
|
|
+0x02, 0x02, 0xf4, 0x30, 0x20, 0x06, 0x03, 0x55,
|
|
|
+0x1d, 0x25, 0x01, 0x01, 0xff, 0x04, 0x16, 0x30,
|
|
|
+0x14, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
|
|
|
+0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01,
|
|
|
+0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x4e, 0x06,
|
|
|
+0x03, 0x55, 0x1d, 0x11, 0x04,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|
|
|
+0x2d, 0xce, 0xe2, 0xe1, 0x87, 0x8d, 0x4c, 0x4b,
|
|
|
+0x89, 0x24, 0x77, 0xff, 0x62, 0x95, 0xf7, 0xec,
|
|
|
+0x16, 0x7c, 0x8a, 0x1e, 0x4d, 0x89, 0xcb, 0x3d,
|
|
|
+0xc8, 0xc0, 0x7c, 0x12, 0x5a, 0x29, 0xf2, 0xe7,
|
|
|
+0x68, 0xf9, 0xb9, 0x85, 0xe5, 0xc0, 0x46, 0xac,
|
|
|
+0x89, 0xdb, 0xd0, 0x87, 0xaa, 0xa1, 0x7a, 0x73,
|
|
|
+0x71, 0xcc, 0x8e, 0x01, 0x80, 0xf3, 0x07, 0x70,
|
|
|
+0x00, 0x00, 0x00, 0x00, 0x80, 0x4f, 0x32, 0x41,
|
|
|
+0xff, 0xff, 0xff, 0xff
|
|
|
+};
|
|
|
+
|
|
|
+START_TEST(emptyIndicationShallYieldNoResponse)
|
|
|
+{
|
|
|
+
|
|
|
+ UA_Int32 handle = stackTestFixture_create(responseMsg);
|
|
|
+ UA_ByteString message = { -1, (UA_Byte*) UA_NULL };
|
|
|
+
|
|
|
+
|
|
|
+ indicateMsg(handle, &message);
|
|
|
+
|
|
|
+
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.length,0);
|
|
|
+
|
|
|
+
|
|
|
+ stackTestFixture_delete(handle);
|
|
|
}
|
|
|
END_TEST
|
|
|
-*/
|
|
|
|
|
|
-START_TEST(encode_builtInDatatypeArray_test_String)
|
|
|
+
|
|
|
+START_TEST(validHELIndicationShallYieldACKResponse)
|
|
|
{
|
|
|
- UA_Int32 noElements = 2;
|
|
|
- UA_ByteString s1 = { 6, (UA_Byte*) "OPC UA" };
|
|
|
- UA_ByteString s2 = { -1, UA_NULL };
|
|
|
- UA_ByteString* array[] = { &s1, &s2 };
|
|
|
- UA_Int32 pos = 0;
|
|
|
- UA_Byte buf[256];
|
|
|
- UA_ByteString dst = { sizeof(buf), buf };
|
|
|
- UA_Byte result[] = {
|
|
|
- 0x02, 0x00, 0x00, 0x00,
|
|
|
- 0x06, 0x00, 0x00, 0x00,
|
|
|
- 'O', 'P', 'C', ' ', 'U', 'A',
|
|
|
- 0xFF, 0xFF, 0xFF, 0xFF
|
|
|
- };
|
|
|
-
|
|
|
- UA_Array_encodeBinary((void const**)array, noElements, UA_BYTESTRING, &pos, &dst);
|
|
|
-
|
|
|
-
|
|
|
- ck_assert_int_eq(pos, 4 + 4 + 6 + 4);
|
|
|
- ck_assert_int_eq(pos, sizeof(result));
|
|
|
-
|
|
|
- ck_assert_int_eq(buf[0],result[0]);
|
|
|
- ck_assert_int_eq(buf[1],result[1]);
|
|
|
- ck_assert_int_eq(buf[2],result[2]);
|
|
|
- ck_assert_int_eq(buf[3],result[3]);
|
|
|
- ck_assert_int_eq(buf[4],result[4]);
|
|
|
- ck_assert_int_eq(buf[5],result[5]);
|
|
|
- ck_assert_int_eq(buf[6],result[6]);
|
|
|
- ck_assert_int_eq(buf[7],result[7]);
|
|
|
- ck_assert_int_eq(buf[8],result[8]);
|
|
|
- ck_assert_int_eq(buf[9],result[9]);
|
|
|
- ck_assert_int_eq(buf[10],result[10]);
|
|
|
- ck_assert_int_eq(buf[11],result[11]);
|
|
|
- ck_assert_int_eq(buf[12],result[12]);
|
|
|
- ck_assert_int_eq(buf[13],result[13]);
|
|
|
- ck_assert_int_eq(buf[14],result[14]);
|
|
|
- ck_assert_int_eq(buf[15],result[15]);
|
|
|
- ck_assert_int_eq(buf[16],result[16]);
|
|
|
- ck_assert_int_eq(buf[17],result[17]);
|
|
|
+
|
|
|
+ UA_Int32 handle = stackTestFixture_create(responseMsg);
|
|
|
+ UA_ByteString message_001 = { sizeof(pkt_HEL), pkt_HEL };
|
|
|
+
|
|
|
+
|
|
|
+ indicateMsg(handle, &message_001);
|
|
|
+
|
|
|
+
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.length,28);
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[0],'A');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[1],'C');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[2],'K');
|
|
|
+
|
|
|
+
|
|
|
+ stackTestFixture_delete(handle);
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
-
|
|
|
+START_TEST(validOpeningSequenceShallCreateChannel)
|
|
|
{
|
|
|
- Suite *s = suite_create("getPacketType");
|
|
|
- TCase *tc_core = tcase_create("Core");
|
|
|
- tcase_add_test(tc_core,test_getPacketType_validParameter);
|
|
|
- suite_add_tcase(s,tc_core);
|
|
|
- return s;
|
|
|
-}**/
|
|
|
+
|
|
|
+ UA_Int32 handle = stackTestFixture_create(responseMsg);
|
|
|
+
|
|
|
+ UA_ByteString message_001 = { sizeof(pkt_HEL), pkt_HEL };
|
|
|
+ UA_ByteString message_002 = { sizeof(pkt_OPN), pkt_OPN };
|
|
|
+
|
|
|
+
|
|
|
+ indicateMsg(handle, &message_001);
|
|
|
+ indicateMsg(handle, &message_002);
|
|
|
+
|
|
|
+
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[0],'O');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[1],'P');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[2],'N');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->connection.connectionState, CONNECTIONSTATE_ESTABLISHED);
|
|
|
+
|
|
|
+
|
|
|
+ stackTestFixture_delete(handle);
|
|
|
+}
|
|
|
+END_TEST
|
|
|
|
|
|
-Suite* testSuite_encode_builtInDatatypeArray()
|
|
|
+START_TEST(validCreateSessionShallCreateSession)
|
|
|
{
|
|
|
- Suite *s = suite_create("encode_builtInDatatypeArray");
|
|
|
- TCase *tc_core = tcase_create("Core");
|
|
|
- tcase_add_test(tc_core, encode_builtInDatatypeArray_test_String);
|
|
|
- suite_add_tcase(s,tc_core);
|
|
|
- return s;
|
|
|
+
|
|
|
+ UA_Int32 handle = stackTestFixture_create(responseMsg);
|
|
|
+
|
|
|
+ UA_ByteString message_001 = { sizeof(pkt_HEL), pkt_HEL };
|
|
|
+ UA_ByteString message_002 = { sizeof(pkt_OPN), pkt_OPN };
|
|
|
+ UA_ByteString message_003 = { sizeof(pkt_MSG_CreateSession), pkt_MSG_CreateSession };
|
|
|
+
|
|
|
+
|
|
|
+ indicateMsg(handle, &message_001);
|
|
|
+ indicateMsg(handle, &message_002);
|
|
|
+ UA_Int32 pos = 8;
|
|
|
+ UA_UInt32 secureChannelId = stackTestFixture_getFixture(handle)->connection.secureChannel->securityToken.secureChannelId;
|
|
|
+ UA_UInt32_encodeBinary(&secureChannelId,&pos,&message_003);
|
|
|
+ indicateMsg(handle, &message_003);
|
|
|
+
|
|
|
+
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[0],'M');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[1],'S');
|
|
|
+ ck_assert_int_eq(stackTestFixture_getFixture(handle)->respMsg.data[2],'G');
|
|
|
+ ck_assert_ptr_ne(stackTestFixture_getFixture(handle)->connection.secureChannel, UA_NULL);
|
|
|
+
|
|
|
+
|
|
|
+ stackTestFixture_delete(handle);
|
|
|
}
|
|
|
+END_TEST
|
|
|
|
|
|
-
|
|
|
-Suite* TL_<TESTSUITENAME>(void)
|
|
|
+Suite* testSuite()
|
|
|
{
|
|
|
- Suite *s = suite_create("<TESTSUITENAME>");
|
|
|
+ Suite *s = suite_create("Stack Test");
|
|
|
TCase *tc_core = tcase_create("Core");
|
|
|
- tcase_add_test(tc_core,<TEST_NAME>);
|
|
|
+ tcase_add_test(tc_core, emptyIndicationShallYieldNoResponse);
|
|
|
+ tcase_add_test(tc_core, validHELIndicationShallYieldACKResponse);
|
|
|
+ tcase_add_test(tc_core, validOpeningSequenceShallCreateChannel);
|
|
|
+ tcase_add_test(tc_core, validCreateSessionShallCreateSession);
|
|
|
suite_add_tcase(s,tc_core);
|
|
|
return s;
|
|
|
}
|
|
|
-*/
|
|
|
-
|
|
|
|
|
|
int main (void)
|
|
|
{
|
|
@@ -138,27 +453,13 @@ int main (void)
|
|
|
Suite *s;
|
|
|
SRunner *sr;
|
|
|
|
|
|
-
|
|
|
- sr = srunner_create(s);
|
|
|
- srunner_run_all(sr,CK_NORMAL);
|
|
|
- number_failed = srunner_ntests_failed(sr);
|
|
|
- srunner_free(sr); */
|
|
|
-
|
|
|
- s = testSuite_encode_builtInDatatypeArray();
|
|
|
+ s = testSuite();
|
|
|
sr = srunner_create(s);
|
|
|
srunner_run_all(sr,CK_NORMAL);
|
|
|
number_failed += srunner_ntests_failed(sr);
|
|
|
srunner_free(sr);
|
|
|
|
|
|
-
|
|
|
- s = <TESTSUITENAME>;
|
|
|
- sr = srunner_create(s);
|
|
|
- srunner_run_all(sr,CK_NORMAL);
|
|
|
- number_failed += srunner_ntests_failed(sr);
|
|
|
- srunner_free(sr);
|
|
|
- */
|
|
|
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|