Commit graph

75 commits

Author SHA1 Message Date
David Anderson
c65121306a Introduce inotify-based replacements for fs_mgr_wait_for_file.
Bug: 134966533
Test: fs_mgr_unit_test gtest
Change-Id: I36802b87cec59b5277267eb919851ca390fea425
2019-06-18 15:27:09 -07:00
Mark Salyzyn
bc79fea7a1 fs_mgr: overlayfs: test: spelling mistake
Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I7bc68c15f53f94d1c14e2da91157ade362bc72f8
2019-06-05 11:12:05 -07:00
Mark Salyzyn
4d702e8dea fs_mgr: overlayfs: test: triage data missing after failure flash scratch
After flashing empty image to scratch device, the device did not
return after 3 minutes.  It also did not collect any triage data
reporting only:

[  FAILED  ] did not reboot after flash

Add triage data, increase timeout to 4 minutes.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Ic607abb5b2575d630bf6c27817a38a90820d24e1
2019-06-03 12:53:07 -07:00
Mark Salyzyn
cfe658a04e adb-remount-test: do not brick devices that support overlayfs but do not use it
restore() should not run adb enable-verity if device does not
use overlayfs even though it supports it.

Test: adb-remount-test
Bug: 132070014
Change-Id: I55d0e1a87eca9c5f258a1587c844f2a6e4b13b29
2019-05-28 08:11:54 -07:00
Mark Salyzyn
d07ab7e544 adb-remount-test: provide additional mount details
For the wipe and remount vendor test, report the df and
mount states to help triage.

Test: adb-remount-test.sh
Bug: 129319403
Change-Id: I4d9a87766d9857a974e601324ab77f69681bfd28
2019-05-28 08:08:49 -07:00
Mark Salyzyn
67788ef8a1 adb-remount-test: check devt and inode
Check to make sure st_dev and st_ino for the uploaded content
is as expected.

Test: adb-remount-test
Bug: 129319403
Bug: 132395411
Change-Id: I89826fc2740dfd2ead4bcd8988cfbbc315b77b09
2019-05-28 08:08:49 -07:00
Mark Salyzyn
d5f89343b1 adb-remount-test: add an avc check
Check if adb remount resulted in any unlabeled references just before
rebooting the device.

Test: adb-remount-test.sh
Bug: 129319403
Bug: 132395411
Change-Id: Ica0c14da39773f615d9b5e4cfc4602bd50c70e4e
2019-05-28 08:08:49 -07:00
Mark Salyzyn
53ec0a4649 adb-remount-test: parameterize fastboot_wait & adb_wait, increase timeout
Increase adb_wait time to 3 minutes since blueline device takes
maximum 2:38 (ten samples) to perform a ramdump should an
inopportune kernel panic occur.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Icfbb799f9420035a755090c9fc5fc2ee05dd68d3
2019-05-28 08:08:49 -07:00
Mark Salyzyn
359c56493c adb-remount-test: report wait duration
Report any unusual durations for how long it took to wait for the
device to come back if --print-time flag.  Also report the boot
reason if unexpected.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I233bbc7b01b025739d7d63191cb62952fa4b7b2a
2019-05-28 08:08:49 -07:00
Mark Salyzyn
00dd058a15 adb-remount-test: check vendor image signature before using
When developing and using the adb remount test, if device under test
is flashed from another source than the current visible tree, make
sure that the vendor image as-built and visible in a sandbox build
is not used indiscriminantly.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I30569a7c871f4c4038b0f7f9c05f5f1a5d12c766
2019-05-28 08:08:49 -07:00
Mark Salyzyn
dbd99f0d2b adb-remount-test: report usb user on unexpected connection
Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I1bc4009b71cac4ac4e06df38cc4da77f2819b88b
2019-05-28 08:08:49 -07:00
Mark Salyzyn
93bb1d0d6d adb-remount-test: wait-for-screen
If we reboot too agressively after a fresh flash either just before
test is run, or after vendor is flashed, we run the risk the device
will consider it a bad boot and head towards recovery or revert to
previous system.

Add checks to wait for the screen.

This can result in the test reporting issues with boot complete,
which will not fail the test currently, but can be used to determine
if the device under test is in a boot loop or fragile state.

Test: fastboot flashall ; adb-remount-test.sh
Bug: 132070014
Change-Id: Ia1b3800c44222cb8fbd9b00e897b32a256996ebc
2019-05-28 08:08:49 -07:00
Mark Salyzyn
277e413ac4 adb-remount-test: adb_reboot stdin issue
adb reboot can pull stdin content, block it.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I36f0bb7486cec2a18cd2b5550650a19f05c904b5
2019-05-28 08:08:49 -07:00
Mark Salyzyn
37921491a5 adb-remount-test: try to fixup device after reboot (recovery)
If device records a boot failure, the device could enter recovery
mode.  If so, try another reboot to see if the device will heal.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I4bee37e11f6344ab1ce176233d7d4e50df132cd7
2019-05-22 14:48:06 -07:00
Mark Salyzyn
30afd8b90b adb-remount-test: try to fixup device after reboot (fastboot)
If bootloader records a boot failure for a slot, the device can
enter fastboot mode.  If so, set the expected slot and reboot.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I801dcec7fd94ff084e54f585370d3c704a0de265
2019-05-22 14:47:58 -07:00
Mark Salyzyn
fb31593542 adb-remount-test: report lsusb for broken connection
Get more details about the usb connection when it times out.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: I784bea3a2cefcef423b576854abb795add47d123
2019-05-22 14:47:50 -07:00
Mark Salyzyn
1e5ab4811a adb-remount-test: stderr cleanup
Push stderr redirection to outer blocks if possible.

Test: adb-remount-test.sh
Bug: 132070014
Change-Id: Id3b2dfdcf0d778053e10fdb26eb0b1d99b455a46
2019-05-22 14:47:41 -07:00
Tom Cherry
f7545cea34 Vboot1.0: remove code to read verity state in userspace
The code to read verity state in userspace is deprecated in favor of
having the bootloader read and report the state, so this change
removes this now unused code.

Bug: 73456517
Test: boot
Change-Id: Ib626fd61850bce3016179ca92a9831c2ac29c032
2019-04-19 16:53:33 -07:00
Treehugger Robot
66b0c31f60 Merge "Increase adb-remount timeout" 2019-04-08 15:13:47 +00:00
Julien Desprez
c25a9da325 Increase adb-remount timeout
Unblocked the previous error we are now reaching the
default 5min timeout which is too short for this test.
Increase it to 1h.

Test: None
Bug: 117670584
Change-Id: I7fe40e54a7fb978392ee919226c0f05413e7349e
2019-04-03 08:27:29 -07:00
Julien Desprez
74239ea1b1 Replace reboot-fastboot by reboot fastboot
Older host adb client do not recognize reboot-fastboot,
switch it for "adb reboot fastboot" which should be the
same.

Test: None
Bug: 117670584
Change-Id: Iec5230ca66ec18fe7d7c0ebd3f9ab9596a6e7b3c
2019-04-02 17:04:39 -07:00
Julien Desprez
61dea3d154 Add the basic config to run through atest
Add basic config that can run through atest the remount
script.
Very first step before being able to run in infra.

Test: atest adb-remount-sh
Bug: 117670584
Change-Id: I399f79fb7d7cd1b8a832be23efb3b625be693f7e
2019-03-28 10:21:02 -07:00
Mark Salyzyn
b43448941a fs_mgr: overlay: test is alarming on legacy eng builds.
On taimen-eng build, the test reports:

  [  WARNING ] user fastboot missing required to invalidate, ignoring a failure
  ERROR: expected "cat: /vendor/hello: No such file or directory"
         got "Hello World! Fri Mar 22 08:56:32 PDT 2019"
  [  FAILED  ] vendor content after flash vendor

