Merge "Snap for 9158858 from 8a9954046b03fca9f6ed131014385da9b99d4638 to android11-tests-release" into android11-tests-release
diff --git a/luni/src/test/java/libcore/android/system/OsTest.java b/luni/src/test/java/libcore/android/system/OsTest.java
index 35019db..fbdd1de 100644
--- a/luni/src/test/java/libcore/android/system/OsTest.java
+++ b/luni/src/test/java/libcore/android/system/OsTest.java
@@ -1306,12 +1306,18 @@
// http://b/65051835
public void test_sendfile_errno() throws Exception {
+ File testFile = File.createTempFile("test_sendfile_errno", "");
+ FileDescriptor fd = Os.open(testFile.toString(), O_WRONLY, S_IRUSR | S_IWUSR);
+ assertNotNull(fd);
+
try {
- // FileDescriptor.out is not open for input, will cause EBADF
+ // fd is not open for input, will cause EBADF
Int64Ref offset = new Int64Ref(10);
- Os.sendfile(FileDescriptor.out, FileDescriptor.out, offset, 10);
+ Os.sendfile(fd, fd, offset, 10);
fail();
} catch (ErrnoException expected) {
+ } finally {
+ Os.close(fd);
}
}