8265231: (fc) ReadDirect and WriteDirect tests fail after fix for JDK-8264821

Reviewed-by: alanb, dcubed, darcy, chegar
This commit is contained in:
Brian Burkhalter 2021-04-14 19:53:19 +00:00
parent 57f86a071e
commit d1b28e7ad0
5 changed files with 9 additions and 26 deletions

View file

@ -47,9 +47,8 @@ import com.sun.nio.file.ExtendedOpenOption;
public class DirectIOTest {
private static final int BASE_SIZE = 4096;
private static long blockSize;
private static int testWrite(Path p) throws Exception {
private static int testWrite(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, StandardOpenOption.WRITE,
ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
@ -67,7 +66,7 @@ public class DirectIOTest {
}
}
private static int testRead(Path p) throws Exception {
private static int testRead(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
int size = Math.max(BASE_SIZE, bs);
@ -94,17 +93,17 @@ public class DirectIOTest {
public static void main(String[] args) throws Exception {
Path p = createTempFile();
blockSize = Files.getFileStore(p).getBlockSize();
long blockSize = Files.getFileStore(p).getBlockSize();
System.loadLibrary("DirectIO");
try {
int size = testWrite(p);
int size = testWrite(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "write. File still exists in cache!");
}
size = testRead(p);
size = testRead(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "read. File still exists in cache!");

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -70,10 +70,6 @@ public class PreadDirect {
private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -59,10 +59,6 @@ public class PwriteDirect {
private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -58,10 +58,6 @@ public class ReadDirect {
private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
@ -48,10 +48,6 @@ public class WriteDirect {
private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();