You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
5.9 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.be.lrsplit/test.unit.be.lrsplit.c
  3. *
  4. * Purpose: Implementation file for the test.unit.be.lrsplit project.
  5. *
  6. * Created: 27th January 2008
  7. * Updated: 22nd March 2010
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2008-2010, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. #include <pantheios/backends/be.lrsplit.h>
  20. #include <pantheios/init_codes.h>
  21. #include <xtests/xtests.h>
  22. #include <stlsoft/stlsoft.h> /* for STLSOFT_NUM_ELEMENTS */
  23. #include <stdio.h> /* for fprintf() */
  24. #include <stdlib.h> /* for EXIT_SUCCESS, EXIT_FAILURE */
  25. const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.be.lrsplit");
  26. static int s_localRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  27. static int s_remoteRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  28. PANTHEIOS_CALL(int) pantheios_be_local_init(
  29. PAN_CHAR_T const* processIdentity
  30. , void* reserved
  31. , void** ptoken
  32. )
  33. {
  34. STLSOFT_SUPPRESS_UNUSED(processIdentity);
  35. STLSOFT_SUPPRESS_UNUSED(reserved);
  36. STLSOFT_SUPPRESS_UNUSED(ptoken);
  37. return s_localRetVal;
  38. }
  39. PANTHEIOS_CALL(void) pantheios_be_local_uninit(void* token)
  40. {
  41. STLSOFT_SUPPRESS_UNUSED(token);
  42. }
  43. PANTHEIOS_CALL(int) pantheios_be_local_logEntry(
  44. void* feToken
  45. , void* beToken
  46. , int severity
  47. , PAN_CHAR_T const* entry
  48. , size_t cchEntry
  49. )
  50. {
  51. STLSOFT_SUPPRESS_UNUSED(feToken);
  52. STLSOFT_SUPPRESS_UNUSED(beToken);
  53. STLSOFT_SUPPRESS_UNUSED(severity);
  54. STLSOFT_SUPPRESS_UNUSED(entry);
  55. return (int)cchEntry;
  56. }
  57. PANTHEIOS_CALL(int) pantheios_be_remote_init(
  58. PAN_CHAR_T const* processIdentity
  59. , void* reserved
  60. , void** ptoken
  61. )
  62. {
  63. STLSOFT_SUPPRESS_UNUSED(processIdentity);
  64. STLSOFT_SUPPRESS_UNUSED(reserved);
  65. STLSOFT_SUPPRESS_UNUSED(ptoken);
  66. return s_remoteRetVal;
  67. }
  68. PANTHEIOS_CALL(void) pantheios_be_remote_uninit(void* token)
  69. {
  70. STLSOFT_SUPPRESS_UNUSED(token);
  71. }
  72. PANTHEIOS_CALL(int) pantheios_be_remote_logEntry(
  73. void* feToken
  74. , void* beToken
  75. , int severity
  76. , PAN_CHAR_T const* entry
  77. , size_t cchEntry
  78. )
  79. {
  80. STLSOFT_SUPPRESS_UNUSED(feToken);
  81. STLSOFT_SUPPRESS_UNUSED(beToken);
  82. STLSOFT_SUPPRESS_UNUSED(severity);
  83. STLSOFT_SUPPRESS_UNUSED(entry);
  84. return (int)cchEntry;
  85. }
  86. PANTHEIOS_CALL(void) pantheios_onBailOut3(int severity, char const* message, char const* processId)
  87. {
  88. STLSOFT_SUPPRESS_UNUSED(severity);
  89. STLSOFT_SUPPRESS_UNUSED(message);
  90. STLSOFT_SUPPRESS_UNUSED(processId);
  91. }
  92. PANTHEIOS_CALL(void) pantheios_onBailOut4(int severity, char const* message, char const* processId, char const* qualifier)
  93. {
  94. STLSOFT_SUPPRESS_UNUSED(severity);
  95. STLSOFT_SUPPRESS_UNUSED(message);
  96. STLSOFT_SUPPRESS_UNUSED(processId);
  97. STLSOFT_SUPPRESS_UNUSED(qualifier);
  98. }
  99. PANTHEIOS_CALL(int) pantheios_isInitialising(void)
  100. {
  101. return 1;
  102. }
  103. PANTHEIOS_CALL(int) pantheios_isInitialised(void)
  104. {
  105. return 0;
  106. }
  107. int main(int argc, char** argv)
  108. {
  109. int retCode = EXIT_SUCCESS;
  110. int verbosity = 2;
  111. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  112. if(XTESTS_START_RUNNER("test.unit.be.lrsplit", verbosity))
  113. {
  114. /* Test-1 */
  115. if(XTESTS_CASE_BEGIN("Test-1", "Verify that both succeed"))
  116. {
  117. void* token;
  118. int res;
  119. s_localRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  120. s_remoteRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  121. res = pantheios_be_init(PANTHEIOS_FE_PROCESS_IDENTITY, NULL, &token);
  122. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_INIT_RC_SUCCESS, res);
  123. pantheios_be_uninit(token);
  124. XTESTS_CASE_END("Test-1");
  125. }
  126. /* Test-2 */
  127. if(XTESTS_CASE_BEGIN("Test-2", "Verify that only local can succeed"))
  128. {
  129. void* token;
  130. int res;
  131. s_localRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  132. s_remoteRetVal = PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE;
  133. res = pantheios_be_init(PANTHEIOS_FE_PROCESS_IDENTITY, NULL, &token);
  134. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE, res);
  135. /* pantheios_be_uninit(token); */
  136. XTESTS_CASE_END("Test-2");
  137. }
  138. /* Test-3 */
  139. if(XTESTS_CASE_BEGIN("Test-3", "Verify that only remote can succeed"))
  140. {
  141. void* token;
  142. int res;
  143. s_localRetVal = PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE;
  144. s_remoteRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  145. res = pantheios_be_init(PANTHEIOS_FE_PROCESS_IDENTITY, NULL, &token);
  146. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE, res);
  147. /* pantheios_be_uninit(token); */
  148. XTESTS_CASE_END("Test-3");
  149. }
  150. /* Test-4 */
  151. if(XTESTS_CASE_BEGIN("Test-4", "Verify that neither can succeed"))
  152. {
  153. void* token;
  154. int res;
  155. s_localRetVal = PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE;
  156. s_remoteRetVal = PANTHEIOS_INIT_RC_SUCCESS;
  157. res = pantheios_be_init(PANTHEIOS_FE_PROCESS_IDENTITY, NULL, &token);
  158. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE, res);
  159. /* pantheios_be_uninit(token); */
  160. XTESTS_CASE_END("Test-4");
  161. }
  162. XTESTS_PRINT_RESULTS();
  163. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  164. }
  165. return retCode;
  166. }
  167. /* ///////////////////////////// end of file //////////////////////////// */