Commit graph

2297 commits

Author SHA1 Message Date
Haibo Huang
c1ef5eb034 Only use color in supported terminal.
Test: compile
Change-Id: Ibb962597e065ebb90a53dd8bc62c4b774a2e4f10
2018-07-16 22:53:49 +00:00
Treehugger Robot
06f217d399 Merge "Remove workarounds for old versions of clang and GCC." 2018-07-11 22:08:46 +00:00
Treehugger Robot
67267589ba Merge "Reimplement popen(3)/pclose(3)." 2018-07-11 22:02:13 +00:00
Elliott Hughes
3012b9636b Remove workarounds for old versions of clang and GCC.
Bug: N/A
Test: ran tests
Change-Id: I89d224c743f5113771de41c74161a7a5ccad05e4
2018-07-11 13:18:29 -07:00
Elliott Hughes
468efc80da Reimplement popen(3)/pclose(3).
pclose(3) is now an alias for fclose(3). We could add a FORTIFY check
that you use pclose(3) if and only if you used popen(3), but there seems
little value to that when we can just do the right thing.

This patch also adds the missing locking to _fwalk --- we need to lock
both the global list of FILE*s and also each FILE* we touch. POSIX says
that "The popen() function shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed in the
new child process", which we implement via _fwalk(fclose) in the child,
but we might want to just make *all* popen(3) file descriptors O_CLOEXEC
in all cases.

Ignore fewer errors in popen(3) failure cases.

Improve popen(3) test coverage.

Bug: http://b/72470344
Test: ran tests
Change-Id: Ic937594bf28ec88b375f7e5825b9c05f500af438
2018-07-11 12:15:26 -07:00
Haibo Huang
83b6379783 Remove bionic test's dependency on gtest internal.
It is wrong to depend on internal ABI. And in the new version, they
explicitly disabled that.
b3d9be5c1d

Test: run test
Change-Id: I194a1e9417df2c52872b6eca6b61fb392e07cd29
2018-07-10 15:45:31 -07:00
Elliott Hughes
07a7c9b316 Merge "Fix some long-standing UTF-8 bugs." 2018-07-09 18:27:31 +00:00
Bernie Innocenti
57fe8130af Merge "bionic: Convert res_send.c to poll()" 2018-07-09 02:46:44 +00:00
Elliott Hughes
402c762fc9 Fix some long-standing UTF-8 bugs.
We we incorrectly rejecting U+fffe and U+ffff, and incorrectly accepting
characters above U+10ffff (see https://tools.ietf.org/html/rfc3629
section 12 for that restriction).

Bug: http://lists.landley.net/pipermail/toybox-landley.net/2017-September/009146.html
Test: ran tests
Test: also ran the exhaustive test from that email thread
Change-Id: I8ae8e41cef01b02933bd4f653ee07791932b79a5
2018-07-06 17:18:05 -07:00
Elliott Hughes
463faada00 pthread_barrier_init: add a test for the count == 0 EINVAL case.
The code was already correct, but we didn't have a test.

Bug: N/A
Test: ran tests
Change-Id: Ie63cbcfbfc2f2df6270aae98f0f4add484d210bc
2018-07-06 14:34:49 -07:00
Bernie Innocenti
b664724525 bionic: Convert res_send.c to poll()
Bug: 5854418
Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Test: manually:
    - flash and boot device
    - connect to wifi
    - launch WebView and resolv a few domains
Change-Id: I7b488e6d061d99a8a3c4bba69c2ac8609257eb6a
2018-07-05 11:39:09 +09:00
Tom Cherry
50acae8f2a Merge "Reland "Remove a check for AIDs in the OEM range."" 2018-06-29 23:08:37 +00:00
Tom Cherry
4cddb00d6f Reland "Remove a check for AIDs in the OEM range."
There may be vendor extensions to the system image which would need to
use these IDs.

This reverts commit 41986a013a.

Bug: 110856218
Test: these tests
2018-06-29 10:39:43 -07:00
Treehugger Robot
363eac0bab Merge "linker: improve "bad ELF magic" error." 2018-06-28 01:03:11 +00:00
Elliott Hughes
a897151426 linker: improve "bad ELF magic" error.
Include what we actually saw.

Bug: http://b/79463184
Test: ran tests
Change-Id: Id5f8aa3ab94b411ea839b0a1ada9beda9053a10f
2018-06-27 14:39:06 -07:00
Elliott Hughes
e7d185f59e <sys/un.h>: add SUN_LEN.
Also used by lldb.

