8334339: Test java/nio/file/attribute/BasicFileAttributeView/CreationTime.java fails on alinux3
Reviewed-by: alanb
This commit is contained in:
parent
eb110bdc6e
commit
7baddc202a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. 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
|
||||
@ -21,15 +21,24 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 8011536 8151430 8316304
|
||||
/* @test id=tmp
|
||||
* @bug 8011536 8151430 8316304 8334339
|
||||
* @summary Basic test for creationTime attribute on platforms/file systems
|
||||
* that support it.
|
||||
* that support it, tests using /tmp directory.
|
||||
* @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
|
||||
* @build jdk.test.lib.Platform
|
||||
* @run main CreationTime .
|
||||
*/
|
||||
|
||||
import java.lang.foreign.Linker;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Files;
|
||||
@ -38,6 +47,7 @@ import java.time.Instant;
|
||||
import java.io.IOException;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
public class CreationTime {
|
||||
|
||||
@ -68,9 +78,15 @@ public class CreationTime {
|
||||
FileTime creationTime = creationTime(file);
|
||||
Instant now = Instant.now();
|
||||
if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the creationTime attribute supported here?
|
||||
@ -95,7 +111,7 @@ public class CreationTime {
|
||||
// Creation time updates are not supported on Linux
|
||||
supportsCreationTimeWrite = false;
|
||||
}
|
||||
System.out.println("supportsCreationTimeRead == " + supportsCreationTimeRead);
|
||||
System.out.println(top + " supportsCreationTimeRead == " + supportsCreationTimeRead);
|
||||
|
||||
/**
|
||||
* If the creation-time attribute is supported then change the file's
|
||||
@ -127,7 +143,12 @@ public class CreationTime {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// create temporary directory to run tests
|
||||
Path dir = TestUtil.createTemporaryDirectory();
|
||||
Path dir;
|
||||
if (args.length == 0) {
|
||||
dir = TestUtil.createTemporaryDirectory();
|
||||
} else {
|
||||
dir = TestUtil.createTemporaryDirectory(args[0]);
|
||||
}
|
||||
try {
|
||||
test(dir);
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user