nsprpub/pr/tests/dceemu.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     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 **/
    21 /***********************************************************************
    22 ** Includes
    23 ***********************************************************************/
    25 #include "prlog.h"
    26 #include "prinit.h"
    27 #include "prpdce.h"
    29 #include <stdio.h>
    30 #include <stdlib.h>
    32 #if defined(_PR_DCETHREADS)
    34 PRIntn failed_already=0;
    35 PRIntn debug_mode=0;
    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);
    44     rv = PRP_TryLock(ml);
    45     PR_ASSERT(PR_SUCCESS == rv);
    46     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    48     rv = PRP_TryLock(ml);
    49     PR_ASSERT(PR_FAILURE == rv);
    50     if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; 
    52     rv = PRP_NakedNotify(cv);
    53     PR_ASSERT(PR_SUCCESS == rv);
    54     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    56     rv = PRP_NakedBroadcast(cv);
    57     PR_ASSERT(PR_SUCCESS == rv);
    58     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    60     rv = PRP_NakedWait(cv, ml, tenmsecs);
    61     PR_ASSERT(PR_SUCCESS == rv);
    62     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    64     PR_Unlock(ml);    
    66     rv = PRP_NakedNotify(cv);
    67     PR_ASSERT(PR_SUCCESS == rv);
    68     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    70     rv = PRP_NakedBroadcast(cv);
    71     PR_ASSERT(PR_SUCCESS == rv);
    72     if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    74     PRP_DestroyNakedCondVar(cv);
    75     PR_DestroyLock(ml);
    77     if (debug_mode) printf("Test succeeded\n");
    79     return 0;
    81 }  /* prmain */
    83 #endif /* #if defined(_PR_DCETHREADS) */
    85 int main(int argc, char **argv)
    86 {
    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 */
   100 /* decemu.c */

mercurial