Commit graph

81890 commits

Author SHA1 Message Date
Elliott Hughes
a8e259db66 Remove stray newline from err() call.
err() does this itself, and includes strerror() too.

Test: treehugger
Change-Id: I0e844f9cc3992e80a302b2f3ca1084b165582a9b
2023-09-07 19:30:31 +00:00
Daniel Zheng
720007ba43 Merge "Adding flag to flash only static partitions" into main 2023-08-09 18:09:00 +00:00
Treehugger Robot
a981d58972 Merge "Remove sub-includes from libcutils/threads.h" into main 2023-08-09 16:43:32 +00:00
Treehugger Robot
790c6315c3 Merge "snapuserd: Remove host_supported from snapuserd_test until it passes." into main 2023-08-09 00:44:39 +00:00
Treehugger Robot
8f5fab42df Merge "crasher: add pac and bti crashes." into main 2023-08-08 23:47:21 +00:00
David Anderson
8665b5f9df snapuserd: Remove host_supported from snapuserd_test until it passes.
Bug: 295074841
Test: snapuserd_test
Change-Id: Ie51263ec6971f9806bcfa2b522e5ed24da5d65cf
2023-08-08 16:34:19 -07:00
Daniel Zheng
5061a1cef8 Merge "Adding struct to hold compresion parameters" into main 2023-08-08 23:08:03 +00:00
Elliott Hughes
1b13b14758 crasher: add pac and bti crashes.
Also add the missing `.size` directives to all the assembler functions
for slightly improved backtraces.

Test: crasher64 pac; crasher64 bti
Change-Id: I8e0c127cbff56c33637e6ca8f1d927b971951807
2023-08-08 16:06:24 -07:00
David Anderson
7bd9162b14 Merge changes Ic18443d4,I9e9af999,I10e099fe,I00cf6ec9,Ia1ea4ba7 into main
* changes:
  snapuserd: Reduce size of COWs in tests.
  snapuserd: Add unit tests for ReadWorker::ReadAlignedSector.
  snapuesrd: Build snapuserd_test on host.
  snapuserd: Add an ITestHarness implementation for hosts.
  snapuserd: Don't specify a path to TemporaryFile.
2023-08-08 22:11:35 +00:00
David Anderson
9c525ff0ed Merge changes Ib33dc593,I6550682f,Ic0681cbf,Iaaf96a37,I89b15492 into main
* changes:
  snapuserd: Factor a base class out of tests.
  snapuserd: Add error propagation to tests.
  snapuserd: Add diagnostics for debugging races.
  snapuserd: Fix race condition in HandleManager shutdown.
  snapuserd: Remove test dependence on LoopDevice.
2023-08-08 19:46:53 +00:00
David Anderson
1333d87bfe snapuserd: Reduce size of COWs in tests.
This greatly reduces the runtime of snapuserd_test, from 4 minutes to
about 1.5 minutes.

Bug: 269361087
Test: snapuserd_test
Change-Id: Ic18443d4e4318f6ef6adadeabd47ccceeeb19b6f
2023-08-08 10:41:56 -07:00
David Anderson
dbda1300ae snapuserd: Factor a base class out of tests.
This factors a lighter weight class out of SnapuserdTest, so we can
construct tests without needing a HandlerManager/daemon.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ib33dc593a5b3d3df86853e73f245918ef36fd9fa
2023-08-08 10:41:56 -07:00
David Anderson
6aec095d68 snapuserd: Add unit tests for ReadWorker::ReadAlignedSector.
These tests are for real bugs that were previously not testable.

Bug: 288273605
Test: snapuserd_test
Change-Id: I9e9af999e4f5f988f4538750eba109f6b2fe448c
2023-08-08 10:41:56 -07:00
David Anderson
9fb4fc307c snapuserd: Add error propagation to tests.
snapuserd_test in general doesn't propagate errors, which means the
first failure will cascade into many failures. This can make it harder
to figure out what's going on.