Bug: N/A
Test: ran tests
Change-Id: I4c2aa60e7a3d8c691742c12ebde142d9438bf60f
2018-06-27 14:08:48 -07:00
Elliott Hughes
e5a5eec5e5 <netinet/ip_icmp.h>: ensure struct icmphdr is available.
Needed to build toybox ping.

Bug: N/A
Test: ran tests
Change-Id: Ifd0f0ccbb8351c6a0ece526b050778fd02e984bf
2018-06-27 12:29:06 -07:00
Dan Willemsen
901055eec7 Mark bionic-loader-test-libs-target as a phony rule
This essentially was phony before, but it wasn't marked as such. Mark it
so that we can turn on some more sanity checks in the build.

Test: Fewer warnings when --warn_real_to_phony is enabled for kati
Change-Id: I5f02b291ca01141dea75977df8b5ef9630917eb2
2018-06-18 20:23:14 -07:00
dimitry
3b0a5b7347 Relax check on number of segments in a .so file
This check was not necessary since it is perfectly fine for a dso to
have any number of PT_LOAD segments, given that the number is > 0.

Bug: http://b/109747297
Test: make
Change-Id: I0e3b400fddf05ed7b9342bacbfffd3b578f26cf3
2018-06-06 11:22:20 +02:00
dimitry
55547db434 Add secondary counter in place of tls_nodelete flag
The tls_nodelete state should apply to load_group not
isolated soinfo. This actually also means that multiple
soinfos may have tls_counter on their dso_handles.

This change replaces TLS_NODELETE flag with secondary counter.
Note that access to the secondary counter (located inside soinfo)
is pretty expensive because it requires soinfo lookup by dso_handle
whereas dso_handle counter is much faster. This is why it is updated
only when dso_handle counter starts or hits 0.

Bug: http://b/80278285
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I535583f6714e45fa2a7eaf7bb3126da20ee7cba9
2018-05-30 10:56:59 +02:00
Tom Cherry
28567aeb26 Merge "Test that vendor AID names begin with vendor_" 2018-05-29 17:56:26 +00:00
Tom Cherry
e88b4083e4 Test that vendor AID names begin with vendor_
Now that we're only processing vendor AID names that begin with
vendor_, add an explicit test to fail devices that use AID names
without this prefix.

Bug: 79528966
Test: Pass if no vendor defined AIDs are present
Test: Pass if vendor defined AIDs are present with vendor_ prefix
Test: Fail if vendor defined AIDs are present without vendor_ prefix

Change-Id: I77c559800b4904f58c49fbe339e4daad7d953089
2018-05-24 14:44:10 -07:00
Ryan Prichard
6814028920 Define DT_ANDROID_REL[A] correctly for a test
DT_ANDROID_REL is 0x6000000f, but this code defined it as 0x60000002.
DT_ANDROID_RELA is 0x60000011, but this code defined it as 0x60000004.

compat_elf_hash_and_relocation_tables tests that certain shared libraries
are linked with ordinary relocations and not with packed relocations. A
shared library will only have one kind of relocation table, so the test
mostly still worked by requiring DT_REL[A].

Previously, this test would have allowed libdl.so to have packed
relocations.

Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests \
  --gtest_filter=dlext.compat_elf_hash_and_relocation_tables
Test: manual
Bug: none
Change-Id: Ic8aa919a68fb6ed01a7994b69c0c7dd3798d6b67
2018-05-23 14:40:40 -07:00
Chih-Hung Hsieh
8e462d411a Do not use clang lld with -z,global
Bug: 80109858
Test: bionic unit test dlfcn.dlsym_df_1_global
Change-Id: Icc754385e54a5cd70312c60c635c094a27249442
2018-05-21 23:49:31 -07:00
Tom Cherry
903e5702f4 Merge "Require vendor users and groups to start with vendor_" 2018-05-16 16:19:28 +00:00
Tom Cherry
c2b9fec50b Require vendor users and groups to start with vendor_
Require that users and groups found in /vendor/etc/{passwd,group}
start with vendor_.  This is needed to compliance with Treble as
without this prefix, it is possible for a new system image to create a
user/group name that a vendor has already used, causing a collision.

Bug: 79528966
Test: new unit test
Change-Id: I07500641e165f41526a8101592d83fa174e7a711
2018-05-15 14:10:21 -07:00
dimitry
8b142566e3 vdso should be available in all namespaces
vdso should be available in all namespaces when present. This
bug went undetected because the way libc currently uses vdso (it
does all the lookups itself). This makes it available for the
programs that want to take advantage by dlopening it.

