nsprpub/pr/tests/logfile.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/tests/logfile.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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 + * A regression test for bug 491441.  NSPR should not crash on startup in
    1.11 + * PR_SetLogFile when the NSPR_LOG_MODULES and NSPR_LOG_FILE environment
    1.12 + * variables are set.
    1.13 + *
    1.14 + * This test could be extended to be a full-blown test for NSPR_LOG_FILE.
    1.15 + */
    1.16 +
    1.17 +#include "prinit.h"
    1.18 +#include "prlog.h"
    1.19 +
    1.20 +#include <stdio.h>
    1.21 +#include <stdlib.h>
    1.22 +
    1.23 +int main()
    1.24 +{
    1.25 +    PRLogModuleInfo *test_lm;
    1.26 +
    1.27 +    if (putenv("NSPR_LOG_MODULES=all:5") != 0) {
    1.28 +        fprintf(stderr, "putenv failed\n");
    1.29 +        exit(1);
    1.30 +    }
    1.31 +    if (putenv("NSPR_LOG_FILE=logfile.log") != 0) {
    1.32 +        fprintf(stderr, "putenv failed\n");
    1.33 +        exit(1);
    1.34 +    }
    1.35 +
    1.36 +    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    1.37 +    test_lm = PR_NewLogModule("test");
    1.38 +    PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message"));
    1.39 +    PR_Cleanup();
    1.40 +    return 0;
    1.41 +}

mercurial