nsprpub/pr/tests/logfile.c

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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/. */
     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  */
    14 #include "prinit.h"
    15 #include "prlog.h"
    17 #include <stdio.h>
    18 #include <stdlib.h>
    20 int main()
    21 {
    22     PRLogModuleInfo *test_lm;
    24     if (putenv("NSPR_LOG_MODULES=all:5") != 0) {
    25         fprintf(stderr, "putenv failed\n");
    26         exit(1);
    27     }
    28     if (putenv("NSPR_LOG_FILE=logfile.log") != 0) {
    29         fprintf(stderr, "putenv failed\n");
    30         exit(1);
    31     }
    33     PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    34     test_lm = PR_NewLogModule("test");
    35     PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message"));
    36     PR_Cleanup();
    37     return 0;
    38 }

mercurial