annotate hotspot/test/native/logging/logTestUtils.inline.hpp @ 40902:395e1f3ec886

8157948: UL allows same log file with multiple file= Reviewed-by: dholmes, rehn
author mlarsson
date Mon, 29 Aug 2016 14:11:22 +0200
parents
children 36a9cca78d25
rev   line source
mlarsson@40656 1 /*
mlarsson@40656 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
mlarsson@40656 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mlarsson@40656 4 *
mlarsson@40656 5 * This code is free software; you can redistribute it and/or modify it
mlarsson@40656 6 * under the terms of the GNU General Public License version 2 only, as
mlarsson@40656 7 * published by the Free Software Foundation.
mlarsson@40656 8 *
mlarsson@40656 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mlarsson@40656 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mlarsson@40656 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mlarsson@40656 12 * version 2 for more details (a copy is included in the LICENSE file that
mlarsson@40656 13 * accompanied this code).
mlarsson@40656 14 *
mlarsson@40656 15 * You should have received a copy of the GNU General Public License version
mlarsson@40656 16 * 2 along with this work; if not, write to the Free Software Foundation,
mlarsson@40656 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mlarsson@40656 18 *
mlarsson@40656 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mlarsson@40656 20 * or visit www.oracle.com if you need additional information or have any
mlarsson@40656 21 * questions.
mlarsson@40656 22 *
mlarsson@40656 23 */
mlarsson@40656 24 #include "runtime/os.hpp"
mlarsson@40656 25 #include "unittest.hpp"
mlarsson@40656 26
mlarsson@40656 27 #define LOG_TEST_STRING_LITERAL "a (hopefully) unique log message for testing"
mlarsson@40656 28
mlarsson@40656 29 static inline bool string_contains_substring(const char* haystack, const char* needle) {
mlarsson@40656 30 return strstr(haystack, needle) != NULL;
mlarsson@40656 31 }
mlarsson@40656 32
mlarsson@40656 33 static inline bool file_exists(const char* filename) {
mlarsson@40656 34 struct stat st;
mlarsson@40656 35 return os::stat(filename, &st) == 0;
mlarsson@40656 36 }
mlarsson@40656 37
mlarsson@40656 38 static inline void delete_file(const char* filename) {
mlarsson@40656 39 if (!file_exists(filename)) {
mlarsson@40656 40 return;
mlarsson@40656 41 }
mlarsson@40656 42 int ret = remove(filename);
mlarsson@40656 43 EXPECT_TRUE(ret == 0 || errno == ENOENT) << "failed to remove file '" << filename << "': "
mlarsson@40656 44 << os::strerror(errno) << " (" << errno << ")";
mlarsson@40656 45 }