nsprpub/pr/tests/dceemu.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/tests/dceemu.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 +** File:        dceemu.c
    1.11 +** Description: testing the DCE emulation api
    1.12 +**
    1.13 +** Modification History:
    1.14 +** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
    1.15 +**	         The debug mode will print all of the printfs associated with this test.
    1.16 +**			 The regress mode will be the default mode. Since the regress tool limits
    1.17 +**           the output to a one line status:PASS or FAIL,all of the printf statements
    1.18 +**             have been handled with an if (debug_mode) statement.
    1.19 +** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
    1.20 +**            recognize the return code from tha main program.
    1.21 +** 12-June-97 Revert to return code 0 and 1, remove debug option (obsolete).
    1.22 +**/
    1.23 +
    1.24 +/***********************************************************************
    1.25 +** Includes
    1.26 +***********************************************************************/
    1.27 +
    1.28 +#include "prlog.h"
    1.29 +#include "prinit.h"
    1.30 +#include "prpdce.h"
    1.31 +
    1.32 +#include <stdio.h>
    1.33 +#include <stdlib.h>
    1.34 +
    1.35 +#if defined(_PR_DCETHREADS)
    1.36 +
    1.37 +PRIntn failed_already=0;
    1.38 +PRIntn debug_mode=0;
    1.39 +
    1.40 +static PRIntn prmain(PRIntn argc, char **argv)
    1.41 +{
    1.42 +    PRStatus rv;
    1.43 +    PRLock *ml = PR_NewLock();
    1.44 +    PRCondVar *cv = PRP_NewNakedCondVar();
    1.45 +    PRIntervalTime tenmsecs = PR_MillisecondsToInterval(10);
    1.46 +
    1.47 +    rv = PRP_TryLock(ml);
    1.48 +    PR_ASSERT(PR_SUCCESS == rv);
    1.49 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    1.50 +    
    1.51 +    rv = PRP_TryLock(ml);
    1.52 +    PR_ASSERT(PR_FAILURE == rv);
    1.53 +    if ((rv != PR_FAILURE) & (!debug_mode)) failed_already=1; 
    1.54 +
    1.55 +    rv = PRP_NakedNotify(cv);
    1.56 +    PR_ASSERT(PR_SUCCESS == rv);
    1.57 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    1.58 +
    1.59 +    rv = PRP_NakedBroadcast(cv);
    1.60 +    PR_ASSERT(PR_SUCCESS == rv);
    1.61 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1; 
    1.62 +
    1.63 +    rv = PRP_NakedWait(cv, ml, tenmsecs);
    1.64 +    PR_ASSERT(PR_SUCCESS == rv);
    1.65 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    1.66 +
    1.67 +    PR_Unlock(ml);    
    1.68 +        
    1.69 +    rv = PRP_NakedNotify(cv);
    1.70 +    PR_ASSERT(PR_SUCCESS == rv);
    1.71 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    1.72 +
    1.73 +    rv = PRP_NakedBroadcast(cv);
    1.74 +    PR_ASSERT(PR_SUCCESS == rv);
    1.75 +    if ((rv != PR_SUCCESS) & (!debug_mode)) failed_already=1;     
    1.76 +
    1.77 +    PRP_DestroyNakedCondVar(cv);
    1.78 +    PR_DestroyLock(ml);
    1.79 +
    1.80 +    if (debug_mode) printf("Test succeeded\n");
    1.81 +
    1.82 +    return 0;
    1.83 +
    1.84 +}  /* prmain */
    1.85 +
    1.86 +#endif /* #if defined(_PR_DCETHREADS) */
    1.87 +
    1.88 +int main(int argc, char **argv)
    1.89 +{
    1.90 +
    1.91 +#if defined(_PR_DCETHREADS)
    1.92 +    PR_Initialize(prmain, argc, argv, 0);
    1.93 +    if(failed_already)    
    1.94 +        return 1;
    1.95 +    else
    1.96 +        return 0;
    1.97 +#else
    1.98 +    return 0;
    1.99 +#endif
   1.100 +}  /* main */
   1.101 +
   1.102 +
   1.103 +/* decemu.c */

mercurial