Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Jul 23, 2024
2 parents b2bc038 + 2288c05 commit 6ff00aa
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

0 comments on commit 6ff00aa

Please sign in to comment.