Kaynağa Gözat

Merge branch 'master' of https://github.com/acplt/open62541

Conflicts:
	examples/server.c
ichrispa 9 yıl önce
ebeveyn
işleme
28ddb8e1e2
3 değiştirilmiş dosya ile 99 ekleme ve 1 silme
  1. 1 1
      include/ua_types.h
  2. 6 0
      tests/CMakeLists.txt
  3. 92 0
      tests/check_session.c

+ 1 - 1
include/ua_types.h

@@ -345,7 +345,7 @@ UA_NodeId UA_EXPORT UA_NodeId_fromByteStringCopy(UA_UInt16 nsIndex, UA_ByteStrin
 #define UA_NODEID_STRING_ALLOC(NSID, CHARS) UA_NodeId_fromCharStringCopy(NSID, CHARS)
 #define UA_NODEID_GUID(NSID, GUID) UA_NodeId_fromGuid(NSID, GUID)
 #define UA_NODEID_BYTESTRING(NSID, CHARS) UA_NodeId_fromCharByteString(NSID, CHARS)
-#define UA_NODEID_BYTESTRING_ALLOC(NSID, CHARS) UA_NodeId_fromCharStringCopy(NSID, CHARS)
+#define UA_NODEID_BYTESTRING_ALLOC(NSID, CHARS) UA_NodeId_fromCharByteStringCopy(NSID, CHARS)
 #define UA_NODEID_NULL UA_NODEID_NUMERIC(0,0)
 
 /* ExpandedNodeId */

+ 6 - 0
tests/CMakeLists.txt

@@ -47,6 +47,12 @@ add_executable(check_nodestore check_nodestore.c $<TARGET_OBJECTS:open62541-obje
 target_link_libraries(check_nodestore ${LIBS})
 add_test(nodestore ${CMAKE_CURRENT_BINARY_DIR}/check_nodestore)
 
+
+
+add_executable(check_session check_session.c $<TARGET_OBJECTS:open62541-object>)
+target_link_libraries(check_session ${LIBS})
+add_test(session ${CMAKE_CURRENT_BINARY_DIR}/check_session)
+
 # add_executable(check_startup check_startup.c)
 # target_link_libraries(check_startup ${LIBS})
 # add_test(startup ${CMAKE_CURRENT_BINARY_DIR}/check_startup)

+ 92 - 0
tests/check_session.c

@@ -0,0 +1,92 @@
+/*
+ * check_session.c
+ *
+ *  Created on: Jul 30, 2015
+ *      Author: opcua
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "ua_types.h"
+#include "server/ua_services.h"
+#include "ua_statuscodes.h"
+#include "check.h"
+#include "ua_util.h"
+
+
+START_TEST(Session_init_ShallWork)
+{
+	UA_Session session;
+	UA_Session_init(&session);
+
+
+    UA_NodeId tmpNodeId;
+    UA_NodeId_init(&tmpNodeId);
+    UA_ApplicationDescription tmpAppDescription;
+    UA_ApplicationDescription_init(&tmpAppDescription);
+    UA_DateTime tmpDateTime;
+    UA_DateTime_init(&tmpDateTime);
+	ck_assert_int_eq(session.activated,UA_FALSE);
+	ck_assert_int_eq(session.authenticationToken.identifier.numeric,tmpNodeId.identifier.numeric);
+	ck_assert_int_eq(session.availableContinuationPoints,MAXCONTINUATIONPOINTS);
+    ck_assert_int_eq(session.channel,UA_NULL);
+    ck_assert_int_eq(session.clientDescription.applicationName.locale.data,UA_NULL);
+    ck_assert_int_eq(session.continuationPoints.lh_first, UA_NULL);
+    ck_assert_int_eq(session.maxRequestMessageSize,0);
+    ck_assert_int_eq(session.maxResponseMessageSize,0);
+    ck_assert_int_eq(session.sessionId.identifier.numeric,tmpNodeId.identifier.numeric);
+    ck_assert_int_eq(session.sessionName.data,UA_NULL);
+    ck_assert_int_eq(session.timeout,0);
+    ck_assert_int_eq(session.validTill,tmpDateTime);
+
+
+	//finally
+}
+END_TEST
+
+START_TEST(Session_updateLifetime_ShallWork)
+{
+	UA_Session session;
+	UA_Session_init(&session);
+    UA_DateTime tmpDateTime;
+    tmpDateTime = session.validTill;
+	UA_Session_updateLifetime(&session);
+
+	UA_Int32 result = (session.validTill > tmpDateTime);
+
+	ck_assert_int_gt(result,0);
+
+
+
+	//finally
+}
+END_TEST
+
+static Suite* testSuite_Session(void) {
+	Suite *s = suite_create("Session");
+	TCase *tc_core = tcase_create("Core");
+	tcase_add_test(tc_core, Session_init_ShallWork);
+	tcase_add_test(tc_core, Session_updateLifetime_ShallWork);
+
+	suite_add_tcase(s,tc_core);
+	return s;
+}
+
+int main(void) {
+	int number_failed = 0;
+
+	Suite *s;
+	SRunner *sr;
+
+	s = testSuite_Session();
+	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;
+}
+
+