summaryrefslogtreecommitdiff
path: root/luni/src/test/java/libcore/android
Commit message (Collapse)AuthorAgeFilesLines
* Do not fail OsTest#test_VmSocket on EAFNOSUPPORTRoman Kiryanov2021-03-291-1/+2
| | | | | | | | | | Some platforms fail with EAFNOSUPPORT instead of EACCES. Bug: 183995234 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest#test_VmSocket Signed-off-by: Roman Kiryanov <rkir@google.com> Change-Id: I85cafff256675cb709693a413c31a3ced3f3a0f1
* Add virtio-vsock support to libcoreRoman Kiryanov2021-03-251-0/+84
| | | | | | | | | | | | ClipboardService.java has an option to talk to the Android Studio Emulator to exchange the clipboard with the host. The emulator is migrating virtio-vsock. Bug: 182436079 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest#test_VmSocketAddress Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest#test_VmSocket Signed-off-by: Roman Kiryanov <rkir@google.com> Change-Id: I3429a7f27972a2ea25194e5d44dc06cb0646e650
* Skip GRO sendmsg tests on pre-5.4 kernels.Lorenzo Colitti2021-03-241-1/+22
| | | | | | | | The UDP_GRO socket option requires 5.4 or above. Bug: 172945027 Test: atest libcore.android.system.OsTest Change-Id: I5a07b7a87c297ad27b3461d46be08f3421fdd2da
* Add GSO and GRO Support Via recvmsg and sendmsgTyler Wear2021-03-221-0/+238
| | | | | | | | | | | | | | | | Create new wrappers for sendmsg and recvmsg so that apps that know about UDP GRO can call these directly. Bug: 172945027 Test: atest libcore.android.system.OsTest#test_sendmsg_af_inet_4K libcore.android.system.OsTest#test_sendmsg_af_inet6_4K libcore.android.system.OsTest#test_sendmsg_af_inet_16K_recvparts libcore.android.system.OsTest#test_sendmsg_af_inet_16K_reciveall libcore.android.system.OsTest#test_sendmsg_af_inet_16K_reciveall_without_recv_msgname libcore.android.system.OsTest#test_sendmsg_af_inet_16K_without_send_msgcontrl libcore.android.system.OsTest#test_sendmsg_af_inet_abnormal Change-Id: Ib65bfba7361139d49049c5f2cae9f2b0da6e27cb
* Relax test_socket_setSockoptTimeval_effective() on old kernels.Pete Bentley2021-02-031-92/+164
| | | | | | | | | | | | | On older kernels, timeouts may return a few seconds early so tolerate that on anything older than 3.18, which is the kernel version for a sailfish running O MR1. Converted to JUnit 4 (needed for an earlier patchset) and got rid of a bunch of lint errors while I was in here. Fixes: 176104885 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: I529e98fe8507cadf007635cdba35e303f8537560
* Fix UDP GRO/GSO tests.Lorenzo Colitti2021-01-251-11/+11
| | | | | | | | | | | | | | | | 1. The GRO test was failing on new kernels. This is because getsockopt(IPPROTO_UDP, UDP_GRO) is not supported: the option can only be set, not get. Don't attempt to get it. 2. The GSO test was failing on older kernels because it fetched the kernel version as a double and then compared it against 4.19. This fails on 4.9 and 4.4 kernels because 4.19 < 4.4. Fix this by fetching the kernel version as a 2-int array instead of a single double. Bug: 172945027 Fix: 178257424 Test: atest libcore.android.system.OsTest#test_socket_udpGro_set passes on redfin and crosshatch Change-Id: I862a8fe88521c0ac6e94c0c281ebb2daedc8e19a
* Add UDP_GRO and UDP_SEGMENT Socket OptionsTyler Wear2021-01-211-0/+46
| | | | | | | | | On new kernel versions UDP_GRO should be supported. Add code to enable these socket options in Java and corresponding test case. Bug: 172945027 Test: atest libcore.android.system.OsTest#test_socket_udpGro_setAndGet libcore.android.system.OsTest#test_socket_udpGso_setAndGet Change-Id: I5d0db2853d819957c93b0c5d10cb830109551024
* Allow socket timeout to expire slightly earlyHans Boehm2020-12-231-1/+3
| | | | | | | | | | Works around test failures on some old devices for now. Needs further investigation. Test: Treehugger. Bug: 176104885 Change-Id: I8960f08b823fb7704760ccb2a33f96abd6443e4e
* Fix StructTimeval roundingHans Boehm2020-12-211-0/+2
| | | | | | | | | | | | | StructTimeval.fromMillis() failed when called on a negative integral number of seconds. That would result in a timeval with a million microseconds, followed by a failed range check. Do the conversion correctly. Add the obvious test cases. Test: Used Treehugger to both confirm the failure and test CL. Bug: 176120149 Change-Id: Ifec35cf68d67fc684f0f6f55b0a0d13d0d98c623
* Deflake OsTest.test_socket_setSockoptTimeval_effective.Pete Bentley2020-12-141-4/+9
| | | | | | | | | | | | | | | | Be more tolerant of longer delays for when device is under load. Additionally check that the process blocks for *at least* the expected timeout. This is a potential source of new flakes but the socket is bound but not listening, so read should block forever in the absence of a timeout. Hans, you've tweaked similar timeouts in the past, do these seem about right to you? Bug: 175252827 Test: atest OsTest.test_socket_setSockoptTimeval_effective. Change-Id: I615f14b6d6b7e3e3e6d7a5a23f579d3681fad581
* Updates OsTest to handle NETLINK_ROUTE restrictions.Bram Bonné2020-01-311-5/+9
| | | | | | | | | | Non-system apps targeting the latest SDK are no longer able to bind() to NETLINK_ROUTE sockets (see https://r.android.com/1219477). Bug: 141455849 Bug: 148621612 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: Ie4a5321711d5fda5c8df9004b41988f8521e53ea
* Fix capitalization in test methodBenedict Wong2020-01-061-3/+3
| | | | | Test: tests passing Change-Id: Iae04433f19f26f0775d6dc56ef511edf138b31d9
* Add fcntlInt to public APIBenedict Wong2019-12-191-0/+39
| | | | | | | | In order to allow sockets to be set as non-blocking after the creation, fcntlInt must be exposed. Test: new tests added, passing Change-Id: If30d3750734a5a3910587a06df334c04fad92703
* Add memfd_create to android.system.OsChong Zhang2019-12-091-0/+68
| | | | | | | | | bug: 145355521 bug: 145607042 test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: I14a78ea8f6434e0590f7096bcda5e1d0f13a6679
* Add MAP_ANONYMOUS to OsConstantsJing Ji2019-11-011-0/+11
| | | | | | Bug: 143725805 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: I5a27c2368201c5f49dca0774f61d1431cc1430dd
* API clean-up around PacketSocketAddressNeil Fuller2019-06-261-2/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | API clean-up around PacketSocketAddress: 1) Use of short / byte for enum ints in Java is awkward because literals are "int", requiring casts. All constants in OsConstants are defined as ints which also require casts. This commit moves to int for PacketSocketAddress fields. 2) The constants to make sense of some PacketSocketAddress values were missing and have been added to the Core Platform API. Note that sll_pkttype is only set when receiving a packet, and there's no function on Os that supports data and address to be returned (i.e. there's no recvfrom() variant that allows for PacketSocketAddress) so it's mostly useless and the associated constants have not been added to @CorePlatformApi. If Android wanted to support PacketSocketAddress fully then it's likely that the PacketSocketAddress will need to be revisited (i.e. some or all fields made non-final) and the constants can be exposed at that time. Test: build / boot Test: Removed the test from knownfailures.txt / ran OsTest on -eng build with vogar Bug: 135660232 Change-Id: I2ef79a3e18f6ffa890d897ac2db54f6fa8c0357a
* Remove some usages of IoUtil methodsNeil Fuller2019-04-041-4/+5
| | | | | | | | | Continuing the long process of shrinking the core platform API by switching users, particularly tests, to alternatives. Bug: 124232146 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: If1a473f4d7a120723602faa70129ead1bf8ebc64
* OsTest: Only test sendfile() API, not separately the implementation method.Tobias Thierer2019-04-021-43/+10
| | | | | | | | | | | | | | | | | | | Testing the implementation method is inconsistent with the other methods tested by OsTest, and offers little value because (a) it is not part of any API surface and (b) Android's implementation in android.system.Os.sendfile() directly delegates to it. That the other version was ever tested is a historical accident: Before http://r.android.com/937425 (bug 129523169), generally only the *internal* version of each of these methods was tested. When the test for sendfile() was added, the need to test the actual public API surface was recognized but the code also wanted to stay consistent with the rest of the test, so coverage for both was added. Now that the other OsTest methods have moved to testing the public API, there is no longer a consistency reason for also testing the private API. Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Change-Id: Iacb32601f2714a50172b79c14231a0b1a26a70a9
* OsTest: Manually fix up formatting.Tobias Thierer2019-04-021-12/+10
| | | | | | | | | | The parent CL reformatted OsTest.java using IntelliJ's automated reformatter (Code / Reformat Code). It messed up in a handful of places, creating lines that were too long (in line comments) or too short (in block comments). This CL manually corrects these minor mistakes. Test: Treehugger Change-Id: I14fd7a3d58fffdb60e88b3dca7c7fe47ad1481a4
* OsTest: Reformat according to 4-space indent "AndroidStyle 4".Tobias Thierer2019-04-021-1302/+1341
| | | | | | | | | | | | | This CL was created via Code / Reformat Code (Ctrl+Alt+L) in IntelliJ. Note that the reformatting also introduced newlines (including empty lines) and other whitespace. Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Test: Confirmed that the following steps resulted in no net changes to the commit: git checkout HEAD^ luni/src/test/java/libcore/android/system/OsTest.java re-run Code / Reformat Code Change-Id: Iba672674cd14793de82641f34ca55bb55f5cdb39
* Test android.system.Os instead of libcore.io.Libcore.osTobias Thierer2019-04-021-0/+1413
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libcore.libcore.io.OsTest was testing libcore.io.Libcore.os, which is the implementation of android.system.Os. This CL moves all applicable parts into libcore.android.system.OsTest and makes them test android.system.Os instead, since that is the public API. Notes: - android.system.OsTest still covers both versions of sendfile() (via enum SendFileImpl) like the old test did. In a future CL, we could optionally drop coverage for the libcore.io version since it's not part of any API surface. - libcore.io.Os has a method accept(FileDescriptor, SocketAddress) but android.system.Os has accept(FileDescriptor, InetSocketAddress). OsTest calls accept() both with InetSocketAddress and UnixSocketAddress compile-time types. This CL adds a @hide method android.system.Os.accept(FileDescriptor, SocketAddress) and delegates to it from the InetSocketAddress method; this way, the existing tests can be reused for android.system.Os. - Even though android/system/OsTest.java did not exist before this CL, I've kept the existing file header from the existing OsTest.java from which the contents of the file are derived. - One test is known to be failing; this CL updates the expectations file to the new name. Fixes: 129523169 Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest Test: atest CtsLibcoreTestCases:libcore.libcore.io.OsTest Test: Used meld to compare libcore/io/OsTest.java from before this CL vs. android/system/OsTest.java after this CL to confirm that the only differences are (a) Libcore.{os,rawOs}. -> Os., (b) removal of the logic that remained in libcore/io/OsTest.java Change-Id: Ic6d7ef683a26ae8a7198a30638bfaa87012f3b11
* Merge "ErrnoException: Add test coverage."Treehugger Robot2019-04-011-0/+89
|\
| * ErrnoException: Add test coverage.Tobias Thierer2019-04-011-0/+89
| | | | | | | | | | | | | | | | @Test rethrow() covers non-SDK CorePlatformApi and IntraCoreApi. Fixes: 129200494 Test: atest CtsLibcoreTestCases:libcore.android.system.ErrnoExceptionTest Change-Id: Id80d4934f134ef8e8c43ace5b9f3aab6973ce492
* | Add tests for sockoptTimeVal functionsNeil Fuller2019-04-011-0/+108
|/ | | | | | | | | | | | | Prepare to add Os.getSockOptTimeVal() and Os.setSockOptTimeVal() to the public SDK API surface along with StructTimeVal. This will also enable them to be removed from the core-platform and intra-core APIs. Test: atest CtsLibcoreTestCases:libcore.android.system.StructTimevalTest Test: atest CtsLibcoreTestCases:libcore.libcore.io.OsTest Bug: 129251251 Bug: 117867568 Bug: 129433363 Change-Id: Ie0b629195f1aac50d78b61203d2f7b91be3454c9
* OsConstants: Add SOCK_CLOEXEC and SOCK_NONBLOCKNick Kralevich2018-12-141-0/+9
| | | | | | | | | | | | | | | Android makes the function socketpair() publicly visible, but never made SOCK_CLOEXEC nor SOCK_NONBLOCK visible. Java socketpair() users have no approved flag to ensure sockets are immediately created with O_CLOEXEC, nor set the non-blocking status on sockets. socketpair() documentation: https://developer.android.com/reference/android/system/Os.html#socketpair(int,%20int,%20int,%20java.io.FileDescriptor,%20java.io.FileDescriptor) Test: compiles Test: cts-tradefed run cts -m CtsLibcoreTestCases -t libcore.android.system.OsConstantsTest Bug: 120983106 Change-Id: Iba6bd318b14faad1696e5ea5d346d2f2f85b8044
* Move libcore tests to non-libcore packages.Tobias Thierer2017-11-081-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The integration of OpenJDK 9 javac into the Android build system requires non-libcore code to live in non-libcore packages, as long as that code isn't considered part of the same module as libcore at javac time. This CL moves libcore test related classes out of such packages; since libcore tests could already only test public (as opposed to package private APIs), no change other than the package name and imports is necessary. Because many libcore tests already live below a top-level package "libcore" (eg., the tests for java.util are in libcore.java.util), this CL likewise prepends "libcore." to the package names of affected classes. For classes relating to libcore.* packages, this results in a package name of the form "libcore.libcore.*". Alternative considered but not pursued: To compile the test classes without moving the out of a libcore package, javac would need to consider them to be in the same module as libcore. This would likely be possible via javac --patch-module, but this has not been explored in detail because: - Most luni tests are already in a toplevel package libcore.*, so this CL makes the test structure more consistent. - Use of --patch-module would likely cause problems when running tests under a runtime that implements the OpenJDK 9 module system; for example, --patch-module cannot add exported packages to the module, so any new packages added in tests (such as the libcore.* packages of most existing luni tests) would not be visible at test runtime. - Having tests in different packages from code under tests makes it more obvious (including to IDEs in which the code might be edited as a single project) that these tests cannot access package-private identifiers in the code under test. Test: Treehugger Test: "make cts" with EXPERIMENTAL_USE_OPENJDK9=true passes with additional changes present locally that have not yet been exported as CLs. Test: CtsLibcoreTestCases Bug: 68224249 Bug: 68932217 (tracks potential follow-up work) Change-Id: Ib6b8e6f3bc87093bc219d2108e601163c6e334cd
* Add equals and hashcode to StructTimespecPhilip P. Moltmann2017-07-191-0/+144
| | | | | | | Test: cts-tradefed run cts-dev -m CtsContentTestCases --test=android.content.cts.SharedPreferencesTest cts-tradefed run cts-dev -m CtsLibcoreTestCases --test=libcore.android.system.StructTimespecTest Bug: 62949739 Change-Id: I503d0d9fb696051924c17b12b3a708954fb01bc2
* Expose TCP_USER_TIMEOUT as a settable socket option.Tobias Thierer2016-08-031-0/+5
| | | | | | | | | | | | | | | | This is for systems whose tcp.h defines this constant, which is true for bionic on recent versions of Android but not the prebuilt glibc-2.15-4.8 currently on host (checked for host/x86_64). Exposed android.system.Os.setsocketoptInt(). Added a test that checks that TCP_USER_TIMEOUT can be set and gotten from stream sockets. Since this is just piping through behavior from the kernel, added no tests for the semantics of that socket option. Test: Checked that the newly added tests pass in cts on Nexus6P. Bug: 30402085 Change-Id: I5fb9e491ce5c856587423d074e9fa3c4b722d956
* Fix package names for OsConstantsTest and SqlDateTest.Piotr Jastrzebski2015-11-111-1/+3
| | | | Change-Id: Id14719899f5dcbd1da1f5067b6d54db9cb506f64
* Fix bogus define checks and a typo.Narayan Kamath2014-06-131-0/+31
RT_* constants are enum members in the UAPI so we can't use #define checks for them. Also fix a typo in the define check for an IFA_ constant. More generally, we should get rid of all these conditional checks for target builds because we know what version of the UAPI we have in bionic. We should move these conditional checks under #if HOST_BUILD or something similar. bug: 15602893 Change-Id: I3affc10773ade4dac68c176f79962ca8ad312579