1 /* |
1 /* |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
86 log_debug(logging)("%s", LOG_TEST_STRING_LITERAL); |
86 log_debug(logging)("%s", LOG_TEST_STRING_LITERAL); |
87 success = LogConfiguration::parse_log_arguments(filename, "all=off", "", "", &stream); |
87 success = LogConfiguration::parse_log_arguments(filename, "all=off", "", "", &stream); |
88 guarantee(success, "Failed to disable logging to file '%s'", filename); |
88 guarantee(success, "Failed to disable logging to file '%s'", filename); |
89 } |
89 } |
90 |
90 |
|
91 static const char* tmp_dir = os::get_temp_directory(); |
|
92 static const char* file_sep = os::file_separator(); |
|
93 |
|
94 // Prepend filename with the temp directory and pid and return the result as a |
|
95 // resource allocated string. |
|
96 static inline char* prepend_temp_dir(const char* filename) { |
|
97 size_t temp_file_len = strlen(tmp_dir) + strlen(file_sep) + strlen(filename) + 28; |
|
98 char* temp_file = NEW_RESOURCE_ARRAY(char, temp_file_len); |
|
99 int ret = jio_snprintf(temp_file, temp_file_len, "%s%spid%d.%s", |
|
100 tmp_dir, file_sep, |
|
101 os::current_process_id(), filename); |
|
102 return temp_file; |
|
103 } |
|
104 |
|
105 // Prepend filename with specified prefix and the temp directory and return the |
|
106 // result as a malloc allocated string. This is used by test_logFileOutput.cpp. |
|
107 static inline char* prepend_prefix_temp_dir(const char* prefix, const char* filename) { |
|
108 size_t temp_file_len = strlen(prefix) + strlen(tmp_dir) + strlen(file_sep) + strlen(filename) + 1; |
|
109 char* temp_file = (char*)os::malloc(temp_file_len, mtLogging); |
|
110 int ret = jio_snprintf(temp_file, temp_file_len, "%s%s%s%s", |
|
111 prefix, tmp_dir, file_sep, filename); |
|
112 return temp_file; |
|
113 } |
|
114 |
91 // Read a complete line from fp and return it as a resource allocated string. |
115 // Read a complete line from fp and return it as a resource allocated string. |
92 // Returns NULL on EOF. |
116 // Returns NULL on EOF. |
93 static inline char* read_line(FILE* fp) { |
117 static inline char* read_line(FILE* fp) { |
94 assert(fp != NULL, "invalid fp"); |
118 assert(fp != NULL, "invalid fp"); |
95 int buflen = 512; |
119 int buflen = 512; |