|
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 #if defined(_PR_DCETHREADS) |
|
33 |
|
34 PRIntn failed_already=0; |
|
35 PRIntn debug_mode=0; |
|
36 |
|
37 static PRIntn prmain(PRIntn argc, char **argv) |
|
38 { |
|
39 PRStatus rv; |
|
40 PRLock *ml = PR_NewLock(); |
|
41 PRCondVar *cv = PRP_NewNakedCondVar(); |
|
42 PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10); |
|
43 |
|
44 rv = PRP_TryLock(ml); |
|
45 PR_ASSERT(PR_SUCCESS == rv); |
|
46 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
47 |
|
48 rv = PRP_TryLock(ml); |
|
49 PR_ASSERT(PR_FAILURE == rv); |
|
50 if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; |
|
51 |
|
52 rv = PRP_NakedNotify(cv); |
|
53 PR_ASSERT(PR_SUCCESS == rv); |
|
54 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
55 |
|
56 rv = PRP_NakedBroadcast(cv); |
|
57 PR_ASSERT(PR_SUCCESS == rv); |
|
58 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
59 |
|
60 rv = PRP_NakedWait(cv, ml, tenmsecs); |
|
61 PR_ASSERT(PR_SUCCESS == rv); |
|
62 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
63 |
|
64 PR_Unlock(ml); |
|
65 |
|
66 rv = PRP_NakedNotify(cv); |
|
67 PR_ASSERT(PR_SUCCESS == rv); |
|
68 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
69 |
|
70 rv = PRP_NakedBroadcast(cv); |
|
71 PR_ASSERT(PR_SUCCESS == rv); |
|
72 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; |
|
73 |
|
74 PRP_DestroyNakedCondVar(cv); |
|
75 PR_DestroyLock(ml); |
|
76 |
|
77 if (debug_mode) printf("Test succeeded\n"); |
|
78 |
|
79 return 0; |
|
80 |
|
81 } /* prmain */ |
|
82 |
|
83 #endif /* #if defined(_PR_DCETHREADS) */ |
|
84 |
|
85 int main(int argc, char **argv) |
|
86 { |
|
87 |
|
88 #if defined(_PR_DCETHREADS) |
|
89 PR_Initialize(prmain, argc, argv, 0); |
|
90 if(failed_already) |
|
91 return 1; |
|
92 else |
|
93 return 0; |
|
94 #else |
|
95 return 0; |
|
96 #endif |
|
97 } /* main */ |
|
98 |
|
99 |
|
100 /* decemu.c */ |