Bug: http://b/73105445
Bug: http://b/79561555
Test: adb shell /data/nativetest/arm/bionic-unit-tests/bionic-unit-tests --gtest_filter=dl.exec_with_ld_config_file
Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter=dl*
Change-Id: I8eae0c9848f256190d1c9ec85d10dc6ce383a8bc
(cherry picked from commit 69c68c46ac)
2018-05-12 10:58:00 +02:00
dimitry
e0906d8f55 Unhardcode /system/lib
Default search path may be different for native bridged enviroments

Bug: http://b/73105445
Test: adb shell /data/nativetest/arm/bionic-unit-tests/bionic-unit-tests --gtest_filter=dl.exec_with_ld_config_file
Change-Id: I09d32dcb8a7a3f161ccc6d58c29252e79ea5fd3e
(cherry picked from commit 1280cf5fd8)
2018-05-12 10:57:46 +02:00
Elliott Hughes
68e1c5b752 Merge "Fix various ftw/nftw "shall fail"s from POSIX." 2018-05-09 15:27:50 +00:00
Elliott Hughes
70a8f2272e Fix various ftw/nftw "shall fail"s from POSIX.
POSIX says ftw/nftw "shall fail" in various cases where BSD's fts_open
doesn't. Since our ftw/nftw are written in terms of fts_open, add a back
door so we can hint to ourselves when we should have the POSIX semantics.

Also pull several O_CLOEXEC and don't-null-check-before-free cleanups
from upstream, and add a couple of tests.

Bug: http://b/31152735
Test: ran bionic tests and LTP "nftw01" test
Change-Id: Ib05facacc1da4c8b2ab48e9ecce88f11a5406630
2018-05-08 15:20:07 -07:00
Evgeny Eltsin
284c4fdc39 Add a warm up pass to pthread_leak.join test
Bug: 73105445
Bug: 37920774
Test: bionic-unit-tests --gtest_filter=pthread_leak*
Change-Id: I227c999ecc13ee0a2136ff6b00a722f135dd48fe
(cherry picked from commit 775fb09621)
2018-05-07 13:16:16 +02:00
Elliott Hughes
d6f57306d2 Fix sysconf errno for unknown names.
The code (and comment) have been like this since the initial commit, but
there was never a test of this, and glibc seems to have been returning
EINVAL (as POSIX says it should) since long before Android existed.

Bug: http://b/31154352
Test: ran tests
Change-Id: Ica1ea836a4a5699ef0d956fe9c0f322e567de34d
2018-04-25 22:13:14 -07:00
Chih-Hung Hsieh
d6b56c921f allow_undefined_symbols to link libelf-tls-library
* Since Android does not have __tls_get_addr yet,
  -fno-emulated-tls is only a test of compiler.
  Lld is correct to reject this at link time.
  But if the purpose of this test is to check at run-time,
  allow_undefined-symbols is the trick to get the linked library.

Bug: http://b/74361956
Test: build and compare linked file
Change-Id: Ibcdc8b50aeeaec9d7d308b66df2a6997ce3c1a4f
2018-04-16 17:44:58 +00:00
Ryan Prichard
344969c849 spawn.signal_stress: reap spawned children on exit
Test: adb shell \
  /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static \
  --gtest_filter=spawn.signal_stress
Bug: b/77824306
Change-Id: I970d1a4d0f8ac9621e676f32f838fc2f638d9750
2018-04-09 16:58:20 -07:00
Tom Cherry
d238817037 Merge "Do not check user/group names in pwd/grp tests for OEM uid/gids" 2018-04-05 16:06:37 +00:00
Tom Cherry
b4c25c882e Do not check user/group names in pwd/grp tests for OEM uid/gids
Vendors that use config.fs will have their own uniquely named
user/group names for uids/gids that fall in the OEM ranges.  We
continue to allow lookup via oem_## for these values, however the
returned structs will always include the name from config.fs, so we do
not check it for anything in the tests.

Bug: 77549259
Test: bionic unit tests with uid 5000 as AID_CRAS
Change-Id: I27fc1fdd0e22063fea82b4c9d2a6fb8b865c5d7b
2018-04-04 15:02:55 -07:00
Luis Hector Chavez
7300d83b2e Make sys_ptrace_test.cpp Yama LSM-aware
This change enables the tracer process to be able to call ptrace(2) on
the worker process, which is does not have a direct-ancestor dependency.

Bug: 77146512
Test: adb shell \
      /data/nativetest{,64}/bionic-unit-tests{,-static}/bionic-unit-tests-{,-static} \
      --gtest_filter='spawn*'  # aosp_sailfish and Chrome OS
Test: cts-tradefed run singleCommand cts --skip-preconditions \
      -m CtsBionicTestCases --test 'PtraceResumptionTest*'  # aosp_sailfish
                                                            # and Chrome OS
