-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5754d
commit 74daf75
Showing
4 changed files
with
186 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* 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 "check.h" | ||
#include <NodesetLoader/backendOpen62541.h> | ||
#include <NodesetLoader/dataTypes.h> | ||
#include <open62541/server.h> | ||
#include <open62541/server_config_default.h> | ||
#include <open62541/types.h> | ||
|
||
#include "testHelper.h" | ||
|
||
UA_Server *server; | ||
char *nodesetPath = NULL; | ||
|
||
static void setup(void) | ||
{ | ||
printf("path to testnodesets %s\n", nodesetPath); | ||
server = UA_Server_new(); | ||
UA_ServerConfig *config = UA_Server_getConfig(server); | ||
UA_ServerConfig_setDefault(config); | ||
} | ||
|
||
static void teardown(void) | ||
{ | ||
UA_Server_run_shutdown(server); | ||
#ifdef USE_CLEANUP_CUSTOM_DATATYPES | ||
const UA_DataTypeArray *customTypes = | ||
UA_Server_getConfig(server)->customDataTypes; | ||
#endif | ||
UA_Server_delete(server); | ||
#ifdef USE_CLEANUP_CUSTOM_DATATYPES | ||
NodesetLoader_cleanupCustomDataTypes(customTypes); | ||
#endif | ||
} | ||
|
||
START_TEST(Server_Issue_241) | ||
{ | ||
ck_assert(NodesetLoader_loadFile(server, nodesetPath, NULL)); | ||
|
||
UA_Variant var; | ||
UA_Variant_init(&var); | ||
UA_StatusCode retval = UA_Server_readValue( | ||
server, UA_NODEID_STRING(2, "Demo.Static.Arrays.StatusCode"), &var); | ||
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); | ||
|
||
ck_assert(var.type = &UA_TYPES[UA_TYPES_STATUSCODE]); | ||
ck_assert(var.arrayLength==10); | ||
|
||
UA_StatusCode *first = (UA_StatusCode*)var.data; | ||
ck_assert(*first == 0u); | ||
UA_StatusCode last = first[9]; | ||
ck_assert(last == 2151022592u); | ||
|
||
UA_Variant_clear(&var); | ||
} | ||
END_TEST | ||
|
||
static Suite *testSuite_Client(void) | ||
{ | ||
Suite *s = suite_create("server nodeset import"); | ||
TCase *tc_server = tcase_create("server nodeset import"); | ||
tcase_add_unchecked_fixture(tc_server, setup, teardown); | ||
tcase_add_test(tc_server, Server_Issue_241); | ||
suite_add_tcase(s, tc_server); | ||
return s; | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
printf("%s", argv[0]); | ||
if (!(argc > 1)) | ||
return 1; | ||
nodesetPath = argv[1]; | ||
Suite *s = testSuite_Client(); | ||
SRunner *sr = srunner_create(s); | ||
srunner_set_fork_status(sr, CK_NOFORK); | ||
srunner_run_all(sr, CK_NORMAL); | ||
int number_failed = srunner_ntests_failed(sr); | ||
srunner_free(sr); | ||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd"> | ||
<NamespaceUris> | ||
<Uri>http://www.unifiedautomation.com/DemoServer/</Uri> | ||
</NamespaceUris> | ||
<Aliases> | ||
<Alias Alias="Boolean">i=1</Alias> | ||
<Alias Alias="SByte">i=2</Alias> | ||
<Alias Alias="Byte">i=3</Alias> | ||
<Alias Alias="Int16">i=4</Alias> | ||
<Alias Alias="UInt16">i=5</Alias> | ||
<Alias Alias="Int32">i=6</Alias> | ||
<Alias Alias="UInt32">i=7</Alias> | ||
<Alias Alias="Int64">i=8</Alias> | ||
<Alias Alias="UInt64">i=9</Alias> | ||
<Alias Alias="Float">i=10</Alias> | ||
<Alias Alias="Double">i=11</Alias> | ||
<Alias Alias="String">i=12</Alias> | ||
<Alias Alias="DateTime">i=13</Alias> | ||
<Alias Alias="Guid">i=14</Alias> | ||
<Alias Alias="ByteString">i=15</Alias> | ||
<Alias Alias="XmlElement">i=16</Alias> | ||
<Alias Alias="NodeId">i=17</Alias> | ||
<Alias Alias="ExpandedNodeId">i=18</Alias> | ||
<Alias Alias="StatusCode">i=19</Alias> | ||
<Alias Alias="QualifiedName">i=20</Alias> | ||
<Alias Alias="LocalizedText">i=21</Alias> | ||
<Alias Alias="Structure">i=22</Alias> | ||
<Alias Alias="BaseDataType">i=24</Alias> | ||
<Alias Alias="Number">i=26</Alias> | ||
<Alias Alias="Integer">i=27</Alias> | ||
<Alias Alias="UInteger">i=28</Alias> | ||
<Alias Alias="Organizes">i=35</Alias> | ||
<Alias Alias="HasTypeDefinition">i=40</Alias> | ||
<Alias Alias="Duration">i=290</Alias> | ||
<Alias Alias="NumericRange">i=291</Alias> | ||
<Alias Alias="UtcTime">i=294</Alias> | ||
<Alias Alias="ServerState">i=852</Alias> | ||
<Alias Alias="ImagePNG">i=2003</Alias> | ||
</Aliases> | ||
<UAVariable NodeId="ns=1;s=Demo.Static.Arrays.StatusCode" BrowseName="1:StatusCode" ParentNodeId="i=85" ValueRank="1" ArrayDimensions="10" DataType="StatusCode" AccessLevel="3" UserAccessLevel="3"> | ||
<DisplayName>StatusCode</DisplayName> | ||
<References> | ||
<Reference ReferenceType="HasTypeDefinition">i=63</Reference> | ||
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference> | ||
</References> | ||
<Value> | ||
<uax:ListOfStatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>0</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2150694912</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2150825984</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2151022592</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2151284736</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2151677952</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>0</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2150694912</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2150825984</uax:Code> | ||
</uax:StatusCode> | ||
<uax:StatusCode> | ||
<uax:Code>2151022592</uax:Code> | ||
</uax:StatusCode> | ||
</uax:ListOfStatusCode> | ||
</Value> | ||
</UAVariable> | ||
</UANodeSet> |