Debian Codegraph @

nsprpub/pr/tests/logfile.c

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
5
6 /*
7 * A regression test for bug 491441. NSPR should not crash on startup in
8 * PR_SetLogFile when the NSPR_LOG_MODULES and NSPR_LOG_FILE environment
9 * variables are set.
10 *
11 * This test could be extended to be a full-blown test for NSPR_LOG_FILE.
12 */
13
14 #include "prinit.h"
15 #include "prlog.h"
16
17 #include <stdio.h>
18 #include <stdlib.h>
19
20 int main() {
21 PRLogModuleInfo* test_lm;
22
23 if (putenv("NSPR_LOG_MODULES=all:5") != 0) {
24 fprintf(stderr, "putenv failed\n");
25 exit(1);
26 }
27 if (putenv("NSPR_LOG_FILE=logfile.log") != 0) {
28 fprintf(stderr, "putenv failed\n");
29 exit(1);
30 }
31
32 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
33 test_lm = PR_NewLogModule("test");
34 PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message"));
35 PR_Cleanup();
36 return 0;
37 }