VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/tests/dceemu.c@ 32258

Last change on this file since 32258 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39** File: dceemu.c
40** Description: testing the DCE emulation api
41**
42** Modification History:
43** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
44** The debug mode will print all of the printfs associated with this test.
45** The regress mode will be the default mode. Since the regress tool limits
46** the output to a one line status:PASS or FAIL,all of the printf statements
47** have been handled with an if (debug_mode) statement.
48** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
49** recognize the return code from tha main program.
50** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete).
51**/
52
53/***********************************************************************
54** Includes
55***********************************************************************/
56
57
58#if defined(_PR_DCETHREADS)
59
60#include "prlog.h"
61#include "prinit.h"
62#include "prpdce.h"
63
64#include <stdio.h>
65#include <stdlib.h>
66PRIntn failed_already=0;
67PRIntn debug_mode=0;
68
69static PRIntn prmain(PRIntn argc, char **argv)
70{
71 PRStatus rv;
72 PRLock *ml = PR_NewLock();
73 PRCondVar *cv = PRP_NewNakedCondVar();
74 PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);
75
76 rv = PRP_TryLock(ml);
77 PR_ASSERT(PR_SUCCESS == rv);
78 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
79
80 rv = PRP_TryLock(ml);
81 PR_ASSERT(PR_FAILURE == rv);
82 if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1;
83
84 rv = PRP_NakedNotify(cv);
85 PR_ASSERT(PR_SUCCESS == rv);
86 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
87
88 rv = PRP_NakedBroadcast(cv);
89 PR_ASSERT(PR_SUCCESS == rv);
90 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
91
92 rv = PRP_NakedWait(cv, ml, tenmsecs);
93 PR_ASSERT(PR_SUCCESS == rv);
94 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
95
96 PR_Unlock(ml);
97
98 rv = PRP_NakedNotify(cv);
99 PR_ASSERT(PR_SUCCESS == rv);
100 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
101
102 rv = PRP_NakedBroadcast(cv);
103 PR_ASSERT(PR_SUCCESS == rv);
104 if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;
105
106 PRP_DestroyNakedCondVar(cv);
107 PR_DestroyLock(ml);
108
109 if (debug_mode) printf("Test succeeded\n");
110
111 return 0;
112
113} /* prmain */
114
115#endif /* #if defined(_PR_DCETHREADS) */
116
117int main(int argc, char **argv)
118{
119
120#if defined(_PR_DCETHREADS)
121 PR_Initialize(prmain, argc, argv, 0);
122 if(failed_already)
123 return 1;
124 else
125 return 0;
126#else
127 return 0;
128#endif
129} /* main */
130
131
132/* decemu.c */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette