Mercurial > hg > openjdk > jdk9 > hotspot
changeset 12472:fc5845d845e3
8170936: Logging: LogFileOutput.invalid_file_test crashes when executed twice.
Reviewed-by: iignatyev, stuefe
author | kzhaldyb |
---|---|
date | Wed, 21 Dec 2016 11:51:57 +0300 |
parents | 0d1580bb0cb3 |
children | da52f1047024 a04e67d8ad3c |
files | test/native/logging/logTestUtils.inline.hpp test/native/logging/test_logFileOutput.cpp |
diffstat | 2 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/test/native/logging/logTestUtils.inline.hpp Wed Dec 21 11:51:57 2016 +0300 +++ b/test/native/logging/logTestUtils.inline.hpp Wed Dec 21 11:51:57 2016 +0300 @@ -59,6 +59,20 @@ assert(!failed, "failed to create directory %s", name); } +static inline void delete_empty_directory(const char* name) { +#ifdef _WINDOWS + if (!file_exists(name)) { + return; + } + bool failed; + failed = !RemoveDirectory(name); + EXPECT_FALSE(failed) << "failed to remove directory '" << name + << "': LastError = " << GetLastError(); +#else + delete_file(name); +#endif +} + static inline void init_log_file(const char* filename, const char* options = "") { LogStreamHandle(Error, logging) stream; bool success = LogConfiguration::parse_log_arguments(filename, "logging=trace", "", options, &stream);
--- a/test/native/logging/test_logFileOutput.cpp Wed Dec 21 11:51:57 2016 +0300 +++ b/test/native/logging/test_logFileOutput.cpp Wed Dec 21 11:51:57 2016 +0300 @@ -103,7 +103,7 @@ EXPECT_FALSE(fo.initialize(buf, &ss)) << "Accepted filesize that overflows"; } -TEST(LogFileOutput, startup_rotation) { +TEST_VM(LogFileOutput, startup_rotation) { const size_t rotations = 5; const char* filename = "start-rotate-test"; char* rotated_file[rotations]; @@ -140,7 +140,7 @@ } } -TEST(LogFileOutput, startup_truncation) { +TEST_VM(LogFileOutput, startup_truncation) { const char* filename = "start-truncate-test"; const char* archived_filename = "start-truncate-test.0"; @@ -168,7 +168,7 @@ delete_file(archived_filename); } -TEST(LogFileOutput, invalid_file) { +TEST_VM(LogFileOutput, invalid_file) { ResourceMark rm; stringStream ss; @@ -179,5 +179,5 @@ << "file was initialized when there was an existing directory with the same name"; EXPECT_TRUE(string_contains_substring(ss.as_string(), "tmplogdir is not a regular file")) << "missing expected error message, received msg: %s" << ss.as_string(); - remove("tmplogdir"); + delete_empty_directory("tmplogdir"); }