Unfortunately error propagation is difficult with gtest, since bool
returns don't work with ASSERT_EQ and Android doesn't use exceptions.

Use ASSERT_NO_FATAL_FAILURE for now, since that is the least invasive
change.

Bug: 288273605
Test: snapuserd_test
Change-Id: I6550682fd63602bc15649f705def2915f6329357
2023-08-08 10:41:56 -07:00
David Anderson
0ec9b0eb92 snapuesrd: Build snapuserd_test on host.
Bug: 288273605
Test: snapuserd_test
Change-Id: I10e099feff30f09b8c9f0b9dcca64336cb0861b9
2023-08-08 10:41:56 -07:00
David Anderson
27add51152 snapuserd: Add an ITestHarness implementation for hosts.
This adds an implementation of ITestHarness suitable for running tests
on the host. IUserDevice and ProcessRequests are implemented just enough
for shutdown of ReadWorker to work. Most snapuserd tests are focused on
merging, and do not need a ReadWorker accepting requests.

Bug: 288273605
Test: snapuserd_test
Change-Id: I00cf6ec941fb6423290f7a299e5321adea7d8919
2023-08-08 10:41:56 -07:00
David Anderson
4e0d58c9e5 snapuserd: Don't specify a path to TemporaryFile.
Placing temporary files in the executable dir creates unexpected files
in the build dir when running on the host, which linger if snapuserd
crashes.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ia1ea4ba70b645a9d2f49419b91003bc62fb03cb2
2023-08-08 10:41:56 -07:00
David Anderson
9aa4218246 snapuserd: Add diagnostics for debugging races.
Adds calls to pthread_setname_np for each thread.

Clarify error messages from io_uring calls that return -errno.

Add log messages for some failure paths that didn't have any.

Add an ostream overload for MERGE_IO_TRANSITION, and add an INVALID
state for initialization.

Bug: 288273605
Test: builds
Change-Id: Ic0681cbf0017af67bcf52b98db184a9b48752faf
2023-08-08 10:41:55 -07:00
David Anderson
02191dbfac snapuserd: Fix race condition in HandleManager shutdown.
When HandlerManager shuts down, the monitor thread is left detached. The
monitor thread does not hold a shared_ptr reference to the
HandlerManager, so the pointer can be left dangling.

Fix this by not detaching the monitor merge thread.

This patch also changes the test harness to destroy
SnapshotHandlerManager on "shutdown", to avoid state leaking into the
next instance of snapuserd.

Bug: 288273605
Test: snapuserd_test
Change-Id: Iaaf96a37657c85cff4d2a8b15ccfde4aa03d3220
2023-08-08 10:40:32 -07:00
David Anderson
db70cbf78a snapuserd: Remove test dependence on LoopDevice.
LoopDevice requires root, which is an obstacle to running this test in
automation. The test also requires memfd which is not available in our
included glibc. Create an IBackingDevice layer so we can use temporary
files instead on host tests, while keeping the block-device code for
on-device tests, which more closely matches how snapuserd runs.

Bug: 288273605
Test: snapuserd_test
Change-Id: I89b154921b6bbcf8fe213ef7f5c4da4d48322909
2023-08-08 10:40:32 -07:00
Daniel Zheng
1cb36d300e Adding struct to hold compresion parameters
Since we're adding compression levels should consolidate this
information into one structure.  Adding in CowCompression struct
to hold this information and refactoring code to work off this struct

Test: ota
Change-Id: I969a3ae19ec80fd964bcfb76b39f42f8dd31a56d
2023-08-08 10:14:14 -07:00
David Anderson
1cf0e90409 Merge changes Ifddb5cb8,I8735ef6c,Ifd33c28e into main
* changes:
  snapuserd: Factor setpriority/settid calls into a helper.
  snapuserd: Add a harness to run tests without dm-user specific code.
  snapuserd: Add an IBlockServerFactory abstraction.
