Commit graph

78335 commits

Author SHA1 Message Date
David Anderson
0dfbdc5bdb Merge "vts_libsnapshot_test: Fix test flakiness." 2022-09-08 19:44:05 +00:00
Treehugger Robot
a5d944f67d Merge "[LSC] Add LOCAL_LICENSE_KINDS to system/core" 2022-09-08 17:03:26 +00:00
Bob Badour
9cf81ccfef [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  init/test_upgrade_mte/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I77b956ed672a2f171b78ab1e7bfddc09bd0dc158
2022-09-08 15:23:25 +00:00
Treehugger Robot
34386d2d29 Merge "Change log level in mount_with_alternatives()" 2022-09-08 13:12:03 +00:00
Sandro Montanari
4b3c063ac3 Merge "Remove /dev/selinux directory creation from first_stage_init.cpp" 2022-09-08 08:37:05 +00:00
David Anderson
7834809350 vts_libsnapshot_test: Fix test flakiness.
This patch fixes a few lingering issues in vts_libsnapshot_test.

The most important fix is a crash in snapuserd when handler deletion
races with the merge monitor thread. Since tests issue lots of
snapshot-related requests in rapid succession, this was easy to hit in
presubmit, and resulted in a null-pointer deref.

SnapuserdClient's CloseConnection does the same thing as the destructor,
but leaves SnapuserdClient in an unusable state. This method is removed
in favor of RAII.

Fix a bug in SnapshotManager where CloseConnection could be called
without zapping snapuserd_client_.

Fix a bug where POLLHUP was checked before calling recv().

Add test name logging so presubmit failures can be diagnosed via logcat
dumps.

Bug: N/A
Test: vts_libsnapshot_test on cuttlefish
Change-Id: I8f22a45e537c24a3c6d327ac47bf8b1352108706
2022-09-07 21:58:03 -07:00
Sandro
d01921034c Remove /dev/selinux directory creation from first_stage_init.cpp
Follow-up from aosp/2203897

Bug: 243923977
Test: m and manual verification
Change-Id: I9e41301d2fe4447906253a5c1249dc6c25cd5218
2022-09-07 15:04:59 +00:00
Sandro Montanari
344f71605c Merge "Create /dev/selinux folder if it was not created by first-stage-init" 2022-09-07 15:01:51 +00:00
Sandro
1120f7f4a9 Create /dev/selinux folder if it was not created by first-stage-init
The /dev/selinux folder is normally created by first-stage-init
https://cs.android.com/android/platform/superproject/+/master:system/core/init/first_stage_init.cpp;l=299-300;drc=07c86bace1e7a7cc4dd975f10b077d21c3743749

However, in some cases the first-stage-init comes from a GKI prebuilt
boot.img and doess not create the required folder (see for example
b/217677967), resulting in bugs like b/244793900.

I modified the selinux.cpp code to create the /dev/selinux folder if it
does not exist already, as a safety measure.

To verify these changes for b/244793900, follow gpaste/4922166775644160

Bug: 243923977
Test: atest SeamendcHostTest, manual verification
Change-Id: I8fe798643b1aeab2b4caac837055348febf70b94
2022-09-07 11:31:47 +00:00
Bowgo Tsai
0db62f43de Change log level in mount_with_alternatives()
mount_with_alternatives() supports mounting any of the
consecutive fstab entries. Some log messages shouldn't
be treated as error so changing log level to INFO instead.

Bug: 245468764
Test: TreeHugger
Change-Id: I94a18d4cf91ee5bb58cf5ba5f853a0e6599071d1
2022-09-07 18:45:36 +08:00
Treehugger Robot
98e474ab43 Merge "Add fdsan capabilities for native handles" 2022-09-06 22:48:31 +00:00
Treehugger Robot
c113dc3a95 Merge "Upgrade MTE to SYNC after ASYNC crash." 2022-09-06 21:29:14 +00:00
Florian Mayer
2ef47f8f6d Upgrade MTE to SYNC after ASYNC crash.
Bug: 169277947
Test: atest mte_ugprade_test on emulator.
Test: ASSUMPTION_FAILED on non-MTE
Test: ASSUMPTION_FAILED on HWASan
Change-Id: I5328d094ffb106abaa548feb76058c9ebd11d745
2022-09-06 20:10:57 +00:00
Treehugger Robot
752437b0c7 Merge "Only run Service::Start() under root" 2022-09-06 13:52:42 +00:00
Jooyung Han
93c24d7e65 Only run Service::Start() under root
Tests using Service::Start() should run under root. Otherwise tests fail
to start services from the test binary due to lack of permission.

Bug: 244748231
Test: CtsInitTestCases
Change-Id: Ia4eb8457cfad7d44da6b171e44f64238e08af9f7
2022-09-06 10:03:47 +09:00
Yi-yo Chiang
9a0a9db6af Merge "adb-remount-test: Miscellaneous fixes - 2nd round" 2022-09-05 08:33:31 +00:00
Yi-yo Chiang
10b691284c Merge changes I2360314c,I51bd32c6,Icb136327,Id8425488
* changes:
  adb-remount-test: Refactor test cleanup
  adb-remount-test: Replace libc.so test with build.prop test
  adb-remount-test: Check override_creds only if overlayfs is used
  adb-remount-test: Print log timestamp & auto-detect color
2022-09-05 05:59:36 +00:00
Yi-yo Chiang
78430afca4 Merge "adb-remount-test: Refactor raw remount & remount from scratch test" 2022-09-05 03:34:56 +00:00
David Anderson
82e1fc0749 Merge "remount: Simplify fs_mgr_overlayfs_setup." 2022-09-03 00:28:13 +00:00
Elliott Hughes
f40607140c Merge "Add the "sys" group for tests." 2022-09-02 22:34:56 +00:00
Jiyong Park
a5dfe700b8 Merge "init: remove unnecessary semicolon" 2022-09-02 11:39:05 +00:00
Yi-yo Chiang
a219a2337a Merge "adb-remount-test: Refactor fastboot flash vendor test" 2022-09-02 10:32:47 +00:00
Jooyung Han
c69bcd4a6d Merge "Removed property init.apex.<apex-name>.load/unload." 2022-09-02 06:46:54 +00:00
Yi-yo Chiang
b1e4f98b96 Merge "adb-remount-test: Refactor remount RW test" 2022-09-02 05:27:21 +00:00
Yi-yo Chiang
a028455e9d Merge changes I4d388590,Id15844d8,Iec4224d8
* changes:
  adb-remount-test: Discover fstab pathname more intelligently
  adb-remount-test: Reduce noise from initial overlayfs diagnostics
  adb-remount-test: Miscellaneous fixes
2022-09-02 04:06:19 +00:00
Brian Duddie
9f2af69d2a Add fdsan capabilities for native handles
Introduces new APIs which can be used to simplify application of fdsan
to native_handle_t usage, and applies fdsan protection to
native_handle_clone() by default.

Bug: 244214188
Test: validated alongside sensor service change to use the new APIs
Change-Id: I3be16a09c336bcbe880bdb542d5da2969c2c34d3
2022-09-02 00:44:13 +00:00
Yi-Yo Chiang
3ae19c3c01 adb-remount-test: Miscellaneous fixes - 2nd round
* Call adb_wait in adb_reboot, as virtually all adb_reboot callsites are
  immediately followed by adb_wait.
* Remove |data| option from skip_administrative_mounts. The |data|
  option doesn't really work anyway, because vold & init creates
  bewildering heirarchy of /data bind-mounts, so it's not feasible to
  filter /data by mountpoints. It's more sensible to filter by the /data
  device node name, which should be done by the caller.
* Untangle skip_administrative_mounts and skip_unrelated_mounts.
  I don't know why we need two separate functions that do similar
  things. Just merge them together.

Bug: 243116800
Test: adb-remount-test
Change-Id: I847f0b8cc2a952bb4c8656a43da783f312670061
2022-09-02 00:52:29 +08:00
Deyao Ren
259b63d71c Removed property init.apex.<apex-name>.load/unload.
Bug: 240533726
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I7ed149f24dc4b116865320c85389ffe7bae6ae0d
2022-09-01 16:14:00 +00:00
Alessandra Loro
68e3a6f94a Merge "Resolve ro.debuggable at build time" 2022-09-01 14:54:36 +00:00
Alessandra Loro
7bd6dca855 Resolve ro.debuggable at build time
Test: n/a
Bug: 243645021

Change-Id: I42c4b1e81383d83c73a565c5e74ac22f17389faf
2022-09-01 13:32:36 +00:00
Yi-yo Chiang
64198bc28f Merge "adb-remount-test: Refactor remount -R & disable-verity test" 2022-09-01 09:11:39 +00:00
Yi-Yo Chiang
310c4dbc62 adb-remount-test: Refactor test cleanup
* If adb remount calls for a reboot during cleanup, this means it's
  trying to recreate vendor overlay. Don't reboot in this case because
  it's pointless. Total test runtime reduced by one reboot.
* Since this entire script assumes /system & /vendor must exist and
  remountable, add them to the MOUNTS list unconditionally.
* Remove /system/hello & /vendor/hello test, as we can just loop over
  MOUNTS to check those.

Bug: 243116800
Test: adb-remount-test
Change-Id: I2360314c404ee247356146760314c91ba2795ff5
2022-09-01 16:23:05 +08:00
Yi-yo Chiang
2e0913ce6c Merge "adb-remount-test: Refactor prologue & /sys/module/overlay mining" 2022-09-01 05:45:36 +00:00
Elliott Hughes
b7475a4c3f Add the "sys" group for tests.
It's useful to have a group that shares a numeric id with Linux and
macOS. "root" doesn't count because group 0 is actually called "wheel"
on the BSDs, and macOS has "daemon" and "kmem" as its groups 1 and 2.

This lets us have toybox tar tests that have the same results on all
supported OSes without special handling.

Test: treehugger
Change-Id: I4704d6f9ada84f3065831a099b34d1c20c4c6b03
2022-09-01 00:01:04 +00:00
Deyao Ren
e37c15e9b0 Merge changes from topic "vapex_stop_service"
* changes:
  Remove and add service and action during apex load and unload
  Stop services when unload an apex
2022-08-31 16:09:43 +00:00
Yi-Yo Chiang
9c7cd64845 adb-remount-test: Replace libc.so test with build.prop test
Since /bionic mountpoint is deprecated, we don't _have_ to explicitly
check consistency of /system/lib/bootstrap/libc.so anymore.

Remove the test which adds junk to the end of libc.so.  Editing libc.so
looks dangerous (albeit not!) and has unclear expectations.
Add test which edits /system/build.prop. Editing build.prop file is more
"safe" as it's just text edit, and the expectations are clear (edited
system properties should be loaded after reboot.)

