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