History log of /libcore/luni/src/test/java/libcore/java/io/FileInputStreamTest.java
Revision Date Author Comments
39b97ad7dd0e91440c67772f84208cd783c98ce0 28-Jul-2016 Erik Wolsheimer <ewol@google.com> Do not run test requiring 3GB free space on devices that do not have it

BUG: 30117577
Change-Id: I1572d760697da8f28bc6599da96c9c861a1bf2b9
7826e25f8bb38e2149e1c50c04d2ff4d1edcf614 03-Jan-2017 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix testSkipOnLargeFiles test

As the result of merge conflict resolution
the FileInputStreamTest.testSkipOnLargeFiles test
did assert it's test twice, failing to close its
second, unnecessary FileInputStream instance.

Bug: 34039901
Test: CtsLibcoreTestCases
Change-Id: If70435579494de4cf3ea9a0c624a7357b48352ad
c18a1e5e32bf80e17a8c970500e9061a9e753390 28-Jul-2016 Erik Wolsheimer <ewol@google.com> Do not run test requiring 3GB free space on devices that do not have it

BUG: 30117577
Change-Id: I1572d760697da8f28bc6599da96c9c861a1bf2b9
(cherry picked from commit c27c91e845227e61e1b1f2cfa125d4c3a4adafe2)
27889fe5c781f35a9b47bc5e13646ac2ad88aebb 02-Nov-2016 Shubham Ajmera <shubhamajmera@google.com> Enable libcore.java.io.FileInputStream#testReadProcVersion

The test was written for b/26117827 to check if available works
correctly for files which are not supported by ioctl. As /proc/version
is no longer accessible by CTS tests, the test now uses /dev/zero
instead. The name of the test has also changed to better reflect its
purpose.

Bug: 29495646
Test: cts-tradefed run cts -m CtsLibcoreTestCases -t \
libcore.java.io.FileInputStreamTest#test_available_on_nonIOCTL_supported_file

Change-Id: Iad827eb2377168029a7333b0db279042bd2cdaa0
27604018f783bf6354a13870b3e7785edca69b5f 28-Sep-2016 Paul Duffin <paulduffin@google.com> Detect and fix resource leakages in tests

Tests that test those classes that use CloseGuard to detect
reosurce leakages are switched to use TestCaseWithRules and
ResourceLeakageDetector.getRule() to detect any resource
leakages and the leaks fixed.

A number of tests could not be fixed due to bugs in the core
classes so a new DisableResourceLeakageDetection annotation was
added as part of this change. A method annotated with that does
not perform resource leakage detection. The affected tests were
annotated with a description and a reference to an associated
bug.

This uses try-with-resources to aid in closing resources. While
that does provide some benefits it is all too easy to change the
behavior of the test unless care is taken. To avoid that it is
important not to merge it with an existing try block such as
those which follow the following pattern:
try {... fail()} catch(..) {}
Merging them could result in the test catching and ignoring
exceptions thrown during the creation of the resource which is
almost certainly not what the test was intending.

Test: Tested with vogar and CTS
Bug: 31542223
Change-Id: Id32bb40fe04eb9719d7e6cd367abb53118b21832
57afdfdc64eee6693ad7055f3097f30ecce08d82 18-Aug-2016 Tobias Thierer <tobiast@google.com> Use fallocate to speed up testSkipOnLargeFiles() by 21sec

This test used to write a 3GiByte file which took 21 seconds
on a Nexus 6P. Since fallocate is available on current AOSP,
we can use it to allocate the same file in much less than 1sec
on file systems that support it (currently btrfs, ext4, ocfs2,
and xfs); on other file systems, or if fallocate is not
available, we fall back to writing the file ourselves.