Bug: 243116800
Test: adb-remount-test
Change-Id: I51bd32c6ffcc57eb646eeec0537e996847e6c2a5
2022-08-31 17:13:20 +08:00
Yi-Yo Chiang
ef8bf18dad adb-remount-test: Check override_creds only if overlayfs is used
Instead of probing the kernel to see if overlayfs is supported, just
check `df` after disable-verity.
If after disable-verity and overlays were mounted, then check that
override_creds patches are applied.

Bug: 243116800
Test: adb-remount-test
Change-Id: Icb1363278536a8177836263882b1a8a0d9f246c9
2022-08-31 15:49:50 +08:00
Yi-yo Chiang
3a6ec217c6 Merge "adb-remount-test: Refactor restore()" 2022-08-31 07:05:06 +00:00
Yi-yo Chiang
447aa1af46 Merge changes Ie5426ff3,I04beb9e0,If90e8d1a
* changes:
  adb-remount-test: Refactor check_eq & check_ne
  adb-remount-test: Add LOG() function
  adb-remount-test: Add surgically_wipe_overlayfs & is_overlayfs_mounted util
2022-08-31 06:10:37 +00:00
Yi-Yo Chiang
6b06037650 adb-remount-test: Print log timestamp & auto-detect color
* Change --print-time to default true, and print timestamp of each log
  message.
