Kaynağa Gözat

repair tests that still apply. still work needed on tests

Julius Pfrommer 10 yıl önce
ebeveyn
işleme
37ce7292b1
3 değiştirilmiş dosya ile 105 ekleme ve 105 silme
  1. 9 9
      tests/CMakeLists.txt
  2. 87 87
      tests/check_namespace.c
  3. 9 9
      tests/check_stack.c

+ 9 - 9
tests/CMakeLists.txt

@@ -17,9 +17,9 @@ add_executable(check_memory check_memory.c)
 target_link_libraries(check_memory ${LIBS})
 add_test(memory ${CMAKE_CURRENT_BINARY_DIR}/check_memory)
 
-add_executable(check_stack check_stack.c)
-target_link_libraries(check_stack ${LIBS})
-add_test(stack ${CMAKE_CURRENT_BINARY_DIR}/check_stack)
+# add_executable(check_stack check_stack.c)
+# target_link_libraries(check_stack ${LIBS})
+# add_test(stack ${CMAKE_CURRENT_BINARY_DIR}/check_stack)
 
 add_executable(check_list check_list.c)
 target_link_libraries(check_list ${LIBS})
@@ -33,10 +33,10 @@ add_executable(check_services_view check_services_view.c)
 target_link_libraries(check_services_view ${LIBS})
 add_test(services_view ${CMAKE_CURRENT_BINARY_DIR}/check_services_view)
 
-add_executable(check_namespace check_namespace.c)
-target_link_libraries(check_namespace ${LIBS})
-add_test(namespace ${CMAKE_CURRENT_BINARY_DIR}/check_namespace)
+add_executable(check_nodestore check_nodestore.c)
+target_link_libraries(check_nodestore ${LIBS})
+add_test(namespace ${CMAKE_CURRENT_BINARY_DIR}/check_nodestore)
 
-add_executable(check_startup check_startup.c)
-target_link_libraries(check_startup ${LIBS})
-add_test(startup ${CMAKE_CURRENT_BINARY_DIR}/check_startup)
+# add_executable(check_startup check_startup.c)
+# target_link_libraries(check_startup ${LIBS})
+# add_test(startup ${CMAKE_CURRENT_BINARY_DIR}/check_startup)

+ 87 - 87
tests/check_namespace.c

@@ -3,7 +3,7 @@
 #include <time.h>
 
 #include "ua_types.h"
-#include "server/ua_namespace.h"
+#include "server/ua_nodestore.h"
 #include "check.h"
 
 #ifdef MULTITHREADING
@@ -22,10 +22,10 @@ void printVisitor(const UA_Node* node) {
 	printf("%d\n", node->nodeId.identifier.numeric);
 }
 