2023-08-08 17:12:12 +00:00
David Anderson
0c0745e627 Merge "snapuserd: Remove ambiguous BufferSink in workers." into main 2023-08-08 02:53:35 +00:00
David Anderson
a49b8d22f4 Merge changes Ie9a781e4,I060788c9,Ie75e9440 into main
* changes:
  snapuserd: Remove dm-user specific code from ReadWorker.
  snapuserd: Add an IBlockServer abstraction around dm-user.
  snapuserd: Rename snapuserd_merge to merge_worker.
2023-08-07 22:31:34 +00:00
David Anderson
dba77ad737 snapuserd: Factor setpriority/settid calls into a helper.
This allows disabling the code in host builds, since settid() isn't
available in the glibc prebuilt.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ifddb5cb8b04484a1ab0a29794d65c9839759a919
2023-08-07 13:37:47 -07:00
David Anderson
fe032d0391 snapuserd: Add a harness to run tests without dm-user specific code.
This patch adds an abstraction layer around Tempdevice (which wraps
device-mapper), and a layer to replace hardcoding of DmUserBlockServer.

The only implementation of the new layer, currently, is for dm-user.
However this will allow the harness to run with a backend chosen at
runtime, making testing on the host or of ublk much easier.

Bug: 288273605
Test: snapuserd_test
Change-Id: I8735ef6c373f3e5c5cdf3df461668ddd8e551f63
2023-08-07 13:37:47 -07:00
David Anderson
384b22ce58 snapuserd: Add an IBlockServerFactory abstraction.
To avoid SnapshotHandler hardcoding specifics about dm-user, this patch
adds a factory interface, responsible for providing IBlockServerOpener
objects.

The test harness will use this to facilitate dm-user-less testing on
host devices.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ifd33c28ee7076f30a8a90f745353893188f97a08
2023-08-07 12:01:24 -07:00
David Anderson
2cffe186ad snapuserd: Remove ambiguous BufferSink in workers.
BufferSink is not needed/used in all worker types, so move it explicitly
to MergeWorker. This also moves the sizeof(dm_user_header) computation
to BufferSink::Initialize.

Bug: 288273605
Test: snapuserd_test
Change-Id: I8fcea6f0e587ca6d8672df5ec58c4d4d14d4b72e
2023-08-07 12:01:03 -07:00
Treehugger Robot
a28b62e0c7 Merge "Add snapuserd_ramdisk execute permission" into main 2023-08-07 18:46:33 +00:00
David Anderson
a392fa3c78 snapuserd: Remove dm-user specific code from ReadWorker.
This uses the new IBlockServer abstraction layer instead.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ie9a781e44da7447426706d4874644aabf1be1946
2023-08-07 11:25:55 -07:00
David Anderson
e9277f91f8 snapuserd: Add an IBlockServer abstraction around dm-user.
This adds the planned interface that will abstract around dm-user (for
now), and later ublk at which point it can be adjusted as needed.

This declares the interface and implements it, but does not yet switch
snapuserd to use it. The implementation is copied from read_worker.cpp.

Bug: 288273605
Test: snapuserd_test
Change-Id: I060788c91dba78e52d315b5616b84b37eaf4040f
2023-08-07 11:25:54 -07:00
David Anderson
76094b499c snapuserd: Rename snapuserd_merge to merge_worker.
This follows the recently added names read_worker and worker.

Bug: 288273605
Test: builds
Change-Id: Ie75e94405a018dd0068aa24aefd268adb1aee17e
2023-08-07 11:01:39 -07:00
Treehugger Robot
405cbee131 Merge "core: fastboot: Fix data not being wiped on do_update" into main 2023-08-07 17:11:03 +00:00
Treehugger Robot
5d0aeaafb7 Merge "Remove gettid declaration from cutils" into main 2023-08-07 16:23:30 +00:00
David Anderson
bcb34d2c54 Merge "snapuserd: Move GetNumSectors call to snapuserd_server." into main 2023-08-07 15:12:20 +00:00
Snehal Koukuntla
6ac2c1693d Merge changes from topic "coverage-build" into main
* changes:
  Add Coverage controller
  Coverage library on the NS side for the coverage controller
