check_pubsub_multiple_layer.c 2.2 KB

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