check_pubsub_multiple_layer.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright (c) 2017 - 2018 Fraunhofer IOSB (Author: Andreas Ebner)
  6. */
  7. #include <open62541/plugin/pubsub_udp.h>
  8. #include <open62541/server_config_default.h>
  9. #include <open62541/server_pubsub.h>
  10. #include "open62541/types_generated_encoding_binary.h"
  11. #include "ua_server_internal.h"
  12. #include <check.h>
  13. UA_Server *server = NULL;
  14. UA_NodeId connection1, connection2;
  15. static void setup(void) {
  16. }
  17. static void teardown(void) {
  18. }
  19. START_TEST(AddMultipleTransportLayers){
  20. server = UA_Server_new();
  21. UA_ServerConfig *config = UA_Server_getConfig(server);
  22. UA_ServerConfig_setDefault(config);
  23. UA_PubSubTransportLayer pubsubTransportLayer;
  24. ck_assert_int_eq(config->pubsubTransportLayersSize, 0);
  25. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  26. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  27. ck_assert_int_eq(config->pubsubTransportLayersSize, 1);
  28. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  29. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  30. ck_assert_int_eq(config->pubsubTransportLayersSize, 2);
  31. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  32. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  33. ck_assert_int_eq(config->pubsubTransportLayersSize, 3);
  34. UA_Server_delete(server);
  35. } END_TEST
  36. int main(void) {
  37. TCase *tc_add_pubsub_writergroup = tcase_create("PubSub Layer allocation");
  38. tcase_add_checked_fixture(tc_add_pubsub_writergroup, setup, teardown);
  39. tcase_add_test(tc_add_pubsub_writergroup, AddMultipleTransportLayers);
  40. Suite *s = suite_create("PubSub Multiple layer handling");
  41. suite_add_tcase(s, tc_add_pubsub_writergroup);
  42. SRunner *sr = srunner_create(s);
  43. srunner_set_fork_status(sr, CK_NOFORK);
  44. srunner_run_all(sr,CK_NORMAL);
  45. int number_failed = srunner_ntests_failed(sr);
  46. srunner_free(sr);
  47. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  48. }