Which is a result of a corner case problem on devices that need to
use overlayfs to support adb remount, but do not have fastbootd as
required by Dynamic Android Partitions (DAP).  These legacy non-DAP
devices we consider this a Known Issue.

The message however is too alarming when reporting this Known Issue
that the test has notified you it accepts.  Use standard notification
output format, and change the result to a series of WARNING instead.

The output would then look like:

  [  WARNING ] user fastboot missing required to invalidate, ignoring a failure
  [  WARNING ] expected "cat: /vendor/hello: No such file or directory"
  [  WARNING ] got "Hello World! Fri Mar 22 08:56:32 PDT 2019"
  [  WARNING ] vendor content after flash vendor

Which still tells us there is an issue, but does not cause a state
of extreme alarm when looking at the test output.

Test: adb-remount-test.sh
Bug: 120448575
Bug: 128876541
Bug: 123079041
Change-Id: I1d8d60f23f7670ade7eae1be629264f7507e0cfd
2019-03-22 09:41:20 -07:00
Mark Salyzyn
a497ab9b55 fs_mgr: remount: manufacture a missing / entry for default fstab
Adjust adb-remount-test.sh to run on cuttlefish.

Test: adb-remount-test.sh
Bug: 128033396
Change-Id: I86825a519fcc821f7da67b0570d7eb2043ae4b42
2019-03-19 16:45:12 -07:00
Mark Salyzyn
60a76f330c fs_mgr: overlay: suppress noise associated with test mounting scratch partition
Add internal fs_mgr_is_ext4 and fs_mgr_is_f2fs to get heads up on
mount failures and thus bypass trying.

Test: adb-remount-test.sh
Bug: 109821005
Change-Id: Ieb1f8c19ced930b6fe2d1791ef710ce528da7e37
2019-03-18 12:50:00 -07:00
Mark Salyzyn
448fc9783c fs_mgr: test: track device active slot throughout
Report any discrepancy in the active slot.

Fix a problem with problematic error propagation for adb_cat()

Test: adb-remount-test.sh
Bug: 126256072
Change-Id: I8a5d4e364945c5e60d252333886987b8dca0cfb3
2019-03-06 08:25:36 -08:00
Mark Salyzyn
f4e7422c65 fs_mgr: remount: add partition argument list
Can supply a specific partition to remount.  Partitions can be
specified by name or mount point.  Some extra work to differentiate
an unknown partition, invalid partition, or one that is covered by
overlayfs.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: Iab6f51c2b5ebe01f1cea3fb235445d5e2f495365
2019-03-04 11:13:05 -08:00
Bowgo Tsai
d214b40685 fs_mgr: fix fs_mgr avb_keys parsing problem
We should check if the fs_mgr option starts with "avb_keys" before
"avb". Otherwise, it will treat "avb_keys" as "avb" fs_mgr option.

Bug: 112103720
Test: atest fs_mgr_unit_test

Change-Id: I88446222fa88e8ecfcd6f96d30ad4336ebe146a8
2019-02-28 10:37:37 +08:00
Mark Salyzyn
1188ce4e1d fs_mgr: remount: add -R argument
The -R flag tells remount it can reboot to disable verity or to
run fsck on an ext4 deduped filesystem, or both.

Testing may include a manual component because adb-remount-test.sh
needs to run from a device in an enable-verity state to test this.

Only recognizes chained avb.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I6ce4372532d9b933dcca9e2bec544d525b76c4d9
2019-02-27 13:03:13 -08:00
Mark Salyzyn
6b3f587ac7 fs_mgr: add remount command
There is currently no good option for callers to setup overlayfs
on-device, it is automated as part of the adb services.  Add a
remount command that does what is needed that simulates the salient
behaviors of the adb remount command.

Clean up some noise restoring device to original state when done.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: Idf213800a8182cb1c51600c8f574df8a8cd68d4a
2019-02-27 13:03:13 -08:00
Mark Salyzyn
6dc0dfe785 fs_mgr: overlayfs: test: add inRecovery check
Handle a device in recovery mode gracefully.  Handle a device
that fails to boot into a commanded state more gracefully.

Deal with regression where die() calls restore(), and we can not
have this under the conditions where we are ignoring the error
in a subshell.

Test: adb-remount-test.sh
Bug: 118225373
Bug: 123079041
Change-Id: Ie37beb245d0ec55eb00757cdb93da34ff9c42827
2019-02-27 13:03:08 -08:00
Mark Salyzyn
a9451a5db1 fs_mgr: overlayfs: requires override_creds patch for 4.4+ kernels (taimen)
The original adb-remount-test.sh when certifying kernels allowed a
pass on 4.4 kernels because it added new content, and missed a test
for overriding existing content.  When the test was added to confirm
APEX control of libc.so, it serendipitously added a check for
overriding existing content, which the 4.4 kernel did not allow to
pass.  Update the tests and documentation to reflect this new state
of affairs.

Summary: 4.4 kernel overlayfs driver worked partially without the
patch for override_creds.

Test: adb-remount-test.sh
Bug: 126256072
Change-Id: I979ea59a12bc0b9926826b9b09a7893ab3b9ee7f
2019-02-26 08:45:17 -08:00
Treehugger Robot
6d6ccdf7c6 Merge changes from topic "fs_mgr_unit_test"
* changes:
  Fix fs_mgr_unit_test
  fs_mgr: add test_suites: ["device-tests"]
2019-02-26 02:35:42 +00:00
Mark Salyzyn
94a0dedbc4 fs_mgr: overlayfs: test: Add --print-time option
Make it easier to collect test execution time.

Clean up some noise restoring device to original state.