* Auto-detect color support. If stdout if terminal, then color default
  to true, else default to false.

Bug: 243116800
Test: adb-remount-test
Change-Id: Id8425488c4b18fe0bc4dd7e50c3e2ae2e8c74cfe
2022-08-31 11:34:00 +08:00
Yi-Yo Chiang
2f0bcd93c2 adb-remount-test: Refactor raw remount & remount from scratch test
Move "raw remount test" right after "disable-verity -R test".
Device is expected to be in a clean state right after disable-verity, so
we can perform "raw remount test" immediately after. This saves us one
reboot.

Move "remount from scratch test" right before "remount -R test".
Since they both require overlay teardown state, group them together so
we only need to teardown (and reboot) once. This saves us one reboot.

Total test runtime reduced by two reboots.

Bug: 243116800
Test: adb-remount-test
Change-Id: Ifd95ba713f1819a7d31e88cd70077dc306c64c58
2022-08-31 11:33:57 +08:00
Yi-Yo Chiang
4cf5421edc adb-remount-test: Refactor fastboot flash vendor test
Instead of relying on a local dev tree (which CI machines never have),
just pull the vendor partition image from device.
This way we can have CI coverage on fastbootd as well.

Stop redefining cleanup() hook, just toss all temporary files to $TMPDIR
and always clean up $TMPDIR on exit.

Clarify logs and error messages.

