michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * A regression test for bug 491441. NSPR should not crash on startup in michael@0: * PR_SetLogFile when the NSPR_LOG_MODULES and NSPR_LOG_FILE environment michael@0: * variables are set. michael@0: * michael@0: * This test could be extended to be a full-blown test for NSPR_LOG_FILE. michael@0: */ michael@0: michael@0: #include "prinit.h" michael@0: #include "prlog.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: int main() michael@0: { michael@0: PRLogModuleInfo *test_lm; michael@0: michael@0: if (putenv("NSPR_LOG_MODULES=all:5") != 0) { michael@0: fprintf(stderr, "putenv failed\n"); michael@0: exit(1); michael@0: } michael@0: if (putenv("NSPR_LOG_FILE=logfile.log") != 0) { michael@0: fprintf(stderr, "putenv failed\n"); michael@0: exit(1); michael@0: } michael@0: michael@0: PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); michael@0: test_lm = PR_NewLogModule("test"); michael@0: PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message")); michael@0: PR_Cleanup(); michael@0: return 0; michael@0: }