2023-08-07 10:53:44 +00:00
David Anderson
1d8e349cce Merge "snapuserd: Split Tempdevice into a separate file." into main 2023-08-07 02:55:24 +00:00
Alexander Koskovich
6367e8953a core: fastboot: Fix data not being wiped on do_update
* With platform-tools-34.0.4 if you try to wipe data
   as apart of the fastboot update command it will not
   work, will just reboot to userspace without running
   the wipe task.

Test: fastboot -w update image.zip, observe that data
      gets wiped. Also verified 'fastboot update image.zip'
      does *not* wipe data.
Change-Id: I57a2c64029fd4f78968324bdf60251e1e962b3fd
2023-08-05 00:39:10 -04:00
David Anderson
babf3a9874 Merge changes from topic "libsnapuserd_client" into main
* changes:
  snapuserd: Remove dependence on libfs_mgr.
  snapuserd: Rename libsnapshot_snapuserd to libsnapuserd_client.
2023-08-04 20:14:54 +00:00
Snehal
806e70bb94 Add Coverage controller
Bug: 289523068

Change-Id: I5b36c274acc7da4e2d6b9cf91409a7b1af5f0d34
2023-08-04 08:54:52 +00:00
Snehal
ed34b6e232 Coverage library on the NS side for the coverage controller
Bug: 289520358

Change-Id: I6c2c0e5db9e8d9a0edec93d2fb123d185c7c4416
2023-08-04 08:54:32 +00:00
Yi-Yo Chiang
656e28174b Merge "libfstab: Optimize out C++ object copy" into main 2023-08-04 05:29:48 +00:00
Yi-Yo Chiang
63a3f34e4c Merge "init: Use libfs_mgr kernel cmdline parser" into main 2023-08-04 03:46:07 +00:00
Yi-Yo Chiang
4131a3afd1 Merge "remount: Replace ServiceManager::getService with checkService" into main 2023-08-04 03:31:33 +00:00
David Anderson
48d1c39da7 snapuserd: Move GetNumSectors call to snapuserd_server.
Calling this in snapuserd_core fails when the base path is a regular
file. Since the value is only read once, just call it from
snapuserd_server instead, which also means we don't have to add an
S_ISBLK check here.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ic26bf807b24611f2d97829d1b4eb1d0ede2feb6a
2023-08-03 16:24:26 -07:00
David Anderson
95f46b0758 snapuserd: Split Tempdevice into a separate file.
Bug: 288273605
Test: snapuserd_test
Change-Id: I3f1b01de8986d22de03bb31355ec09fe48c9204b
2023-08-03 16:15:37 -07:00
David Anderson
c132bf80ae snapuserd: Remove dependence on libfs_mgr.
The only function we use from libfs_mgr is WaitForFile, so factor that
out into libfs_mgr_file_wait. libfs_mgr has too much dependence on AOSP
internals to build on the host.

Bug: 288273605
Test: builds
Change-Id: I8e5eb4075ae01b9ca64074422171a487179e7943
2023-08-03 16:15:34 -07:00
David Anderson
75c5deed52 snapuserd: Rename libsnapshot_snapuserd to libsnapuserd_client.
We don't need this on the host, since the host will not be running
snapuserd as a server. Rename it for clarity and remove it where we can.

Bug: 288273605
Test: snapuserd_test
Change-Id: I679ef668a89411c670fea8d3b758bde589623548
2023-08-03 16:15:33 -07:00
Tomasz Wasilczyk
d22098f65d Remove sub-includes from libcutils/threads.h
This will drop any incentive to use this header

Bug: 289414897
Test: it builds
Change-Id: I3d7f56ac027f59794cb4cf533847c5fda5529906
2023-08-03 22:16:23 +00:00
Tomasz Wasilczyk
21a0716613 Remove gettid declaration from cutils
Bug: 289414897
Test: it builds
Change-Id: I22d93406cf065c0e3c7d94e800763974d228ee21
2023-08-03 22:16:12 +00:00