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: alanb
  • Loading branch information
SendaoYan authored and Alan Bateman committed Jun 23, 2024
1 parent eb110bd commit 7baddc2
Showing 1 changed file with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -38,6 +47,7 @@
import java.io.IOException;

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

public class CreationTime {

Expand Down Expand Up @@ -68,8 +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) {
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 @@ -95,7 +111,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 @@ -127,7 +143,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

7 comments on commit 7baddc2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk:jdk23

@openjdk
Copy link

@openjdk openjdk bot commented on 7baddc2 Jun 24, 2024

Choose a reason for hiding this comment

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

@sendaoYan the backport was successfully created on the branch backport-sendaoYan-7baddc20-jdk23 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk23, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7baddc20 from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 23 Jun 2024 and was reviewed by Alan Bateman.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-sendaoYan-7baddc20-jdk23:backport-sendaoYan-7baddc20-jdk23
$ git checkout backport-sendaoYan-7baddc20-jdk23
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-sendaoYan-7baddc20-jdk23

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7baddc2 Jul 22, 2024

Choose a reason for hiding this comment

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

@sendaoYan Could not automatically backport 7baddc20 to openjdk/jdk21u-dev due to conflicts in the following files:

  • test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-sendaoYan-7baddc20-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 7baddc202a9ab2b85401aa05f827678b514ebf55

# Backport the commit
$ git cherry-pick --no-commit 7baddc202a9ab2b85401aa05f827678b514ebf55
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 7baddc202a9ab2b85401aa05f827678b514ebf55'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 7baddc202a9ab2b85401aa05f827678b514ebf55.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7baddc20 from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 23 Jun 2024 and was reviewed by Alan Bateman.

Thanks!

@openjdk
Copy link

@openjdk openjdk bot commented on 7baddc2 Jul 22, 2024

Choose a reason for hiding this comment

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

@sendaoYan Could not automatically backport 7baddc20 to openjdk/jdk17u-dev due to conflicts in the following files:

  • test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-sendaoYan-7baddc20-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 7baddc202a9ab2b85401aa05f827678b514ebf55

# Backport the commit
$ git cherry-pick --no-commit 7baddc202a9ab2b85401aa05f827678b514ebf55
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 7baddc202a9ab2b85401aa05f827678b514ebf55'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 7baddc202a9ab2b85401aa05f827678b514ebf55.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7baddc20 from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 23 Jun 2024 and was reviewed by Alan Bateman.

Thanks!

Please sign in to comment.