check_pubsub_multiple_layer.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <check.h>
  8. #include <open62541/server_pubsub.h>
  9. #include <open62541/server_config_default.h>
  10. #include "open62541/types_generated_encoding_binary.h"
  11. #include <open62541/plugin/pubsub_udp.h>
  12. #include "ua_server_internal.h"
  13. UA_Server *server = NULL;
  14. UA_ServerConfig *config = NULL;
  15. UA_NodeId connection1, connection2;
  16. static void setup(void) {
  17. }
  18. static void teardown(void) {
  19. }
  20. START_TEST(AddMultipleTransportLayers){
  21. config = UA_ServerConfig_new_default();
  22. UA_PubSubTransportLayer pubsubTransportLayer;
  23. ck_assert_int_eq(config->pubsubTransportLayersSize, 0);
  24. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  25. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  26. ck_assert_int_eq(config->pubsubTransportLayersSize, 1);
  27. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  28. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  29. ck_assert_int_eq(config->pubsubTransportLayersSize, 2);
  30. pubsubTransportLayer = UA_PubSubTransportLayerUDPMP();
  31. UA_ServerConfig_addPubSubTransportLayer(config, &pubsubTransportLayer);
  32. ck_assert_int_eq(config->pubsubTransportLayersSize, 3);
  33. server = UA_Server_new(config);
  34. UA_Server_delete(server);
  35. UA_ServerConfig_delete(config);
  36. } END_TEST
  37. int main(void) {
  38. TCase *tc_add_pubsub_writergroup = tcase_create("PubSub Layer allocation");
  39. tcase_add_checked_fixture(tc_add_pubsub_writergroup, setup, teardown);
  40. tcase_add_test(tc_add_pubsub_writergroup, AddMultipleTransportLayers);
  41. Suite *s = suite_create("PubSub Multiple layer handling");
  42. suite_add_tcase(s, tc_add_pubsub_writergroup);
  43. SRunner *sr = srunner_create(s);
  44. srunner_set_fork_status(sr, CK_NOFORK);
  45. srunner_run_all(sr,CK_NORMAL);
  46. int number_failed = srunner_ntests_failed(sr);
  47. srunner_free(sr);
  48. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  49. }