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 main()20int main() 21 { 22 PRLogModuleInfo *test_lm; 23 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 } 32 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 } 39