dceemu.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /*
  6. ** File: dceemu.c
  7. ** Description: testing the DCE emulation api
  8. **
  9. ** Modification History:
  10. ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
  11. ** The debug mode will print all of the printfs associated with this test.
  12. ** The regress mode will be the default mode. Since the regress tool limits
  13. ** the output to a one line status:PASS or FAIL,all of the printf statements
  14. ** have been handled with an if (debug_mode) statement.
  15. ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
  16. ** recognize the return code from tha main program.
  17. ** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete).
  18. **/
  19. /***********************************************************************
  20. ** Includes
  21. ***********************************************************************/
  22. #include "prlog.h"
  23. #include "prinit.h"
  24. #include "prpdce.h"
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. PRIntn failed_already=0;
  28. PRIntn debug_mode=0;
  29. static PRIntn prmain(PRIntn argc, char **argv)
  30. {
  31. PRStatus rv;
  32. PRLock *ml = PR_NewLock();
  33. PRCondVar *cv = PRP_NewNakedCondVar();
  34. PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);
  35. rv = PRP_TryLock(ml);
  36. PR_ASSERT(PR_SUCCESS == rv);
  37. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  38. failed_already=1;
  39. }
  40. rv = PRP_TryLock(ml);
  41. PR_ASSERT(PR_FAILURE == rv);
  42. if ((rv != PR_FAILURE) & (!debug_mode)) {
  43. failed_already=1;
  44. }
  45. rv = PRP_NakedNotify(cv);
  46. PR_ASSERT(PR_SUCCESS == rv);
  47. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  48. failed_already=1;
  49. }
  50. rv = PRP_NakedBroadcast(cv);
  51. PR_ASSERT(PR_SUCCESS == rv);
  52. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  53. failed_already=1;
  54. }
  55. rv = PRP_NakedWait(cv, ml, tenmsecs);
  56. PR_ASSERT(PR_SUCCESS == rv);
  57. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  58. failed_already=1;
  59. }
  60. PR_Unlock(ml);
  61. rv = PRP_NakedNotify(cv);
  62. PR_ASSERT(PR_SUCCESS == rv);
  63. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  64. failed_already=1;
  65. }
  66. rv = PRP_NakedBroadcast(cv);
  67. PR_ASSERT(PR_SUCCESS == rv);
  68. if ((rv != PR_SUCCESS) & (!debug_mode)) {
  69. failed_already=1;
  70. }
  71. PRP_DestroyNakedCondVar(cv);
  72. PR_DestroyLock(ml);
  73. if (debug_mode) {
  74. printf("Test succeeded\n");
  75. }
  76. return 0;
  77. } /* prmain */
  78. int main(int argc, char **argv)
  79. {
  80. PR_Initialize(prmain, argc, argv, 0);
  81. if(failed_already) {
  82. return 1;
  83. }
  84. else {
  85. return 0;
  86. }
  87. } /* main */
  88. /* decemu.c */