Navigation Menu

Skip to content

Commit

Permalink
8281149: (fs) java/nio/file/FileStore/Basic.java fails with java.lang…
Browse files Browse the repository at this point in the history
….RuntimeException: values differ by more than 1GB

Reviewed-by: jpai, rriggs
  • Loading branch information
Brian Burkhalter committed May 19, 2023
1 parent 44218b1 commit a5343fa
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/jdk/java/nio/file/FileStore/Basic.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, 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 Down Expand Up @@ -57,11 +57,12 @@ static void assertTrue(boolean okay) {
throw new RuntimeException("Assertion failed");
}

static void checkWithin1GB(long expected, long actual) {
static void checkWithin1GB(String space, long expected, long actual) {
long diff = Math.abs(actual - expected);
if (diff > G) {
String msg = String.format("|actual %d - expected %d| = %d (%f G)",
actual, expected, diff, (float)diff/G);
String msg = String.format("%s: |actual %d - expected %d| = %d (%f G)",
space, actual, expected, diff,
(float)diff/G);
throw new RuntimeException(msg);
}
}
Expand Down Expand Up @@ -110,19 +111,19 @@ static void doTests(Path dir) throws IOException {
* Test: Space atributes
*/
File f = file1.toFile();
long total = f.getTotalSpace();
long free = f.getFreeSpace();
long usable = f.getUsableSpace();

// check values are "close"
checkWithin1GB(total, store1.getTotalSpace());
checkWithin1GB(free, store1.getUnallocatedSpace());
checkWithin1GB(usable, store1.getUsableSpace());
checkWithin1GB("total", f.getTotalSpace(), store1.getTotalSpace());
checkWithin1GB("free", f.getFreeSpace(), store1.getUnallocatedSpace());
checkWithin1GB("usable", f.getUsableSpace(), store1.getUsableSpace());

// get values by name
checkWithin1GB(total, (Long)store1.getAttribute("totalSpace"));
checkWithin1GB(free, (Long)store1.getAttribute("unallocatedSpace"));
checkWithin1GB(usable, (Long)store1.getAttribute("usableSpace"));
checkWithin1GB("total", f.getTotalSpace(),
(Long)store1.getAttribute("totalSpace"));
checkWithin1GB("free", f.getFreeSpace(),
(Long)store1.getAttribute("unallocatedSpace"));
checkWithin1GB("usable", f.getUsableSpace(),
(Long)store1.getAttribute("usableSpace"));

/**
* Test: Enumerate all FileStores
Expand Down

3 comments on commit a5343fa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on a5343fa Oct 5, 2023

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 a5343fa Oct 5, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-a5343fa6 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, 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 a5343fa6 from the openjdk/jdk repository.

The commit being backported was authored by Brian Burkhalter on 19 May 2023 and was reviewed by Jaikiran Pai and Roger Riggs.

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/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-a5343fa6:GoeLin-backport-a5343fa6
$ git checkout GoeLin-backport-a5343fa6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-a5343fa6

Please sign in to comment.