Test: adb-remount-test.sh --print-time
Bug: 123079041
Change-Id: I56f12698ff25362dcefcf8a6ddd8f96a23b37f34
2019-02-25 21:33:33 +00:00
Bowgo Tsai
035f7f2b9c Fix fs_mgr_unit_test
The copy of /data/* doesn't work now, so put the fstab content
into the unittest source instead.

Also replacing ReadFstabFromFd with ReadFstabFromFile, to prevent
race.

Finally, two test cases are temporarily disabled due to read
fstab file error (root cause is still unknown).

Bug: 124837435
Test: atest 124837435
Change-Id: Ib6a3d931a48bffd8be23bda23fa4492babafd166
2019-02-22 10:09:52 +08:00
Tom Cherry
7b98b64dda fs_mgr: add test_suites: ["device-tests"]
Bug: 124837435
Test: tree-hugger
Change-Id: Ia82eb9000b62926abbea108fdd77f15f4a2a1f8c
2019-02-21 11:42:04 +08:00
Paul Trautrim
c10d3fdb2c Add presubmit test for vendor overlay
Add a test that creates files in the appropriate vendor_overlay directory and
verifies that they are correctly overlaid (or not) onto /vendor after rebooting.

Test: locally running atest
Change-Id: I65860dbeb837f86ac030fa51b3af93844e82de96
2019-02-16 08:24:35 +09:00
Mark Salyzyn
bbe33f7826 fs_mgr: harden adb-remount-test.sh
Harden adb-remount-test.sh script.  Add --no-color and --color
options.  Allows --serial to be passed in.  Add a recovery handler
that restores the device to verity enabled if possible.  List the
partitions sizes as they may be relevant to triaging errors.  Allow
for devices that have a mixed set of remounts, some direct, some
with overlayfs.  Allow two scripts to run at the same time on a host
machine targetting different devices.  Detect if wrong adb is used
for adb reboot-fastboot.

Add a build target for adb-remount-test.sh so that the script
is landed into the host tools bin for easy pickup.

Test: adb-remount-test.sh
Bug: 123079041
Change-Id: I6369a245a656419067ec4350a4dbdf78c9b0533e
2019-02-15 14:28:19 -08:00
Mark Salyzyn
dffdb4374b fs_mgr: overlayfs: export fs_mgr_overlayfs_candidate_list
Refactor fs_mgr_candidate_list into fs_mgr_overlayfs_candidate_list
that reports all the possible candidates.  The caller is responsible
for filtering out any that have verity enabled.

Sundry improvements to the adb-remount-test.sh script to improve
stability and feedback.

Test: adb-remount-test.sh
Bug: 122602260
Change-Id: I2399f83d8ed77d8f3d2ad1405d0c187ccbace764
2019-02-13 10:49:18 -08:00
Mark Salyzyn
6d109ecba3 fs_mgr: overlayfs support legacy devices (marlin)
Expand the tests to deal with the boot environment for marlin.
Recognize that older overlayfs drivers do not report to /sys/module
and the parsing /proc/filesystem is another place to interrogate this.

Suppress adb push and pull noise during testing.  Resolve APEX
failures.  Add some cleanup to test script.

NB: Running test to completion is difficult because marlin's USB
    driver is flakey enough through the multitude of reboots and
    may not reconnect.  The tester will have to notice when a reboot
    is stalling and manually disconnect and reconnect the USB
    connection to trigger discovery and to continue through the
    test sequences.  To make this easier, report when we are
    waiting for the device to make it easier to babysit.

Test: system/core/fs_mgr/tests/adb-remount-test.sh
Bug: 120448575
Bug: 123079041
Change-Id: I5fc5f01b4e4788ac57541cb5235f7ac4e4284d71
2019-02-06 15:35:29 -08:00
Tom Cherry
685c2c7b1e Remove old C fs_mgr interface
Remove superfluous fs_mgr flags as well.

Bug: 62292478
Test: tree hugger, fs_mgr_unit_test
Change-Id: Ib307400941b46ca8bcb51d479668efd82fc3ed2d
2019-02-04 15:09:02 -08:00
Tom Cherry
54ea49ba05 Merge "Add android::fs_mgr namespace for new Fstab code" 2019-01-31 19:35:54 +00:00
Tom Cherry
a3530e6366 Add android::fs_mgr namespace for new Fstab code
Should have been done a while ago, but better late than never.

Test: treehugger
Change-Id: I0ea6e8d459cd3f3b3ce2d00a7a6a9786d52c52dd
2019-01-30 20:20:05 -08:00
Jiyong Park
7c7189c469 Handle adb sync with Bionic under /bionic
Background:
We now have two sets of Bionic: the bootstrap Bionic which is at
/system/{lib|bin}/bootstrap for early processes and the default Bionic
which is from the runtime APEX for all the others. In order to give the
same path for Bionic to both categories of processes, the init prepares
two mount namespaces and bind-mount appropriate Bionic files onto the
common mount points under /bionic. For example,
/system/bin/bootstrap/linker is bind-mounted to /bionic/bin/linker for
the early processes. Likewise, /apex/com.android.runtime/bin/linker is
bind-mounted to the same path for rest of the processes.

In addition, in order not to propagate mount events in one mount
namespace to the other namespace, /bionic itself is created as a mount
namespace (via self bind-mount) and its propagation type is set to
private.

Changes required:
This however requires some adjustments to adb sync and remount
mechanism.

For remounting, /bionic path should also be re-mounted for RW, because
it is a RO mount in the beginning. This remounting is done only for the
system-as-root devices where entire / can be re-mounted as RW.

For synching, the sync thread creates a temporary mount namespace where
there is no bind-mount. This ensures that a path that the thread handles
is pointing to the correct file that is expected from the client side.

In addition, push operation to /bionic path is done without unlinking.
This is required because the mount points under /bionic are gone in the
current mount namespace but are still active in other mount namespaces.
If unlinked, the existing mounts on the path are all silently removed.
In order to prevent the unwanted situation, the moint points are not
unlinked but truncated to 0. This however is not a significant problem
because the files that serve as mount points do not carry any
useful information (i.e. the content is meaningless).

Bug: 879416
Test: adb sync
adb push <random_file> /bionic/bin/linker64
adb push <random_file> /system/bin/bootstrap/bin/linker64
system/core/fs_mgr/tests/adb-remount-test.sh
Change-Id: Id87dc9ee7ec5c43d06b54969b55e2cb394329317
2019-01-30 19:18:22 +09:00
Tom Cherry
eb6da459a0 fs_mgr: test parsing all mount and fs mgr options
Test: these new unit tests
Change-Id: Ibdecf0c97b313dc157b982340ca022b617757383
2019-01-25 16:03:52 -08:00
Tom Cherry
7e34f75075 fs_mgr: store file_contents_mode and file_names_mode directly
It doesn't really make sense to have extra logic to convert these
strings to enums then back again to strings for usage, especially
since with the C++ fstab, these strings are small enough to fall into
the small string optimization of std::string.

This will help make future changes cleaner as well.
Test: boot, fs_mgr_test

Change-Id: I5669ed10f2fc3eafdb137747446a2e93c24d55c4
2019-01-25 11:14:29 -08:00
Tom Cherry
afa0d88eea Merge "Update fs_mgr tests for new fstab format and add to TEST_MAPPING" 2019-01-25 17:25:58 +00:00
Mark Salyzyn
91ed3340d5 fs_mgr: overlayfs: test: test mount -o rw,remount command
WAI: Using mount -o rw,remount command can only work after the
overlays are setup.  After the second 'adb disable-verity' or
'adb remount -R' has been issued; the first only disables
verity and does not setup the backing storage.  If mount remount
command is issued after the first on an overlayfs system, it will
report a r/o filesystem.

Add a test that confirms that at least this supported behavior is
working, we do not test the corner case.

In the case of overlayfs, we have declared we will not support the
mount remount operation until then; we would need to modify toybox
to add logic that resides inside adb remount service.  toybox is
allowed to be adjusted to compile under Android and bionic, but it
is not supposed to have code that is specific to Android.

Fix last test to before this one to move us back into this state.
Fix the adb_sh command parser to handle properly quoting arguments
as it passes them to adb, since we will need it working for this
added test.

Report the product serial number of build description to aid triage.

Test: adb-remount-test.sh
Bug: 109821005
Bug: 122602260
Bug: 123079041
Change-Id: Ida051dbe2a918182db97f0f22f64b299e3c0a068
2019-01-23 14:41:49 -08:00
Tom Cherry
4e904768f7 Update fs_mgr tests for new fstab format and add to TEST_MAPPING
And fix a bug in the meantime, where mounts with no filesystem
specific mount options were incorrectly having an empty string in
their set of mount options.

Test: this test
Change-Id: I9b1f14d00a90f8b95a13fcecb3cfa7fe10a2f96a
2019-01-23 11:28:00 -08:00
Mark Salyzyn
52490faabe fs_mgr: overlayfs: test: check for existence of userspace fastboot
If there is no userspace fastboot, then overlayfs has a corner case
bug where overlay content is not wiped when the partition is flashed.
We will report a warning instead.

This is done to reduce the flakiness of the test results as we do not
intend to fix this specific corner case in the short term.  We would
require to record a sha representing the flash image, and the risks
were evaluated as too high of an impact on libavb to add interfaces
to expose the signatures, especially at first stage mount time.  All
new devices must support Dynamic Android Partitions (DAP), which
means they all have support for userspace fastboot, it will be
considered a misconfiguration and thus the position is we will not
fix this issue and only use this test adjustment to deal with legacy
products.  If a legacy non-DAP product wishes to close the issue
today, they must supply a user space fastboot.

Test: adb-remount-test.sh
Bug: 109821005
Bug: 123079041
Change-Id: I420cb87c19e3e184a974dfc373fb17c097d4858f
2019-01-22 15:28:38 -08:00