Since
run cts -p android.core.tests.libcore.package.libcore
runs the test twice (on 32bit and 64bit runtimes), this speeds
up the libcore CTS test suite on a Nexus 6P by 42 seconds.
The time for each of the two runs decreased to 507sec
(from 528sec; was 587sec before http://r.android.com/258101 )

Also tweaked the test to close() the FileInputStream at the end.

Test: cts-tradefed run cts -c libcore.java.io.FileInputStreamTest

Bug: 30948560
Bug: 28192631
Change-Id: I740d7dec9bcc520b60f66fb8c8f05969610ef794
b82a632c94083fa0c0e3ff0a403d716fe8eda7f1 28-Jul-2016 Erik Wolsheimer <ewol@google.com> Do not run test requiring 3GB free space on devices that do not have it

BUG: 30117577

(cherry picked from commit bffdac5860ce06e759b82a903c73c31a676392f0)

Change-Id: I7251d907789a2b8ecfcd762618c768346bc9ff40
bffdac5860ce06e759b82a903c73c31a676392f0 28-Jul-2016 Erik Wolsheimer <ewol@google.com> Do not run test requiring 3GB free space on devices that do not have it

BUG: 30117577
Change-Id: I1572d760697da8f28bc6599da96c9c861a1bf2b9
c27c91e845227e61e1b1f2cfa125d4c3a4adafe2 28-Jul-2016 Erik Wolsheimer <ewol@google.com> Do not run test requiring 3GB free space on devices that do not have it

BUG: 30117577
Change-Id: I1572d760697da8f28bc6599da96c9c861a1bf2b9
f7f72edb7528537ef9cbd008ad1cb204021f27bf 15-Apr-2016 Narayan Kamath <narayan@google.com> FileInputStreamTest : Add test for skips of files larger than 2G.

Test that skip works if the file offset is larger than a 32 bit off_t.

NOTE: This test is "fast enough" on devices i've tested on but might
need to be suppressed if it's flaky due to a timeout.

bug: 28192631

(cherry picked from commit 7de69aa0a031aacea41c3a472dc4986267b4ccd4)

Change-Id: I0cded3688bf9383389098c053d51d5f2e3d2eb51
7de69aa0a031aacea41c3a472dc4986267b4ccd4 15-Apr-2016 Narayan Kamath <narayan@google.com> FileInputStreamTest : Add test for skips of files larger than 2G.

Test that skip works if the file offset is larger than a 32 bit off_t.

NOTE: This test is "fast enough" on devices i've tested on but might
need to be suppressed if it's flaky due to a timeout.

bug: 28192631
Change-Id: I3582ae2d221eb6202638ccee272d8c5e8779f55c
e3603abc77118773fc0cf5892be0df4056b1fb57 02-Feb-2016 Narayan Kamath <narayan@google.com> FileInputStream: Fix FD leak when opening a dir.

We should close the underlying file before we throw an
exception.

bug: 25695227

Change-Id: Ia121184968192147fb3b95c30eb855194b692b37
50164c3602af46021e434ff5047352299a36e0f0 16-Dec-2015 Yi Kong <yikong@google.com> Guard accesses to closed file streams

Check whether the file stream is closed before accessing the
underlying file descriptor.

Bug: 25897330
Change-Id: Ibb14bcd5530ee848c547dd3a0bc859cdb9b0391b
3ef077835b6f7af06814343aab0b84f41997ad3f 10-Dec-2015 Narayan Kamath <narayan@google.com> Fix FileInputStream.available() for non-regular files.

Use FIONREAD for all files, and return 0 (the conservative estimate)
for files for which this ioctl is not implemented.

bug: 26117827
Change-Id: I27d203f354045dd17e24fc6a55732fd41a1ab712
34625fce1396e8639a650af8905a579f9cf659a2 02-Jul-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix FileInputStream#close with shared FD.

Change-Id: Id31c85df95b8c0c301f222d737f52b2aa3b9ba77
0d8b5c3692c36837d22c4e7d9c4d7d95f6a10235 12-Dec-2014 Elliott Hughes <enh@google.com> Add pipe2 and O_CLOEXEC to the libcore POSIX API.

@hide right now, but we should expose these at some point.

Bug: 18719692
Change-Id: I0a73606cf089ed307d1ab2916a7df28b3c45aaf0
b1f55cb6f95928be969a8fe5c7447e13f14d0a68 19-Jul-2011 Elliott Hughes <enh@google.com> Fix FileInputStream/FileOutputStream on unowned FileDescriptors.

We were relying on the fd being invalid to prevent us from performing
activity on a closed stream. Unfortunately, this didn't work with our
clever scheme to avoid having to treat the two cases separately.

Go back to a simple scheme with one FileDescriptor and a boolean that
tells us whether or not we should close it. If we don't close it, we
switch it out for an invalid FileDescriptor so we won't continue to
act on the unowned FileDescriptor.

Bug: 4361076
Change-Id: I1851926fd2847ea63d91a8e0680a7430ecb16453
73298fc8f21a2440b4848912e95a072713b93a1a 07-Apr-2011 Elliott Hughes <enh@google.com> Fix a typo in FileOutputStream.

The matching code in FileInputStream was correct, but I've added tests for
both. Note that the RI does not pass these tests; this was always an Android
extension, one which we'd apparently never written a test for.

Change-Id: I04d0f63839f07e8ff4ad7b3d54a31b0c0955f8d1
462bdac45c10f43d88d8f07f6994e272a27c14a2 30-Mar-2011 Elliott Hughes <enh@google.com> Add close(2).

This is sufficient for non-socket fds, but may need to change to support the
asynchronous socket close monitor. (Hopefully not; I'd rather lift that into
Java.)

I've also changed the semantics of IoUtils.close to match those desired by
all callers: ignore null/invalid FileDescriptors.

Bug: 3107501
Change-Id: Iad5c31c8f0f34d2a5ab1ed4581509b46af28bd1f
41f0605d2c809bd9bc1c0fb68d86b49a0f59b6c5 24-Mar-2011 Elliott Hughes <enh@google.com> Add pipe(2).

This lets us kill quite a bit of IoUtils.

Bug: 3107501
Change-Id: Ic8a297b29cc53a17841cc77e266cd8dc3910c521
0ac77ac8e915bff1a863e371f9b363033f9cf759 23-Mar-2011 Elliott Hughes <enh@google.com> Add open(2).

Bug: 3107501
Change-Id: I404030b4c678862465d04f723a6a324663e0af25
0f524004b71b732c888d10eab57008bc65d8a3e0 20-Jan-2011 Owen Lin <owenlin@google.com> Skip bytes by reading if the file is not seekable.

And also add unit test for FileInputStream.skip() for a pipe.

bug: 3298498

Change-Id: Iceecdd42654700e00f15b53759a3761e1c4da943