dceemu.c (2794B)
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 /* 7 ** File: dceemu.c 8 ** Description: testing the DCE emulation api 9 ** 10 ** Modification History: 11 ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag. 12 ** The debug mode will print all of the printfs associated with this 13 *test. 14 ** The regress mode will be the default mode. Since the regress tool 15 *limits 16 ** the output to a one line status:PASS or FAIL,all of the printf 17 *statements 18 ** have been handled with an if (debug_mode) statement. 19 ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been 20 *updated to 21 ** recognize the return code from tha main program. 22 ** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete). 23 **/ 24 25 /*********************************************************************** 26 ** Includes 27 ***********************************************************************/ 28 29 #include "prlog.h" 30 #include "prinit.h" 31 #include "prpdce.h" 32 33 #include <stdio.h> 34 #include <stdlib.h> 35 36 PRIntn failed_already = 0; 37 PRIntn debug_mode = 0; 38 39 static PRIntn prmain(PRIntn argc, char** argv) { 40 PRStatus rv; 41 PRLock* ml = PR_NewLock(); 42 PRCondVar* cv = PRP_NewNakedCondVar(); 43 PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10); 44 45 rv = PRP_TryLock(ml); 46 PR_ASSERT(PR_SUCCESS == rv); 47 if ((rv != PR_SUCCESS) & (!debug_mode)) { 48 failed_already = 1; 49 } 50 51 rv = PRP_TryLock(ml); 52 PR_ASSERT(PR_FAILURE == rv); 53 if ((rv != PR_FAILURE) & (!debug_mode)) { 54 failed_already = 1; 55 } 56 57 rv = PRP_NakedNotify(cv); 58 PR_ASSERT(PR_SUCCESS == rv); 59 if ((rv != PR_SUCCESS) & (!debug_mode)) { 60 failed_already = 1; 61 } 62 63 rv = PRP_NakedBroadcast(cv); 64 PR_ASSERT(PR_SUCCESS == rv); 65 if ((rv != PR_SUCCESS) & (!debug_mode)) { 66 failed_already = 1; 67 } 68 69 rv = PRP_NakedWait(cv, ml, tenmsecs); 70 PR_ASSERT(PR_SUCCESS == rv); 71 if ((rv != PR_SUCCESS) & (!debug_mode)) { 72 failed_already = 1; 73 } 74 75 PR_Unlock(ml); 76 77 rv = PRP_NakedNotify(cv); 78 PR_ASSERT(PR_SUCCESS == rv); 79 if ((rv != PR_SUCCESS) & (!debug_mode)) { 80 failed_already = 1; 81 } 82 83 rv = PRP_NakedBroadcast(cv); 84 PR_ASSERT(PR_SUCCESS == rv); 85 if ((rv != PR_SUCCESS) & (!debug_mode)) { 86 failed_already = 1; 87 } 88 89 PRP_DestroyNakedCondVar(cv); 90 PR_DestroyLock(ml); 91 92 if (debug_mode) { 93 printf("Test succeeded\n"); 94 } 95 96 return 0; 97 98 } /* prmain */ 99 100 int main(int argc, char** argv) { 101 PR_Initialize(prmain, argc, argv, 0); 102 if (failed_already) { 103 return 1; 104 } else { 105 return 0; 106 } 107 } /* main */ 108 109 /* decemu.c */