-START_TEST(test_UA_Namespace) {
-	UA_Namespace *ns = UA_NULL;
-	UA_Namespace_new(&ns);
-	UA_Namespace_delete(ns);
+START_TEST(test_UA_NodeStore) {
+	UA_NodeStore *ns = UA_NULL;
+	UA_NodeStore_new(&ns);
+	UA_NodeStore_delete(ns);
 }
 END_TEST
 
@@ -38,115 +38,115 @@ UA_Int32 createNode(UA_Node** p, UA_Int16 nsid, UA_Int32 id) {
 	return UA_SUCCESS;
 }
 
-START_TEST(findNodeInUA_NamespaceWithSingleEntry) {
+START_TEST(findNodeInUA_NodeStoreWithSingleEntry) {
 #ifdef MULTITHREADING
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
 	UA_Node* n1; createNode(&n1,0,2253);
-	UA_Namespace_insert(ns, &n1, UA_NAMESPACE_INSERT_UNIQUE | UA_NAMESPACE_INSERT_GETMANAGED);
+	UA_NodeStore_insert(ns, &n1, UA_NODESTORE_INSERT_UNIQUE | UA_NODESTORE_INSERT_GETMANAGED);
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
 	// when
-	retval = UA_Namespace_get(ns,&n1->nodeId,&nr);
+	retval = UA_NodeStore_get(ns,&n1->nodeId,&nr);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_ptr_eq(nr,n1);
 	// finally
-	UA_Namespace_releaseManagedNode(n1);
-	UA_Namespace_releaseManagedNode(nr);
-	UA_Namespace_delete(ns);
+	UA_NodeStore_releaseManagedNode(n1);
+	UA_NodeStore_releaseManagedNode(nr);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
 }
 END_TEST
 
-START_TEST(failToFindNodeInOtherUA_Namespace) {
+START_TEST(failToFindNodeInOtherUA_NodeStore) {
 #ifdef MULTITHREADING
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns = UA_NULL;
-	UA_Namespace_new(&ns);
+	UA_NodeStore *ns = UA_NULL;
+	UA_NodeStore_new(&ns);
 
-	UA_Node* n1; createNode(&n1,0,2253); UA_Namespace_insert(ns, &n1, 0);
-	UA_Node* n2; createNode(&n2,0,2253); UA_Namespace_insert(ns, &n2, 0);
+	UA_Node* n1; createNode(&n1,0,2253); UA_NodeStore_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2253); UA_NodeStore_insert(ns, &n2, 0);
 
 	const UA_Node* nr = UA_NULL;
 	// when
 	UA_Node* n; createNode(&n,1,2255);
-	UA_Int32 retval = UA_Namespace_get(ns,&n->nodeId, &nr);
+	UA_Int32 retval = UA_NodeStore_get(ns,&n->nodeId, &nr);
 	// then
 	ck_assert_int_ne(retval, UA_SUCCESS);
 	// finally
 	UA_Node_delete(n);
-	UA_Namespace_releaseManagedNode(nr);
-	UA_Namespace_delete(ns);
+	UA_NodeStore_releaseManagedNode(nr);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
 }
 END_TEST
 
-START_TEST(findNodeInUA_NamespaceWithSeveralEntries) {
+START_TEST(findNodeInUA_NodeStoreWithSeveralEntries) {
 #ifdef MULTITHREADING
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
-	UA_Node* n1; createNode(&n1,0,2253); UA_Namespace_insert(ns, &n1, 0);
-	UA_Node* n2; createNode(&n2,0,2255); UA_Namespace_insert(ns, &n2, 0);
-	UA_Node* n3; createNode(&n3,0,2257); UA_Namespace_insert(ns, &n3, UA_NAMESPACE_INSERT_GETMANAGED);
-	UA_Node* n4; createNode(&n4,0,2200); UA_Namespace_insert(ns, &n4, 0);
-	UA_Node* n5; createNode(&n5,0,1); UA_Namespace_insert(ns, &n5, 0);
-	UA_Node* n6; createNode(&n6,0,12); UA_Namespace_insert(ns, &n6, 0);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
+	UA_Node* n1; createNode(&n1,0,2253); UA_NodeStore_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); UA_NodeStore_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); UA_NodeStore_insert(ns, &n3, UA_NODESTORE_INSERT_GETMANAGED);
+	UA_Node* n4; createNode(&n4,0,2200); UA_NodeStore_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); UA_NodeStore_insert(ns, &n5, 0);
+	UA_Node* n6; createNode(&n6,0,12); UA_NodeStore_insert(ns, &n6, 0);
 
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
 	// when
-	retval = UA_Namespace_get(ns,&(n3->nodeId),&nr);
+	retval = UA_NodeStore_get(ns,&(n3->nodeId),&nr);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_ptr_eq(nr,n3);
 	// finally
-	UA_Namespace_releaseManagedNode(n3);
-	UA_Namespace_releaseManagedNode(nr);
-	UA_Namespace_delete(ns);
+	UA_NodeStore_releaseManagedNode(n3);
+	UA_NodeStore_releaseManagedNode(nr);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
 }
 END_TEST
 
-START_TEST(iterateOverUA_NamespaceShallNotVisitEmptyNodes) {
+START_TEST(iterateOverUA_NodeStoreShallNotVisitEmptyNodes) {
 #ifdef MULTITHREADING
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
-	UA_Node* n1; createNode(&n1,0,2253); UA_Namespace_insert(ns, &n1, 0);
-	UA_Node* n2; createNode(&n2,0,2255); UA_Namespace_insert(ns, &n2, 0);
-	UA_Node* n3; createNode(&n3,0,2257); UA_Namespace_insert(ns, &n3, 0);
-	UA_Node* n4; createNode(&n4,0,2200); UA_Namespace_insert(ns, &n4, 0);
-	UA_Node* n5; createNode(&n5,0,1); UA_Namespace_insert(ns, &n5, 0);
-	UA_Node* n6; createNode(&n6,0,12); UA_Namespace_insert(ns, &n6, 0);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
+	UA_Node* n1; createNode(&n1,0,2253); UA_NodeStore_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); UA_NodeStore_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); UA_NodeStore_insert(ns, &n3, 0);
+	UA_Node* n4; createNode(&n4,0,2200); UA_NodeStore_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); UA_NodeStore_insert(ns, &n5, 0);
+	UA_Node* n6; createNode(&n6,0,12); UA_NodeStore_insert(ns, &n6, 0);
 
 	UA_Int32 retval;
 	// when
 	zeroCnt = 0;
 	visitCnt = 0;
