mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 09:34:38 +02:00
8265231: (fc) ReadDirect and WriteDirect tests fail after fix for JDK-8264821
Reviewed-by: alanb, dcubed, darcy, chegar
This commit is contained in:
parent
57f86a071e
commit
d1b28e7ad0
5 changed files with 9 additions and 26 deletions
|
@ -47,9 +47,8 @@ import com.sun.nio.file.ExtendedOpenOption;
|
||||||
public class DirectIOTest {
|
public class DirectIOTest {
|
||||||
|
|
||||||
private static final int BASE_SIZE = 4096;
|
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,
|
try (FileChannel fc = FileChannel.open(p, StandardOpenOption.WRITE,
|
||||||
ExtendedOpenOption.DIRECT)) {
|
ExtendedOpenOption.DIRECT)) {
|
||||||
int bs = (int)blockSize;
|
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)) {
|
try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) {
|
||||||
int bs = (int)blockSize;
|
int bs = (int)blockSize;
|
||||||
int size = Math.max(BASE_SIZE, bs);
|
int size = Math.max(BASE_SIZE, bs);
|
||||||
|
@ -94,17 +93,17 @@ public class DirectIOTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Path p = createTempFile();
|
Path p = createTempFile();
|
||||||
blockSize = Files.getFileStore(p).getBlockSize();
|
long blockSize = Files.getFileStore(p).getBlockSize();
|
||||||
|
|
||||||
System.loadLibrary("DirectIO");
|
System.loadLibrary("DirectIO");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int size = testWrite(p);
|
int size = testWrite(p, blockSize);
|
||||||
if (isFileInCache(size, p)) {
|
if (isFileInCache(size, p)) {
|
||||||
throw new RuntimeException("DirectIO is not working properly with "
|
throw new RuntimeException("DirectIO is not working properly with "
|
||||||
+ "write. File still exists in cache!");
|
+ "write. File still exists in cache!");
|
||||||
}
|
}
|
||||||
size = testRead(p);
|
size = testRead(p, blockSize);
|
||||||
if (isFileInCache(size, p)) {
|
if (isFileInCache(size, p)) {
|
||||||
throw new RuntimeException("DirectIO is not working properly with "
|
throw new RuntimeException("DirectIO is not working properly with "
|
||||||
+ "read. File still exists in cache!");
|
+ "read. File still exists in cache!");
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
private static boolean initTests() throws Exception {
|
||||||
Path p = DirectIOTest.createTempFile();
|
Path p = DirectIOTest.createTempFile();
|
||||||
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
|
|
||||||
Files.delete(p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
FileStore fs = Files.getFileStore(p);
|
FileStore fs = Files.getFileStore(p);
|
||||||
alignment = (int)fs.getBlockSize();
|
alignment = (int)fs.getBlockSize();
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
private static boolean initTests() throws Exception {
|
||||||
Path p = DirectIOTest.createTempFile();
|
Path p = DirectIOTest.createTempFile();
|
||||||
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
|
|
||||||
Files.delete(p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
FileStore fs = Files.getFileStore(p);
|
FileStore fs = Files.getFileStore(p);
|
||||||
alignment = (int)fs.getBlockSize();
|
alignment = (int)fs.getBlockSize();
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
private static boolean initTests() throws Exception {
|
||||||
Path p = DirectIOTest.createTempFile();
|
Path p = DirectIOTest.createTempFile();
|
||||||
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
|
|
||||||
Files.delete(p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
FileStore fs = Files.getFileStore(p);
|
FileStore fs = Files.getFileStore(p);
|
||||||
alignment = (int)fs.getBlockSize();
|
alignment = (int)fs.getBlockSize();
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
private static boolean initTests() throws Exception {
|
||||||
Path p = DirectIOTest.createTempFile();
|
Path p = DirectIOTest.createTempFile();
|
||||||
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
|
|
||||||
Files.delete(p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
FileStore fs = Files.getFileStore(p);
|
FileStore fs = Files.getFileStore(p);
|
||||||
alignment = (int)fs.getBlockSize();
|
alignment = (int)fs.getBlockSize();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue