Bug 462294 - Add "View Video" to context menu for <video> elements. r=gavin, ui...
[wine-gecko.git] / nsprpub / pr / tests / joinkk.c
blob0fd991e5161d0d69dab2c5ab637e26fd0ff549f3
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
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/
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.
15 * The Original Code is the Netscape Portable Runtime (NSPR).
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
38 /***********************************************************************
40 ** Name: dbmalloc1.c
42 ** Description: Tests PR_SetMallocCountdown PR_ClearMallocCountdown functions.
44 ** Modification History:
45 **
46 ** 19-May-97 AGarcia - separate the four join tests into different unit test modules.
47 ** AGarcia- Converted the test to accomodate the debug_mode flag.
48 ** The debug mode will print all of the printfs associated with this test.
49 ** The regress mode will be the default mode. Since the regress tool limits
50 ** the output to a one line status:PASS or FAIL,all of the printf statements
51 ** have been handled with an if (debug_mode) statement.
52 ** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
53 ** recognize the return code from tha main program.
54 ***********************************************************************/
56 /***********************************************************************
57 ** Includes
58 ***********************************************************************/
59 /* Used to get the command line option */
60 #include "plgetopt.h"
62 #include "nspr.h"
64 #include <stdio.h>
65 #include <stdlib.h>
66 #include <string.h>
68 #ifdef XP_MAC
69 #include "prlog.h"
70 #define printf PR_LogPrint
71 #endif
73 PRIntn failed_already=0;
74 PRIntn debug_mode;
76 Program to test joining of threads. Two threads are created. One
77 to be waited upon until it has started. The other to join after it has
78 completed.
82 static void lowPriority(void *arg)
86 static void highPriority(void *arg)
90 void runTest(PRThreadScope scope1, PRThreadScope scope2)
92 PRThread *low,*high;
94 /* create the low and high priority threads */
96 low = PR_CreateThread(PR_USER_THREAD,
97 lowPriority, 0,
98 PR_PRIORITY_LOW,
99 scope1,
100 PR_JOINABLE_THREAD,
102 if (!low) {
103 if (debug_mode) printf("\tcannot create low priority thread\n");
104 else failed_already=1;
105 return;
108 high = PR_CreateThread(PR_USER_THREAD,
109 highPriority, 0,
110 PR_PRIORITY_HIGH,
111 scope2,
112 PR_JOINABLE_THREAD,
114 if (!high) {
115 if (debug_mode) printf("\tcannot create high priority thread\n");
116 else failed_already=1;
117 return;
120 /* Do the joining for both threads */
121 if (PR_JoinThread(low) == PR_FAILURE) {
122 if (debug_mode) printf("\tcannot join low priority thread\n");
123 else failed_already=1;
124 return;
125 } else {
126 if (debug_mode) printf("\tjoined low priority thread\n");
128 if (PR_JoinThread(high) == PR_FAILURE) {
129 if (debug_mode) printf("\tcannot join high priority thread\n");
130 else failed_already=1;
131 return;
132 } else {
133 if (debug_mode) printf("\tjoined high priority thread\n");
137 static PRIntn PR_CALLBACK RealMain( PRIntn argc, char **argv )
139 /* The command line argument: -d is used to determine if the test is being run
140 in debug mode. The regress tool requires only one line output:PASS or FAIL.
141 All of the printfs associated with this test has been handled with a if (debug_mode)
142 test.
143 Usage: test_name -d
146 PLOptStatus os;
147 PLOptState *opt = PL_CreateOptState(argc, argv, "d:");
148 while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
150 if (PL_OPT_BAD == os) continue;
151 switch (opt->option)
153 case 'd': /* debug mode */
154 debug_mode = 1;
155 break;
156 default:
157 break;
160 PL_DestroyOptState(opt);
162 #ifdef XP_MAC
163 SetupMacPrintfLog("join.log");
164 #endif
168 /* main test */
170 if (debug_mode) printf("Kernel-Kernel test\n");
171 runTest(PR_GLOBAL_THREAD, PR_GLOBAL_THREAD);
173 if(failed_already)
175 printf("FAIL\n");
176 return 1;
178 else
180 printf("PASS\n");
181 return 0;
186 PRIntn main(PRIntn argc, char **argv)
188 PRIntn rv;
190 PR_STDIO_INIT();
191 rv = PR_Initialize(RealMain, argc, argv, 0);
192 return rv;
193 } /* main */