DO NOT MERGE Use explicitly opened file with O_WRONLY in test_sendfile_errno

(This is a backport of 50338dd868baf91202a8ddd23f49cb523f0736fd.)

The test intends to verify if sendfile() returns an error when the
source is write-only, and it uses stdout for that purpose.

However during Android instrumentation, stdout is actually /dev/null
opened with O_RDWR; and the test has been passing relying on the fact
that sendfile() only supports regular files and block devices. With
recent kernel changes this no longer holds true.

The proposed fix is to explicitly open a file with O_WRONLY set, so the
test is actually testing what it intends to test regardless of
environmental setup.

Bug: 244008857
Test: am instrument -w -r -e class libcore.libcore.io.OsTest#test_sendfile_errno android.libcore.cts
Change-Id: Id3838183aa1f0e5c64e4254271e09a6fcfdb8503
1 file changed