check_session.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * check_session.c
  3. *
  4. * Created on: Jul 30, 2015
  5. * Author: opcua
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include "ua_types.h"
  10. #include "server/ua_services.h"
  11. #include "ua_statuscodes.h"
  12. #include "check.h"
  13. #include "ua_util.h"
  14. START_TEST(Session_init_ShallWork)
  15. {
  16. UA_Session session;
  17. UA_Session_init(&session);
  18. UA_NodeId tmpNodeId;
  19. UA_NodeId_init(&tmpNodeId);
  20. UA_ApplicationDescription tmpAppDescription;
  21. UA_ApplicationDescription_init(&tmpAppDescription);
  22. UA_DateTime tmpDateTime;
  23. UA_DateTime_init(&tmpDateTime);
  24. ck_assert_int_eq(session.activated,UA_FALSE);
  25. ck_assert_int_eq(session.authenticationToken.identifier.numeric,tmpNodeId.identifier.numeric);
  26. ck_assert_int_eq(session.availableContinuationPoints,MAXCONTINUATIONPOINTS);
  27. ck_assert_ptr_eq(session.channel,NULL);
  28. ck_assert_ptr_eq(session.clientDescription.applicationName.locale.data,NULL);
  29. ck_assert_ptr_eq(session.continuationPoints.lh_first, NULL);
  30. ck_assert_int_eq(session.maxRequestMessageSize,0);
  31. ck_assert_int_eq(session.maxResponseMessageSize,0);
  32. ck_assert_int_eq(session.sessionId.identifier.numeric,tmpNodeId.identifier.numeric);
  33. ck_assert_ptr_eq(session.sessionName.data,NULL);
  34. ck_assert_int_eq(session.timeout,0);
  35. ck_assert_int_eq(session.validTill,tmpDateTime);
  36. //finally
  37. }
  38. END_TEST
  39. START_TEST(Session_updateLifetime_ShallWork)
  40. {
  41. UA_Session session;
  42. UA_Session_init(&session);
  43. UA_DateTime tmpDateTime;
  44. tmpDateTime = session.validTill;
  45. UA_Session_updateLifetime(&session);
  46. UA_Int32 result = (session.validTill > tmpDateTime);
  47. ck_assert_int_gt(result,0);
  48. //finally
  49. }
  50. END_TEST
  51. static Suite* testSuite_Session(void) {
  52. Suite *s = suite_create("Session");
  53. TCase *tc_core = tcase_create("Core");
  54. tcase_add_test(tc_core, Session_init_ShallWork);
  55. tcase_add_test(tc_core, Session_updateLifetime_ShallWork);
  56. suite_add_tcase(s,tc_core);
  57. return s;
  58. }
  59. int main(void) {
  60. int number_failed = 0;
  61. Suite *s;
  62. SRunner *sr;
  63. s = testSuite_Session();
  64. sr = srunner_create(s);
  65. srunner_run_all(sr,CK_NORMAL);
  66. number_failed += srunner_ntests_failed(sr);
  67. srunner_free(sr);
  68. return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  69. }