Skip to content
Snippets Groups Projects
Commit c7ca5f83 authored by SendaoYan's avatar SendaoYan Committed by Paul Hohensee
Browse files

8334339: Test java/nio/file/attribute/BasicFileAttributeView/CreationTime.java fails on alinux3

Reviewed-by: phh
Backport-of: 7baddc202a9ab2b85401aa05f827678b514ebf55
parent 933587a0
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2013, 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,11 +21,22 @@
* questions.
*/
/* @test
* @bug 8011536 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.nio.file.Path;
......@@ -35,6 +46,7 @@ import java.time.Instant;
import java.io.IOException;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
public class CreationTime {
......@@ -65,9 +77,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?
......@@ -89,7 +107,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
......@@ -121,7 +139,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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment