home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / tests / dceemu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  114 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20. ** File:        dceemu.c
  21. ** Description: testing the DCE emulation api
  22. **
  23. ** Modification History:
  24. ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
  25. **             The debug mode will print all of the printfs associated with this test.
  26. **             The regress mode will be the default mode. Since the regress tool limits
  27. **           the output to a one line status:PASS or FAIL,all of the printf statements
  28. **             have been handled with an if (debug_mode) statement.
  29. ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
  30. **            recognize the return code from tha main program.
  31. ** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete).
  32. **/
  33.  
  34. /***********************************************************************
  35. ** Includes
  36. ***********************************************************************/
  37.  
  38.  
  39. #if defined(XP_UNIX)
  40.  
  41. #include "prlog.h"
  42. #include "prinit.h"
  43. #include "prpdce.h"
  44.  
  45. #include <stdio.h>
  46. #include <stdlib.h>
  47. PRIntn failed_already=0;
  48. PRIntn debug_mode=0;
  49.  
  50. static PRIntn prmain(PRIntn argc, char **argv)
  51. {
  52.     PRStatus rv;
  53.     PRLock *ml = PR_NewLock();
  54.     PRCondVar *cv = PRP_NewNakedCondVar();
  55.     PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);
  56.  
  57.     rv = PRP_TryLock(ml);
  58.     PR_ASSERT(PR_SUCCESS == rv);
  59.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
  60.     
  61.     rv = PRP_TryLock(ml);
  62.     PR_ASSERT(PR_FAILURE == rv);
  63.     if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; 
  64.  
  65.     rv = PRP_NakedNotify(cv);
  66.     PR_ASSERT(PR_SUCCESS == rv);
  67.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
  68.  
  69.     rv = PRP_NakedBroadcast(cv);
  70.     PR_ASSERT(PR_SUCCESS == rv);
  71.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
  72.  
  73.     rv = PRP_NakedWait(cv, ml, tenmsecs);
  74.     PR_ASSERT(PR_SUCCESS == rv);
  75.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
  76.  
  77.     PR_Unlock(ml);    
  78.         
  79.     rv = PRP_NakedNotify(cv);
  80.     PR_ASSERT(PR_SUCCESS == rv);
  81.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
  82.  
  83.     rv = PRP_NakedBroadcast(cv);
  84.     PR_ASSERT(PR_SUCCESS == rv);
  85.     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
  86.  
  87.     PRP_DestroyNakedCondVar(cv);
  88.     PR_DestroyLock(ml);
  89.  
  90.     if (debug_mode) printf("Test succeeded\n");
  91.  
  92.     return 0;
  93.  
  94. }  /* prmain */
  95.  
  96. #endif /* #if defined(XP_UNIX) */
  97.  
  98. int main(int argc, char **argv)
  99. {
  100.  
  101. #if defined(XP_UNIX)
  102.     PR_Initialize(prmain, argc, argv, 0);
  103.     if(failed_already)    
  104.         return 1;
  105.     else
  106.         return 0;
  107. #else
  108.     return 0;
  109. #endif
  110. }  /* main */
  111.  
  112.  
  113. /* decemu.c */
  114.