Bug: 243116800
Test: adb-remount-test
Change-Id: I08fb8df58a61c03db3274b22b51e40a1a8f41095
2022-08-31 11:32:55 +08:00
Yi-Yo Chiang
7da7fa4d09 adb-remount-test: Refactor remount RW test
* Check mount flag changes (ro/rw) before and after "adb remount".
* Add comment explaining what's going on with the |uses_dynamic_scratch|
  and |scratch_partition| variables.
* Add rich logs reporting infomation about the scratch partition.
* Add rich error messages.
* Filter out /data devices and external volumes (vold managed device)
  when checking RW partitions. We are only interested in system
  partitions.
* Remove redundant "remount from setup" test from end-of-file, as they
  are testing the same thing as the refactored remount test. Total test
  runtime reduced by one reboot.

Bug: 243116800
Test: adb-remount-test
Change-Id: Icda5bff78372bebfe2e166d8537a06be66fff886
2022-08-31 11:32:55 +08:00
Yi-Yo Chiang
9a636d2a85 adb-remount-test: Discover fstab pathname more intelligently
Pick exactly one fstab file whose pathname suffix matches one of the
fstab suffix properties.
This helps on CF who ships redundant copies of fstab.

Bug: 243116800
Test: adb-remount-test
Change-Id: I4d38859014161e14dba1f7e19dbce44a2621d0f1
2022-08-31 11:32:55 +08:00
Yi-Yo Chiang
7b126377b2 adb-remount-test: Refactor remount -R & disable-verity test
Since remount -R and disable-verity -R have similar expectations, group
them together and reuse each other's test code.
Remove the redundant "remount -R" test at end of file.
Total test runtime reduced by one reboot.

Bug: 243116800
Test: adb-remount-test
Change-Id: I510a9de39f94b73450df9abf82a55496df96bea1
2022-08-31 11:32:54 +08:00
Yi-Yo Chiang
c6f434c587 adb-remount-test: Refactor prologue & /sys/module/overlay mining
While doing precondition check, verify that device is debuggable and
unlocked.

The /sys/module/overlay mining code had some remarkably written chained
... && ... || ... expressions. This is also remarkably unreadable for
those untrained of bash command chaining pitfalls.
Just rewrite these with plain old if-then-else expressions.

Bug: 243116800
Test: adb-remount-test
Change-Id: I56b1dea5b9147755a43462682a51bc5802ee64c1
2022-08-31 11:32:54 +08:00
Yi-Yo Chiang
8f8d920588 adb-remount-test: Refactor restore()
The redefining of cleanup hooks are making the script rather difficult
to read. Instead of redefining restore() just to skip some parts of it,
let restore() check flags and conditionally execute cleanup code.

Bug: 243116800
Test: adb-remount-test
Change-Id: If9d627618b54e215200455e8133492670737571d
2022-08-31 11:32:54 +08:00
Yi-Yo Chiang
1a0e4d0bf7 adb-remount-test: Refactor check_eq & check_ne
Just use bash [[ for regex compare, which result in shorter code and
more robust.
Simplify the messaging pipeline:
  If success, don't print anything and return 0. Let caller decide what
  to log.
  If failure and --warning, log error message and return 1.
  If failure and ! --warning, die with error message.

Bug: 243116800
Test: adb-remount-test
Change-Id: Ie5426ff3fa57395aa6b4fe71c9bf96bd8e9afc35
2022-08-31 11:32:54 +08:00
Yi-Yo Chiang
32277d0967 adb-remount-test: Reduce noise from initial overlayfs diagnostics
There's quite a lot of noise from running "Checking current overlayfs
status". Improve the test output by filtering uninteresting df lines.

* "/apex/..." mounts not interesting.
* "rw" mounts not interesting.
* "fuse" devices not interesting.

Bug: 243116800
Test: adb-remount-test
Change-Id: Id15844d853aaf3f7ed86f1a83544494b697b5b39
2022-08-31 11:32:54 +08:00
Yi-Yo Chiang
bd9335d43d adb-remount-test: Add LOG() function
Right now there are a lot of log commands in the form of
  "echo <color code><log type><color code> [msg]... >&2"
which is painful to read, and test writers often accidentally omit the
trailing ">&2".

Add a LOG() function which takes care of the log formatting and stderr
redirecting once and for all.
Also bulk edit existing log commands to use LOG() everywhere.

Bug: 243116800
Test: adb-remount-test --color
Change-Id: I04beb9e09b28c08a3a6f4309bf2d4b6de906df90
2022-08-31 11:32:54 +08:00