1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027 |
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include "check.h"
- #include "server/ua_nodestore.h"
- #include "server/ua_services.h"
- #include "ua_client.h"
- #include "ua_nodeids.h"
- #include "ua_types.h"
- #include "ua_config_standard.h"
- #include "server/ua_server_internal.h"
- static UA_StatusCode
- readCPUTemperature(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp,
- const UA_NumericRange *range, UA_DataValue *dataValue) {
- UA_Float temp = 20.5f;
- UA_Variant_setScalarCopy(&dataValue->value, &temp, &UA_TYPES[UA_TYPES_FLOAT]);
- dataValue->hasValue = true;
- return UA_STATUSCODE_GOOD;
- }
- static UA_Server *
- makeTestSequence(void) {
- UA_Server * server = UA_Server_new(UA_ServerConfig_standard);
- UA_StatusCode retval = UA_STATUSCODE_GOOD;
- /* VariableNode */
- UA_VariableAttributes vattr;
- UA_VariableAttributes_init(&vattr);
- UA_Int32 myInteger = 42;
- UA_Variant_setScalar(&vattr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
- vattr.description = UA_LOCALIZEDTEXT("locale","the answer");
- vattr.displayName = UA_LOCALIZEDTEXT("locale","the answer");
- vattr.valueRank = -2;
- UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
- UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
- UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
- UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
- retval = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
- parentReferenceNodeId, myIntegerName,
- UA_NODEID_NULL, vattr, NULL, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- /* DataSource VariableNode */
- UA_VariableAttributes_init(&vattr);
- UA_DataSource temperatureDataSource =
- (UA_DataSource) {.handle = NULL, .read = readCPUTemperature, .write = NULL};
- vattr.description = UA_LOCALIZEDTEXT("en_US","temperature");
- vattr.displayName = UA_LOCALIZEDTEXT("en_US","temperature");
- retval = UA_Server_addDataSourceVariableNode(server, UA_NODEID_STRING(1, "cpu.temperature"),
- UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
- UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
- UA_QUALIFIEDNAME(1, "cpu temperature"),
- UA_NODEID_NULL, vattr, temperatureDataSource, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- /* VariableNode with array */
- UA_VariableAttributes_init(&vattr);
- UA_Int32 myIntegerArray[9] = {1,2,3,4,5,6,7,8,9};
- UA_Variant_setArray(&vattr.value, &myIntegerArray, 9, &UA_TYPES[UA_TYPES_INT32]);
- vattr.valueRank = -2;
- UA_UInt32 myIntegerDimensions[2] = {3,3};
- vattr.value.arrayDimensions = myIntegerDimensions;
- vattr.value.arrayDimensionsSize = 2;
- vattr.displayName = UA_LOCALIZEDTEXT("locale","myarray");
- myIntegerName = UA_QUALIFIEDNAME(1, "myarray");
- myIntegerNodeId = UA_NODEID_STRING(1, "myarray");
- parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
- parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
- retval = UA_Server_addVariableNode(server, myIntegerNodeId, parentNodeId,
- parentReferenceNodeId, myIntegerName,
- UA_NODEID_NULL, vattr, NULL, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- /* ObjectNode */
- UA_ObjectAttributes obj_attr;
- UA_ObjectAttributes_init(&obj_attr);
- obj_attr.description = UA_LOCALIZEDTEXT("en_US","Demo");
- obj_attr.displayName = UA_LOCALIZEDTEXT("en_US","Demo");
- retval = UA_Server_addObjectNode(server, UA_NODEID_NUMERIC(1, 50),
- UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
- UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
- UA_QUALIFIEDNAME(1, "Demo"),
- UA_NODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE),
- obj_attr, NULL, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- /* ViewNode */
- UA_ViewAttributes view_attr;
- UA_ViewAttributes_init(&view_attr);
- view_attr.description = UA_LOCALIZEDTEXT("en_US", "Viewtest");
- view_attr.displayName = UA_LOCALIZEDTEXT("en_US", "Viewtest");
- retval = UA_Server_addViewNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWNODE),
- UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWSFOLDER),
- UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
- UA_QUALIFIEDNAME(0, "Viewtest"), view_attr, NULL, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- #ifdef UA_ENABLE_METHODCALLS
- /* MethodNode */
- UA_MethodAttributes ma;
- UA_MethodAttributes_init(&ma);
- ma.description = UA_LOCALIZEDTEXT("en_US", "Methodtest");
- ma.displayName = UA_LOCALIZEDTEXT("en_US", "Methodtest");
- retval = UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(0, UA_NS0ID_METHODNODE),
- UA_NODEID_NUMERIC(0, 3),
- UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
- UA_QUALIFIEDNAME(0, "Methodtest"), ma,
- NULL, NULL, 0, NULL, 0, NULL, NULL);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- #endif
- return server;
- }
- static UA_VariableNode* makeCompareSequence(void) {
- UA_VariableNode *node = UA_NodeStore_newVariableNode();
- UA_Int32 myInteger = 42;
- UA_Variant_setScalarCopy(&node->value.data.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
- node->value.data.value.hasValue = true;
- const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
- UA_QualifiedName_copy(&myIntegerName,&node->browseName);
- const UA_LocalizedText myIntegerDisplName = UA_LOCALIZEDTEXT("locale", "the answer");
- UA_LocalizedText_copy(&myIntegerDisplName, &node->displayName);
- UA_LocalizedText_copy(&myIntegerDisplName, &node->description);
- const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
- UA_NodeId_copy(&myIntegerNodeId,&node->nodeId);
- return node;
- }
- START_TEST(ReadSingleAttributeValueWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(resp.status, UA_STATUSCODE_GOOD);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
- ck_assert_int_eq(42, *(UA_Int32* )resp.value.data);
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- START_TEST(ReadSingleAttributeValueRangeWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "myarray");
- rvi.indexRange = UA_STRING("1:2,0:1");
- rvi.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(4, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- START_TEST(ReadSingleAttributeNodeIdWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_NODEID;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- const UA_NodeId myIntegerNodeId = UA_NODEID_STRING(1, "the.answer");
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
- UA_NodeId* respval = (UA_NodeId*) resp.value.data;
- ck_assert_int_eq(1, respval->namespaceIndex);
- ck_assert(UA_String_equal(&myIntegerNodeId.identifier.string, &respval->identifier.string));
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeNodeClassWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_NODECLASS;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODECLASS],resp.value.type);
- ck_assert_int_eq(*(UA_Int32*)resp.value.data,UA_NODECLASS_VARIABLE);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeBrowseNameWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_BROWSENAME;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
-
- UA_QualifiedName* respval = (UA_QualifiedName*) resp.value.data;
- const UA_QualifiedName myIntegerName = UA_QUALIFIEDNAME(1, "the answer");
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_QUALIFIEDNAME], resp.value.type);
- ck_assert_int_eq(1, respval->namespaceIndex);
- ck_assert(UA_String_equal(&myIntegerName.name, &respval->name));
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeDisplayNameWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
- const UA_LocalizedText comp = UA_LOCALIZEDTEXT("locale", "the answer");
- UA_VariableNode* compNode = makeCompareSequence();
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
- ck_assert(UA_String_equal(&comp.text, &respval->text));
- ck_assert(UA_String_equal(&compNode->displayName.locale, &respval->locale));
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- UA_NodeStore_deleteNode((UA_Node*)compNode);
- } END_TEST
- START_TEST(ReadSingleAttributeDescriptionWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_DESCRIPTION;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
-
- UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
- UA_VariableNode* compNode = makeCompareSequence();
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT], resp.value.type);
- ck_assert(UA_String_equal(&compNode->description.locale, &respval->locale));
- ck_assert(UA_String_equal(&compNode->description.text, &respval->text));
- UA_DataValue_deleteMembers(&resp);
- UA_NodeStore_deleteNode((UA_Node*)compNode);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeWriteMaskWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_WRITEMASK;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
-
- UA_UInt32* respval = (UA_UInt32*) resp.value.data;
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type);
- ck_assert_int_eq(0,*respval);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeUserWriteMaskWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_USERWRITEMASK;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- /* Uncommented since the userwritemask is always 0xffffffff for the local admin user */
- /* UA_UInt32* respval = (UA_UInt32*) resp.value.data; */
- /* ck_assert_int_eq(0, resp.value.arrayLength); */
- /* ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_UINT32], resp.value.type); */
- /* ck_assert_int_eq(0,*respval); */
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeIsAbstractWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
- rvi.attributeId = UA_ATTRIBUTEID_ISABSTRACT;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
- ck_assert(*(UA_Boolean* )resp.value.data==false);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeSymmetricWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
- rvi.attributeId = UA_ATTRIBUTEID_SYMMETRIC;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
- ck_assert(*(UA_Boolean* )resp.value.data==false);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeInverseNameWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
- rvi.attributeId = UA_ATTRIBUTEID_INVERSENAME;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- UA_LocalizedText* respval = (UA_LocalizedText*) resp.value.data;
- const UA_LocalizedText comp = UA_LOCALIZEDTEXT("en_US", "OrganizedBy");
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_LOCALIZEDTEXT],resp.value.type);
- ck_assert(UA_String_equal(&comp.text, &respval->text));
- ck_assert(UA_String_equal(&comp.locale, &respval->locale));
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeContainsNoLoopsWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWNODE);
- rvi.attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
- ck_assert(*(UA_Boolean* )resp.value.data==false);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeEventNotifierWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(1, 50);
- rvi.attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE],resp.value.type);
- ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeDataTypeWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_DATATYPE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
- ck_assert_int_eq(true, resp.hasValue);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_NODEID], resp.value.type);
- UA_NodeId* respval = (UA_NodeId*)resp.value.data;
- ck_assert_int_eq(respval->namespaceIndex,0);
- ck_assert_int_eq(respval->identifier.numeric, UA_NS0ID_BASEDATATYPE);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeValueRankWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_VALUERANK;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
- ck_assert_int_eq(-2, *(UA_Int32* )resp.value.data);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeArrayDimensionsWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_INT32], resp.value.type);
- ck_assert_ptr_eq((UA_Int32*)resp.value.data,0);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeAccessLevelWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type);
- ck_assert_int_eq(*(UA_Byte*)resp.value.data, 0);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeUserAccessLevelWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_USERACCESSLEVEL;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- /* Uncommented since the accesslevel is always 0xff for the local admin user */
- /* UA_RCU_LOCK(); */
- /* const UA_VariableNode* compNode = */
- /* (const UA_VariableNode*)UA_NodeStore_get(server->nodestore, &rvi.nodeId); */
- /* ck_assert_int_eq(0, resp.value.arrayLength); */
- /* ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BYTE], resp.value.type); */
- /* ck_assert_int_eq(*(UA_Byte*)resp.value.data, compNode->accessLevel & 0xFF); // 0xFF is the default userAccessLevel */
- /* UA_RCU_UNLOCK(); */
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- START_TEST(ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
-
- UA_Double* respval = (UA_Double*) resp.value.data;
- UA_VariableNode *compNode = makeCompareSequence();
- UA_Double comp = (UA_Double) compNode->minimumSamplingInterval;
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_DOUBLE], resp.value.type);
- ck_assert(*respval == comp);
- UA_DataValue_deleteMembers(&resp);
- UA_NodeStore_deleteNode((UA_Node*)compNode);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeHistorizingWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_HISTORIZING;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
- ck_assert(*(UA_Boolean*)resp.value.data==false);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeExecutableWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- #ifdef UA_ENABLE_METHODCALLS
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_METHODNODE);
- rvi.attributeId = UA_ATTRIBUTEID_EXECUTABLE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(true, resp.hasValue);
- ck_assert_int_eq(0, resp.value.arrayLength);
- ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type);
- ck_assert(*(UA_Boolean*)resp.value.data==false);
- UA_DataValue_deleteMembers(&resp);
- #endif
- UA_Server_delete(server);
- } END_TEST
- START_TEST(ReadSingleAttributeUserExecutableWithoutTimestamp) {
- #ifdef UA_ENABLE_METHODCALLS
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_METHODNODE);
- rvi.attributeId = UA_ATTRIBUTEID_USEREXECUTABLE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- /* Uncommented since userexecutable is always true for the local admin user */
- /* ck_assert_int_eq(0, resp.value.arrayLength); */
- /* ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type); */
- /* ck_assert(*(UA_Boolean*)resp.value.data==false); */
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- #endif
- } END_TEST
- START_TEST(ReadSingleDataSourceAttributeValueWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
- rvi.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- START_TEST(ReadSingleDataSourceAttributeDataTypeWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
- rvi.attributeId = UA_ATTRIBUTEID_DATATYPE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
- ck_assert_int_eq(resp.hasServerTimestamp, false);
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- START_TEST (ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp) {
- UA_Server *server = makeTestSequence();
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
- rvi.attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
-
- ck_assert_int_eq(UA_STATUSCODE_GOOD, resp.status);
- UA_Server_delete(server);
- UA_DataValue_deleteMembers(&resp);
- } END_TEST
- /* Tests for writeValue method */
- START_TEST(WriteSingleAttributeNodeId) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_NodeId id;
- UA_NodeId_init(&id);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_NODEID;
- wValue.value.hasValue = true;
- UA_Variant_setScalar(&wValue.value.value, &id, &UA_TYPES[UA_TYPES_NODEID]);
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeNodeclass) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- UA_NodeClass class;
- UA_NodeClass_init(&class);
- wValue.attributeId = UA_ATTRIBUTEID_NODECLASS;
- wValue.value.hasValue = true;
- UA_Variant_setScalar(&wValue.value.value, &class, &UA_TYPES[UA_TYPES_NODECLASS]);
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeBrowseName) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_QualifiedName testValue = UA_QUALIFIEDNAME(1, "the.answer");
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_QUALIFIEDNAME]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_BROWSENAME;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeDisplayName) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_EN", "the.answer");
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
- wValue.value.hasValue = true;
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_DISPLAYNAME;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeDescription) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_EN", "the.answer");
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
- wValue.value.hasValue = true;
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_DESCRIPTION;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeWriteMask) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 testValue = 0;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_UINT32]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_WRITEMASK;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeIsAbstract) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Boolean testValue = true;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_ISABSTRACT;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeSymmetric) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Boolean testValue = true;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_SYMMETRIC;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeInverseName) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_LocalizedText testValue = UA_LOCALIZEDTEXT("en_US", "not.the.answer");
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_INVERSENAME;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeContainsNoLoops) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Boolean testValue = true;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_CONTAINSNOLOOPS;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeEventNotifier) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Byte testValue = 0;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_EVENTNOTIFIER;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeValue) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 myInteger = 20;
- UA_Variant_setScalar(&wValue.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
- wValue.value.hasValue = true;
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_ReadValueId rvi;
- UA_ReadValueId_init(&rvi);
- rvi.nodeId = UA_NODEID_STRING(1, "the.answer");
- rvi.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_DataValue resp = UA_Server_read(server, &rvi, UA_TIMESTAMPSTORETURN_NEITHER);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- ck_assert(resp.hasValue);
- ck_assert_int_eq(20, *(UA_Int32*)resp.value.data);
- UA_DataValue_deleteMembers(&resp);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeValueRangeFromScalar) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 myInteger = 20;
- UA_Variant_setScalar(&wValue.value.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]);
- wValue.value.hasValue = true;
- wValue.nodeId = UA_NODEID_STRING(1, "myarray");
- wValue.indexRange = UA_STRING("0,0");
- wValue.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeValueRangeFromArray) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 myInteger = 20;
- UA_Variant_setArray(&wValue.value.value, &myInteger, 1, &UA_TYPES[UA_TYPES_INT32]);
- wValue.value.hasValue = true;
- wValue.nodeId = UA_NODEID_STRING(1, "myarray");
- wValue.indexRange = UA_STRING("0,0");
- wValue.attributeId = UA_ATTRIBUTEID_VALUE;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeDataType) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_NodeId typeId;
- UA_NodeId_init(&typeId);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_DATATYPE;
- wValue.value.hasValue = true;
- UA_Variant_setScalar(&wValue.value.value, &typeId, &UA_TYPES[UA_TYPES_NODEID]);
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADTYPEMISMATCH);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeValueRank) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 testValue = -1;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_VALUERANK;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- // Returns attributeInvalid, since variant/value may be writable
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeArrayDimensions) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_UInt32 testValue[] = {1,1,1};
- UA_Variant_setArray(&wValue.value.value, &testValue, 3, &UA_TYPES[UA_TYPES_UINT32]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_ARRAYDIMENSIONS;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- // Returns attributeInvalid, since variant/value may be writable
- ck_assert_int_eq(retval, UA_STATUSCODE_BADTYPEMISMATCH);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeAccessLevel) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Byte testValue = 0;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BYTE]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_ACCESSLEVEL;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeMinimumSamplingInterval) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Double testValue = 0.0;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_DOUBLE]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeHistorizing) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Boolean testValue = true;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_HISTORIZING;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleAttributeExecutable) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Boolean testValue = true;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_BOOLEAN]);
- wValue.nodeId = UA_NODEID_STRING(1, "the.answer");
- wValue.attributeId = UA_ATTRIBUTEID_EXECUTABLE;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADNODECLASSINVALID);
- UA_Server_delete(server);
- } END_TEST
- START_TEST(WriteSingleDataSourceAttributeValue) {
- UA_Server *server = makeTestSequence();
- UA_WriteValue wValue;
- UA_WriteValue_init(&wValue);
- UA_Int32 testValue = 0;
- UA_Variant_setScalar(&wValue.value.value, &testValue, &UA_TYPES[UA_TYPES_INT32]);
- wValue.nodeId = UA_NODEID_STRING(1, "cpu.temperature");
- wValue.attributeId = UA_ATTRIBUTEID_VALUE;
- wValue.value.hasValue = true;
- UA_StatusCode retval = UA_Server_write(server, &wValue);
- ck_assert_int_eq(retval, UA_STATUSCODE_BADWRITENOTSUPPORTED);
- UA_Server_delete(server);
- } END_TEST
- static Suite * testSuite_services_attributes(void) {
- Suite *s = suite_create("services_attributes_read");
- TCase *tc_readSingleAttributes = tcase_create("readSingleAttributes");
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRangeWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeIdWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeNodeClassWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeBrowseNameWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDisplayNameWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDescriptionWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeWriteMaskWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserWriteMaskWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeIsAbstractWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeSymmetricWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeInverseNameWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeContainsNoLoopsWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeEventNotifierWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeDataTypeWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeValueRankWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeArrayDimensionsWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeAccessLevelWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserAccessLevelWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeMinimumSamplingIntervalWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeHistorizingWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeExecutableWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleAttributeUserExecutableWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeValueWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeDataTypeWithoutTimestamp);
- tcase_add_test(tc_readSingleAttributes, ReadSingleDataSourceAttributeArrayDimensionsWithoutTimestamp);
- suite_add_tcase(s, tc_readSingleAttributes);
- TCase *tc_writeSingleAttributes = tcase_create("writeSingleAttributes");
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeId);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeNodeclass);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeBrowseName);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDisplayName);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDescription);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeWriteMask);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeIsAbstract);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeSymmetric);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeInverseName);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeContainsNoLoops);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeEventNotifier);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValue);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeDataType);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRangeFromScalar);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRangeFromArray);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeValueRank);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeArrayDimensions);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeAccessLevel);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeMinimumSamplingInterval);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeHistorizing);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleAttributeExecutable);
- tcase_add_test(tc_writeSingleAttributes, WriteSingleDataSourceAttributeValue);
- suite_add_tcase(s, tc_writeSingleAttributes);
- return s;
- }
- int main(void) {
- int number_failed = 0;
- Suite *s;
- s = testSuite_services_attributes();
- SRunner *sr = srunner_create(s);
- srunner_set_fork_status(sr, CK_NOFORK);
- srunner_run_all(sr, CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
- }
|