Skip to content

Commit

Permalink
8341882: [BACKOUT] java/nio/file/attribute/BasicFileAttributeView/Cre…
Browse files Browse the repository at this point in the history
…ationTime.java#tmp fails on alinux3

Reviewed-by: thartmann
  • Loading branch information
chhagedorn committed Oct 10, 2024
1 parent 780de00 commit 36fca5d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 200 deletions.
2 changes: 0 additions & 2 deletions make/test/JtregNativeJdk.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ ifeq ($(call isTargetOs, linux), true)
# stripping during the test libraries' build.
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libFib := -g
BUILD_JDK_JTREG_LIBRARIES_STRIP_SYMBOLS_libFib := false
# nio tests' libCreationTimeHelper native needs -ldl linker flag
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libCreationTimeHelper := -ldl
endif

ifeq ($(ASAN_ENABLED), true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024 Alibaba Group Holding Limited. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,18 +25,18 @@
* @bug 8011536 8151430 8316304 8334339
* @summary Basic test for creationTime attribute on platforms/file systems
* that support it, tests using /tmp directory.
* @library ../.. /test/lib /java/foreign
* @build jdk.test.lib.Platform NativeTestHelper
* @run main/othervm/native --enable-native-access=ALL-UNNAMED CreationTime
* @library ../.. /test/lib
* @build jdk.test.lib.Platform
* @run main CreationTime
*/

/* @test id=cwd
* @summary Basic test for creationTime attribute on platforms/file systems
* that support it, tests using the test scratch directory, the test
* scratch directory maybe at diff disk partition to /tmp on linux.
* @library ../.. /test/lib /java/foreign
* @build jdk.test.lib.Platform NativeTestHelper
* @run main/othervm/native --enable-native-access=ALL-UNNAMED CreationTime .
* @library ../.. /test/lib
* @build jdk.test.lib.Platform
* @run main CreationTime .
*/

import java.lang.foreign.Linker;
Expand All @@ -52,6 +51,8 @@

public class CreationTime {

private static final java.io.PrintStream err = System.err;

/**
* Reads the creationTime attribute
*/
Expand All @@ -77,9 +78,14 @@ static void test(Path top) throws IOException {
FileTime creationTime = creationTime(file);
Instant now = Instant.now();
if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) {
System.err.println("creationTime.toMillis() == " + creationTime.toMillis());
System.err.println("File creation time reported as: " + creationTime);
throw new RuntimeException("Expected to be close to: " + now);
System.out.println("creationTime.toMillis() == " + creationTime.toMillis());
// If the file system doesn't support birth time, then skip this test
if (creationTime.toMillis() == 0) {
throw new SkippedException("birth time not support for: " + file);
} else {
err.println("File creation time reported as: " + creationTime);
throw new RuntimeException("Expected to be close to: " + now);
}
}

/**
Expand All @@ -101,12 +107,7 @@ static void test(Path top) throws IOException {
}
} else if (Platform.isLinux()) {
// Creation time read depends on statx system call support
try {
supportsCreationTimeRead = CreationTimeHelper.
linuxIsCreationTimeSupported(file.toAbsolutePath().toString());
} catch (Throwable e) {
supportsCreationTimeRead = false;
}
supportsCreationTimeRead = Linker.nativeLinker().defaultLookup().find("statx").isPresent();
// Creation time updates are not supported on Linux
supportsCreationTimeWrite = false;
}
Expand All @@ -121,11 +122,8 @@ static void test(Path top) throws IOException {
Instant plusHour = Instant.now().plusSeconds(60L * 60L);
Files.setLastModifiedTime(file, FileTime.from(plusHour));
FileTime current = creationTime(file);
if (!current.equals(creationTime)) {
System.err.println("current = " + current);
System.err.println("creationTime = " + creationTime);
if (!current.equals(creationTime))
throw new RuntimeException("Creation time should not have changed");
}
}

/**
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 36fca5d

Please sign in to comment.