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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,15 +21,24 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test id=tmp
|
||||||
* @bug 8011536 8151430 8316304
|
* @bug 8011536 8151430 8316304 8334339
|
||||||
* @summary Basic test for creationTime attribute on platforms/file systems
|
* @summary Basic test for creationTime attribute on platforms/file systems
|
||||||
* that support it.
|
* that support it, tests using /tmp directory.
|
||||||
* @library ../.. /test/lib
|
* @library ../.. /test/lib
|
||||||
* @build jdk.test.lib.Platform
|
* @build jdk.test.lib.Platform
|
||||||
* @run main CreationTime
|
* @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.lang.foreign.Linker;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -38,6 +47,7 @@ import java.time.Instant;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
public class CreationTime {
|
public class CreationTime {
|
||||||
|
|
||||||
@ -68,8 +78,14 @@ public class CreationTime {
|
|||||||
FileTime creationTime = creationTime(file);
|
FileTime creationTime = creationTime(file);
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) {
|
if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) {
|
||||||
err.println("File creation time reported as: " + creationTime);
|
System.out.println("creationTime.toMillis() == " + creationTime.toMillis());
|
||||||
throw new RuntimeException("Expected to be close to: " + now);
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +111,7 @@ public class CreationTime {
|
|||||||
// Creation time updates are not supported on Linux
|
// Creation time updates are not supported on Linux
|
||||||
supportsCreationTimeWrite = false;
|
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
|
* 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 {
|
public static void main(String[] args) throws IOException {
|
||||||
// create temporary directory to run tests
|
// 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 {
|
try {
|
||||||
test(dir);
|
test(dir);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user