Skip to content

Commit

Permalink
8334339: Test java/nio/file/attribute/BasicFileAttributeView/Creation…
Browse files Browse the repository at this point in the history
…Time.java fails on alinux3

Reviewed-by: phh
Backport-of: 7baddc202a9ab2b85401aa05f827678b514ebf55
  • Loading branch information
SendaoYan authored and Paul Hohensee committed Jul 24, 2024
1 parent 933587a commit c7ca5f8
Showing 1 changed file with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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
Expand All @@ -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.
* @library ../.. /test/lib
* 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;
Expand All @@ -35,6 +46,7 @@
import java.io.IOException;

import jdk.test.lib.Platform;
import jtreg.SkippedException;

public class CreationTime {

Expand Down Expand Up @@ -65,8 +77,14 @@ static void test(Path top) throws IOException {
FileTime creationTime = creationTime(file);
Instant now = Instant.now();
if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) {
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 @@ -89,7 +107,7 @@ static void test(Path top) throws IOException {
// 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
Expand Down Expand Up @@ -121,7 +139,12 @@ static void test(Path top) throws IOException {

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 {
Expand Down

1 comment on commit c7ca5f8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.