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/. */
8 ** Description: Testing lazy initialization
10 ** Since you only get to initialize once, you have to rerun the test
11 ** for each test case. The test cases are numbered. If you want to
12 ** add more tests, take the next number and add it to the switch
15 ** This test is problematic on systems that don't support the notion
16 ** of console output. The workarounds to emulate that feature include
17 ** initializations themselves, which defeats the purpose here.
33 static void PR_CALLBACK
lazyEntry(void *arg
)
35 PR_ASSERT(NULL
== arg
);
39 int main(int argc
, char **argv
)
47 PRThread
*thread
= NULL
;
48 PRIntervalTime interval
= 0;
49 PRFileDesc
*file
, *udp
, *tcp
, *pair
[2];
62 case 0: ml
= PR_NewLock();
65 case 1: interval
= PR_SecondsToInterval(1);
68 case 2: thread
= PR_CreateThread(
69 PR_USER_THREAD
, lazyEntry
, NULL
, PR_PRIORITY_NORMAL
,
70 PR_LOCAL_THREAD
, PR_JOINABLE_THREAD
, 0);
73 case 3: file
= PR_Open("./tmp-", PR_RDONLY
, 0);
76 case 4: udp
= PR_NewUDPSocket();
79 case 5: tcp
= PR_NewTCPSocket();
82 case 6: dir
= PR_OpenDir("./tmp-");
85 case 7: (void)PR_NewThreadPrivateIndex(&pdkey
, NULL
);
88 case 8: path
= PR_GetEnv("PATH");
91 case 9: status
= PR_NewTCPSocketPair(pair
);
94 case 10: PR_SetConcurrency(2);
99 "lazyinit: unrecognized command line argument: %s\n",