Change-Id: I9e41b3ddde64c0623ba9299cede9d5b2001c8e30
2018-04-04 14:10:57 -07:00
Ryan Prichard
a1bc826c37 Fix race in spawn.signal_stress test
The default behavior for a real-time signal is to terminate the process.
If the child we fork sends a SIGRTMIN signal before we've set up the
ScopedSignalHandler for it, then the parent is terminated.

Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static --gtest_filter=spawn.signal_stress --gtest_repeat=1000
Bug: b/77554047
Change-Id: Ib44cbea8ccf506644405d8f426d9ad24e77cfa33
2018-04-03 21:57:24 -07:00
Ryan Prichard
6c3f97d236 Fix race in ld.config.txt tests
The tests can run in parallel, and if they do, one test can truncate
ld.config.txt while another test is reading it (via the loader). Fix the
issue by using a TemporaryFile as the LD_CONFIG_FILE.

Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests  --gtest_filter=dl.exec_with_ld_config_file:dl.exec_with_ld_config_file_with_ld_preload:dl.disable_ld_config_file --gtest_repeat=1000
Bug: b/77555708
Change-Id: I9763caa076ece30d1a0eb9c8892a310ac51543b6
2018-04-03 21:57:16 -07:00
Treehugger Robot
68ce672b5f Merge "Break libdl.so and ld-android.so's dependency on libc.so." 2018-04-04 04:28:52 +00:00
Treehugger Robot
c0db96dadf Merge "Fix build failure with dlext_testzip Bionic tests" 2018-04-02 23:24:24 +00:00
Ryan Prichard
470b66644b Break libdl.so and ld-android.so's dependency on libc.so.
* Specify "nocrt: true" to avoid calling __cxa_finalize.

 * Define a dummy __aeabi_unwind_cpp_pr0 for arm32.

Bug: b/62815515
Bug: b/73873002
Test: boot AOSP hikey960-userdebug
Test: run ndk_cxa_example in special /system/bin/debug namespace
Test: run Bionic unit tests
Change-Id: I59bcb100a2753286b59c51a47d7a183507219a07
2018-03-30 13:56:03 -07:00
Ryan Prichard
ef59154d41 Fix build failure with dlext_testzip Bionic tests
Other build rules create and use a test config file in the intermediate
directory containing $(LOCAL_BUILT_MODULE). Currently, this makefile
deletes $(dir $(LOCAL_BUILT_MODULE)) (aka $(dir $@)), so it can delete
the config file after it's created and before it's used. Avoid this
issue by using $(dir $@)/zipdir as the working directory for
constructing a zip file.

Bug: b/74524170
Test: mmma bionic
Test: run Bionic unit tests
Change-Id: Icee4d7bc72ba1c136385a0cb2c28491649598e7c
2018-03-30 13:56:03 -07:00
Elliott Hughes
06d31c94c2 Add libtest_missing_symbol_child_private.
Bug: http://b/77236525
Bug: http://b/77276121
Test: builds
Change-Id: I7398a7f5ecefcda37d1e9e4ab6cd85c3071e9648
2018-03-29 11:28:53 -07:00
Elliott Hughes
51466528cd Fix -/_ typo.
Bug: http://b/77236525
Bug: http://b/77276121
Test: builds
Change-Id: I54adfe7898b4bd7d708240c5d9cee6ba8ec723fd
2018-03-29 11:17:37 -07:00
Treehugger Robot
a3f6f6c1b9 Merge "Add missing shared library dependencies to bionic-unit-tests" 2018-03-29 07:05:23 +00:00
Jiyong Park
ce10b16294 Add missing shared library dependencies to bionic-unit-tests
Bug: 77236525

Test: 'make tests dist' and verify that these libraries are in the
*-continuous_native_tests-*.zip

Change-Id: I9cbb6a7e4230208f7563d8f7bfc3c5e7a1e89c9b
2018-03-29 10:34:41 +09:00
Pirama Arumuga Nainar
1395f70f6c Add missed shared library dependency to bionic-unit-tests
Test: N/A

Change-Id: I7b6cf631208a01f788760595f927aba669901350
2018-03-28 15:27:47 -07:00
Treehugger Robot
daa2a32894 Merge "Add missing shared library dependencies to bionic-unit-tests" 2018-03-27 23:30:31 +00:00
Pirama Arumuga Nainar
c53e8b88d5 Add missing shared library dependencies to bionic-unit-tests
Test: 'make tests dist' and verify that these libraries are in the
*-continuous_native_tests-*.zip

Change-Id: I2bd2ba9b44400804a125a8bc8ec49d84270d6361
2018-03-27 10:34:07 -07:00