-	retval = UA_Namespace_iterate(ns,checkZeroVisitor);
+	retval = UA_NodeStore_iterate(ns,checkZeroVisitor);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(zeroCnt, 0);
 	ck_assert_int_eq(visitCnt, 6);
 	// finally
-	UA_Namespace_delete(ns);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
@@ -158,25 +158,25 @@ START_TEST(findNodeInExpandedNamespace) {
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
 	UA_Node* n;
 	UA_Int32 i=0;
 	for (; i<200; i++) {
-		createNode(&n,0,i); UA_Namespace_insert(ns, &n, 0);
+		createNode(&n,0,i); UA_NodeStore_insert(ns, &n, 0);
 	}
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
 	// when
 	createNode(&n,0,25);
-	retval = UA_Namespace_get(ns,&(n->nodeId),&nr);
+	retval = UA_NodeStore_get(ns,&(n->nodeId),&nr);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(nr->nodeId.identifier.numeric,n->nodeId.identifier.numeric);
 	// finally
 	UA_free((void*)n);
-	UA_Namespace_releaseManagedNode(nr);
-	UA_Namespace_delete(ns);
+	UA_NodeStore_releaseManagedNode(nr);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
@@ -188,53 +188,53 @@ START_TEST(iterateOverExpandedNamespaceShallNotVisitEmptyNodes) {
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
 	UA_Node* n;
 	UA_Int32 i=0;
 	for (; i<200; i++) {
-		createNode(&n,0,i); UA_Namespace_insert(ns, &n, 0);
+		createNode(&n,0,i); UA_NodeStore_insert(ns, &n, 0);
 	}
 	// when
 	UA_Int32 retval;
 	zeroCnt = 0;
 	visitCnt = 0;
-	retval = UA_Namespace_iterate(ns,checkZeroVisitor);
+	retval = UA_NodeStore_iterate(ns,checkZeroVisitor);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(zeroCnt, 0);
 	ck_assert_int_eq(visitCnt, 200);
 	// finally
-	UA_Namespace_delete(ns);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
 }
 END_TEST
 
-START_TEST(failToFindNonExistantNodeInUA_NamespaceWithSeveralEntries) {
+START_TEST(failToFindNonExistantNodeInUA_NodeStoreWithSeveralEntries) {
 #ifdef MULTITHREADING
    	rcu_register_thread();
 #endif
 	// given
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
-	UA_Node* n1; createNode(&n1,0,2253); UA_Namespace_insert(ns, &n1, 0);
-	UA_Node* n2; createNode(&n2,0,2255); UA_Namespace_insert(ns, &n2, 0);
-	UA_Node* n3; createNode(&n3,0,2257); UA_Namespace_insert(ns, &n3, 0);
-	UA_Node* n4; createNode(&n4,0,2200); UA_Namespace_insert(ns, &n4, 0);
-	UA_Node* n5; createNode(&n5,0,1); UA_Namespace_insert(ns, &n5, 0);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
+	UA_Node* n1; createNode(&n1,0,2253); UA_NodeStore_insert(ns, &n1, 0);
+	UA_Node* n2; createNode(&n2,0,2255); UA_NodeStore_insert(ns, &n2, 0);
+	UA_Node* n3; createNode(&n3,0,2257); UA_NodeStore_insert(ns, &n3, 0);
+	UA_Node* n4; createNode(&n4,0,2200); UA_NodeStore_insert(ns, &n4, 0);
+	UA_Node* n5; createNode(&n5,0,1); UA_NodeStore_insert(ns, &n5, 0);
 	UA_Node* n6; createNode(&n6,0,12); 
 
 	const UA_Node* nr = UA_NULL;
 	UA_Int32 retval;
 	// when
-	retval = UA_Namespace_get(ns, &(n6->nodeId), &nr);
+	retval = UA_NodeStore_get(ns, &(n6->nodeId), &nr);
 	// then
 	ck_assert_int_ne(retval, UA_SUCCESS);
 	// finally
 	UA_free((void *)n6);
-	UA_Namespace_delete(ns);
+	UA_NodeStore_delete(ns);
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
 #endif
@@ -246,8 +246,8 @@ END_TEST
 /************************************/
 
 #ifdef MULTITHREADING
-struct UA_NamespaceProfileTest {
-	UA_Namespace *ns;
+struct UA_NodeStoreProfileTest {
+	UA_NodeStore *ns;
 	UA_Int32 min_val;
 	UA_Int32 max_val;
 	UA_Int32 rounds;
@@ -255,16 +255,16 @@ struct UA_NamespaceProfileTest {
 
 void *profileGetThread(void *arg) {
    	rcu_register_thread();
-	struct UA_NamespaceProfileTest *test = (struct UA_NamespaceProfileTest*) arg;
+	struct UA_NodeStoreProfileTest *test = (struct UA_NodeStoreProfileTest*) arg;
 	UA_NodeId id = NS0NODEID(0);
 	const UA_Node *cn;
 	UA_Int32 max_val = test->max_val;
-	UA_Namespace *ns = test->ns;
+	UA_NodeStore *ns = test->ns;
 	for(UA_Int32 x = 0; x<test->rounds; x++) {
 		for (UA_Int32 i=test->min_val; i<max_val; i++) {
 			id.identifier.numeric = i;
-			UA_Namespace_get(ns,&id, &cn);
-			UA_Namespace_releaseManagedNode(cn);
+			UA_NodeStore_get(ns,&id, &cn);
+			UA_NodeStore_releaseManagedNode(cn);
 		}
 	}
 	rcu_unregister_thread();
@@ -279,21 +279,21 @@ START_TEST(profileGetDelete) {
 #endif
 
 #define N 1000000
-	UA_Namespace *ns;
-	UA_Namespace_new(&ns);
+	UA_NodeStore *ns;
+	UA_NodeStore_new(&ns);
 	UA_Int32 i=0;
 	UA_Node *n;
 	for (; i<N; i++) {
-		createNode(&n,0,i); UA_Namespace_insert(ns, &n, 0);
+		createNode(&n,0,i); UA_NodeStore_insert(ns, &n, 0);
 	}
 	clock_t begin, end;
 	begin = clock();
 #ifdef MULTITHREADING
 #define THREADS 4
     pthread_t t[THREADS];
-	struct UA_NamespaceProfileTest p[THREADS];
+	struct UA_NodeStoreProfileTest p[THREADS];
 	for (int i = 0; i < THREADS; i++) {
-		p[i] = (struct UA_NamespaceProfileTest){ns, i*(N/THREADS), (i+1)*(N/THREADS), 50};
+		p[i] = (struct UA_NodeStoreProfileTest){ns, i*(N/THREADS), (i+1)*(N/THREADS), 50};
 		pthread_create(&t[i], NULL, profileGetThread, &p[i]);
 	}
 	for (int i = 0; i < THREADS; i++)
@@ -306,15 +306,15 @@ START_TEST(profileGetDelete) {
 	for(UA_Int32 x = 0; x<50; x++) {
 	    for(i=0; i<N; i++) {
 	        id.identifier.numeric = i;
-			UA_Namespace_get(ns,&id, &cn);
-			UA_Namespace_releaseManagedNode(cn);
+			UA_NodeStore_get(ns,&id, &cn);
+			UA_NodeStore_releaseManagedNode(cn);
         }
     }
 	end = clock();
 	printf("Time for single-threaded %d create/get/delete in a namespace: %fs.\n", N, (double)(end - begin) / CLOCKS_PER_SEC);
 #endif
 
-	UA_Namespace_delete(ns);
+	UA_NodeStore_delete(ns);
 
 #ifdef MULTITHREADING
 	rcu_unregister_thread();
@@ -323,22 +323,22 @@ START_TEST(profileGetDelete) {
 END_TEST
 
 Suite * namespace_suite (void) {
-	Suite *s = suite_create ("UA_Namespace");
+	Suite *s = suite_create ("UA_NodeStore");
 
 	TCase *tc_cd = tcase_create ("Create/Delete");
-	tcase_add_test (tc_cd, test_UA_Namespace);
+	tcase_add_test (tc_cd, test_UA_NodeStore);
 	suite_add_tcase (s, tc_cd);
 
 	TCase* tc_find = tcase_create ("Find");
-	tcase_add_test (tc_find, findNodeInUA_NamespaceWithSingleEntry);
-	tcase_add_test (tc_find, findNodeInUA_NamespaceWithSeveralEntries);
+	tcase_add_test (tc_find, findNodeInUA_NodeStoreWithSingleEntry);
+	tcase_add_test (tc_find, findNodeInUA_NodeStoreWithSeveralEntries);
 	tcase_add_test (tc_find, findNodeInExpandedNamespace);
-	tcase_add_test (tc_find, failToFindNonExistantNodeInUA_NamespaceWithSeveralEntries);
-	tcase_add_test (tc_find, failToFindNodeInOtherUA_Namespace);
+	tcase_add_test (tc_find, failToFindNonExistantNodeInUA_NodeStoreWithSeveralEntries);
+	tcase_add_test (tc_find, failToFindNodeInOtherUA_NodeStore);
 	suite_add_tcase (s, tc_find);
 
 	TCase* tc_iterate = tcase_create ("Iterate");
-	tcase_add_test (tc_iterate, iterateOverUA_NamespaceShallNotVisitEmptyNodes);
+	tcase_add_test (tc_iterate, iterateOverUA_NodeStoreShallNotVisitEmptyNodes);
 	tcase_add_test (tc_iterate, iterateOverExpandedNamespaceShallNotVisitEmptyNodes);
 	suite_add_tcase (s, tc_iterate);
 	

+ 9 - 9
tests/check_stack.c

@@ -434,20 +434,20 @@ START_TEST(validCreateSessionShallCreateSession) {
 }
 END_TEST
 
-START_TEST(UA_OPCUATcpMessageHeader_copyShallWorkOnInputExample) {
+START_TEST(UA_TcpMessageHeader_copyShallWorkOnInputExample) {
 	// given
-	UA_OPCUATcpMessageHeader src;
-	UA_OPCUATcpMessageHeader_init(&src);
+	UA_TcpMessageHeader src;
+	UA_TcpMessageHeader_init(&src);
 	src.isFinal = 2;
 	src.messageSize = 43;
 	src.messageType = UA_MESSAGETYPE_MSG;
-	const UA_OPCUATcpMessageHeader srcConst = src;
+	const UA_TcpMessageHeader srcConst = src;
 
-	UA_OPCUATcpMessageHeader dst;
+	UA_TcpMessageHeader dst;
 	UA_Int32 ret;
 
 	// when
-	ret = UA_OPCUATcpMessageHeader_copy(&srcConst, &dst);
+	ret = UA_TcpMessageHeader_copy(&srcConst, &dst);
 	// then
 	ck_assert_int_eq(ret, UA_SUCCESS);
 	ck_assert_int_eq(UA_MESSAGETYPE_MSG, dst.messageType);
@@ -488,8 +488,8 @@ START_TEST(UA_SecureConversationMessageHeader_copyShallWorkOnInputExample) {
 	UA_SecureConversationMessageHeader src;
 	UA_SecureConversationMessageHeader_init(&src);
 	src.secureChannelId = 84;
-	UA_OPCUATcpMessageHeader srcHeader;
-	UA_OPCUATcpMessageHeader_init(&srcHeader);
+	UA_TcpMessageHeader srcHeader;
+	UA_TcpMessageHeader_init(&srcHeader);
 	srcHeader.isFinal = 4;
 	srcHeader.messageSize = 765;
 	srcHeader.messageType = UA_MESSAGETYPE_CLO;
@@ -634,7 +634,7 @@ Suite *testSuite() {
 	suite_add_tcase(s, tc_core);
 
 	TCase *tc_transport = tcase_create("Transport");
-	tcase_add_test(tc_transport, UA_OPCUATcpMessageHeader_copyShallWorkOnInputExample);
+	tcase_add_test(tc_transport, UA_TcpMessageHeader_copyShallWorkOnInputExample);
 	tcase_add_test(tc_transport, UA_AsymmetricAlgorithmSecurityHeader_copyShallWorkOnInputExample);
 	tcase_add_test(tc_transport, UA_SecureConversationMessageHeader_copyShallWorkOnInputExample);
 	tcase_add_test(tc_transport, UA_SequenceHeader_copyShallWorkOnInputExample);