michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: ** File: dceemu.c michael@0: ** Description: testing the DCE emulation api michael@0: ** michael@0: ** Modification History: michael@0: ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag. michael@0: ** The debug mode will print all of the printfs associated with this test. michael@0: ** The regress mode will be the default mode. Since the regress tool limits michael@0: ** the output to a one line status:PASS or FAIL,all of the printf statements michael@0: ** have been handled with an if (debug_mode) statement. michael@0: ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to michael@0: ** recognize the return code from tha main program. michael@0: ** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete). michael@0: **/ michael@0: michael@0: /*********************************************************************** michael@0: ** Includes michael@0: ***********************************************************************/ michael@0: michael@0: #include "prlog.h" michael@0: #include "prinit.h" michael@0: #include "prpdce.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #if defined(_PR_DCETHREADS) michael@0: michael@0: PRIntn failed_already=0; michael@0: PRIntn debug_mode=0; michael@0: michael@0: static PRIntn prmain(PRIntn argc, char **argv) michael@0: { michael@0: PRStatus rv; michael@0: PRLock *ml = PR_NewLock(); michael@0: PRCondVar *cv = PRP_NewNakedCondVar(); michael@0: PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10); michael@0: michael@0: rv = PRP_TryLock(ml); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: rv = PRP_TryLock(ml); michael@0: PR_ASSERT(PR_FAILURE == rv); michael@0: if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; michael@0: michael@0: rv = PRP_NakedNotify(cv); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: rv = PRP_NakedBroadcast(cv); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: rv = PRP_NakedWait(cv, ml, tenmsecs); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: PR_Unlock(ml); michael@0: michael@0: rv = PRP_NakedNotify(cv); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: rv = PRP_NakedBroadcast(cv); michael@0: PR_ASSERT(PR_SUCCESS == rv); michael@0: if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; michael@0: michael@0: PRP_DestroyNakedCondVar(cv); michael@0: PR_DestroyLock(ml); michael@0: michael@0: if (debug_mode) printf("Test succeeded\n"); michael@0: michael@0: return 0; michael@0: michael@0: } /* prmain */ michael@0: michael@0: #endif /* #if defined(_PR_DCETHREADS) */ michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: michael@0: #if defined(_PR_DCETHREADS) michael@0: PR_Initialize(prmain, argc, argv, 0); michael@0: if(failed_already) michael@0: return 1; michael@0: else michael@0: return 0; michael@0: #else michael@0: return 0; michael@0: #endif michael@0: } /* main */ michael@0: michael@0: michael@0: /* decemu.c */