Back to index

lightning-sunbird  0.9+nobinonly
dceemu.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** File:        dceemu.c
00040 ** Description: testing the DCE emulation api
00041 **
00042 ** Modification History:
00043 ** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
00044 **              The debug mode will print all of the printfs associated with this test.
00045 **                    The regress mode will be the default mode. Since the regress tool limits
00046 **           the output to a one line status:PASS or FAIL,all of the printf statements
00047 **             have been handled with an if (debug_mode) statement.
00048 ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
00049 **            recognize the return code from tha main program.
00050 ** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete).
00051 **/
00052 
00053 /***********************************************************************
00054 ** Includes
00055 ***********************************************************************/
00056 
00057 
00058 #if defined(_PR_DCETHREADS)
00059 
00060 #include "prlog.h"
00061 #include "prinit.h"
00062 #include "prpdce.h"
00063 
00064 #include <stdio.h>
00065 #include <stdlib.h>
00066 PRIntn failed_already=0;
00067 PRIntn debug_mode=0;
00068 
00069 static PRIntn prmain(PRIntn argc, char **argv)
00070 {
00071     PRStatus rv;
00072     PRLock *ml = PR_NewLock();
00073     PRCondVar *cv = PRP_NewNakedCondVar();
00074     PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);
00075 
00076     rv = PRP_TryLock(ml);
00077     PR_ASSERT(PR_SUCCESS == rv);
00078     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
00079     
00080     rv = PRP_TryLock(ml);
00081     PR_ASSERT(PR_FAILURE == rv);
00082     if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; 
00083 
00084     rv = PRP_NakedNotify(cv);
00085     PR_ASSERT(PR_SUCCESS == rv);
00086     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
00087 
00088     rv = PRP_NakedBroadcast(cv);
00089     PR_ASSERT(PR_SUCCESS == rv);
00090     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
00091 
00092     rv = PRP_NakedWait(cv, ml, tenmsecs);
00093     PR_ASSERT(PR_SUCCESS == rv);
00094     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
00095 
00096     PR_Unlock(ml);    
00097         
00098     rv = PRP_NakedNotify(cv);
00099     PR_ASSERT(PR_SUCCESS == rv);
00100     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
00101 
00102     rv = PRP_NakedBroadcast(cv);
00103     PR_ASSERT(PR_SUCCESS == rv);
00104     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
00105 
00106     PRP_DestroyNakedCondVar(cv);
00107     PR_DestroyLock(ml);
00108 
00109     if (debug_mode) printf("Test succeeded\n");
00110 
00111     return 0;
00112 
00113 }  /* prmain */
00114 
00115 #endif /* #if defined(_PR_DCETHREADS) */
00116 
00117 int main(int argc, char **argv)
00118 {
00119 
00120 #if defined(_PR_DCETHREADS)
00121     PR_Initialize(prmain, argc, argv, 0);
00122     if(failed_already)    
00123         return 1;
00124     else
00125         return 0;
00126 #else
00127     return 0;
00128 #endif
00129 }  /* main */
00130 
00131 
00132 /* decemu.c */