Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * A regression test for bug 491441. NSPR should not crash on startup in |
michael@0 | 8 | * PR_SetLogFile when the NSPR_LOG_MODULES and NSPR_LOG_FILE environment |
michael@0 | 9 | * variables are set. |
michael@0 | 10 | * |
michael@0 | 11 | * This test could be extended to be a full-blown test for NSPR_LOG_FILE. |
michael@0 | 12 | */ |
michael@0 | 13 | |
michael@0 | 14 | #include "prinit.h" |
michael@0 | 15 | #include "prlog.h" |
michael@0 | 16 | |
michael@0 | 17 | #include <stdio.h> |
michael@0 | 18 | #include <stdlib.h> |
michael@0 | 19 | |
michael@0 | 20 | int main() |
michael@0 | 21 | { |
michael@0 | 22 | PRLogModuleInfo *test_lm; |
michael@0 | 23 | |
michael@0 | 24 | if (putenv("NSPR_LOG_MODULES=all:5") != 0) { |
michael@0 | 25 | fprintf(stderr, "putenv failed\n"); |
michael@0 | 26 | exit(1); |
michael@0 | 27 | } |
michael@0 | 28 | if (putenv("NSPR_LOG_FILE=logfile.log") != 0) { |
michael@0 | 29 | fprintf(stderr, "putenv failed\n"); |
michael@0 | 30 | exit(1); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); |
michael@0 | 34 | test_lm = PR_NewLogModule("test"); |
michael@0 | 35 | PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message")); |
michael@0 | 36 | PR_Cleanup(); |
michael@0 | 37 | return 0; |
michael@0 | 38 | } |