Commit Graph

468 Commits

Author SHA1 Message Date
Jihoon Kang
9c1450e0d2 Modify dependencies of fake_device_config
This change modifes the dependencies of fake_device_config by setting
the sdk_version to none instead of core_current, and setting the
appropriate system_modules in order to resolve circular dependencies.

Test: m fake_device_config && BUILD_FROM_SOURCE_STUB m fake_device_config
Change-Id: I497e2db9ea3456057a1e3f5c624cbd2042da6837
2024-02-13 06:54:49 +00:00
Dennis Shen
248510a659 aconfig: remove libcxx dependency for now
Contenxt: b/324826914, libcxx is the culprit of the linking failure.
Remove libcxx dependency for now.

Bug: b/324826914
Test: atest aconfig_storage_file.test
Change-Id: I55b1a41efbf4486715f465a8d56a4e2e6ab0254a
2024-02-12 20:09:51 +00:00
Stephen Hines
68a4bdb3eb Test modules should always be last
```
error: items after a test module
   --> build/make/tools/aconfig/aconfig/src/test.rs:18:1
    |
18  | pub mod test_utils {
    | ^^^^^^^^^^^^^^^^^^
...
345 | pub use test_utils::*;
    |         ^^^^^^^^^^
    |
    = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
    = note: `-D clippy::items-after-test-module` implied by `-D
warnings`
    = help: to override `-D warnings` add
`#[allow(clippy::items_after_test_module)]`
```

Bug: http://b/321303117
Test: toolchain/android_rust/test_compiler.py --prebuilt-path dist/rust-dev.tar.xz --target aosp_cf_x86_64_phone --all-rust
Change-Id: I2c95af50a5d389fc37e1abc677e9b4d34b6562b4
2024-02-09 16:46:48 -08:00
Dennis Shen
8b5244c841 aconfig: aconfig storage cpp api on device integration test
Bug: 321077378
Test: atest aconfig_storage.test.cpp
Change-Id: I99532e9288f411d6025868341883fdbef600cfd7
2024-02-09 21:10:43 +00:00
Dennis Shen
91ba7d56ea Merge "aconfig: add storage api rust test on the host" into main 2024-02-09 21:00:16 +00:00
Dennis Shen
2ea228ef70 Merge "aosp: reenable the filtered out test point in atest" into main 2024-02-09 20:09:28 +00:00
Dennis Shen
997e65779a Merge "aconfig: create c++ interlop from rust flag apis" into main 2024-02-09 16:53:53 +00:00
Dennis Shen
4f6f12841c aosp: reenable the filtered out test point in atest
A more systematic fix. Now for each test point, we create temp file
copies at temp dir and explicitly set the file permission of these temp
files. This should bypass the issue that test build artifact file
permission are not guaranteed. Because we will generate these test
storage files on the fly at run time.

Bug: b/324459233
Test: atest aconfig_storage_file.test
Change-Id: Iaa7083be6cc49421090ab4c74e54c4bcf8e35801
2024-02-09 16:51:17 +00:00
Dennis Shen
213dbb71a5 aconfig: add storage api rust test on the host
Bug: 321077378
Test: atest aconfig_storage.test.rust
Change-Id: I3301834909441dea471c0d4b1aae0a117af7dc29
2024-02-09 15:54:22 +00:00
Dennis Shen
2f0929d867 aconfig: turn off the offending test point
Bug: b/324459233
Test: atest aconfig_storage_file.test and the test point is no longer executed.
Change-Id: I34b5da7a1b152f213926cc2e1f9511785e9d384f
2024-02-09 12:48:52 +00:00
Dennis Shen
618e66a28b aconfig: create c++ interlop from rust flag apis
Using cxx to generate c++ code for the apis that are marked to exported
in the ffi mod in src/lib.rs. For generated code simplicity, it returns
a new flag struct for each rust api.

Create a cc_library to wrap around generated c++ code. See the created
aconfig_storage.hpp for the exported header. Note there is a nested
aconfig_storage::test_only_api namespace, where we place test only apis.
The production apis are placed under aconfig_storage namespace.

Bug: 321077378
Test: m libaconfig_storage_cc
Change-Id: I73a85a26d3749908abc461362f5e0bfc3f85bf4d
2024-02-09 02:51:08 +00:00
Dennis Shen
e7fde3a86f Merge "aconfig: add top level flag read lib api" into main 2024-02-08 18:17:27 +00:00
Dennis Shen
1452104995 aconfig: add top level flag read lib api
1, update android build soong targets as now libmemmap2 has been
introduced to android code base.

2, add three public apis for package offset query, flag offset query,
and flag value query. These apis assume the stoarge location pb file is
at /metadata/aconfig/aconfig_storage.pb. This file will be created by
storage daemon. For testing purposes, we also expose impl version of
these apis that accept a custom storage location pb file.

Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: I91b284e2dfcdb8ff3674d463ed1c13696d9ae020
2024-02-08 14:57:51 +00:00
Mårten Kongstad
36402f1c35 aconfig: move all tests to presubmit
The tests added to TEST_MAPPING in aosp/2870454 have now soaked in
postsubmit long enough to be allowed to advance to presubmit.

Bug: N/A
Test: atest --test-mapping $(gettop)/build/tools/aconfig
Test: Treehugger
Change-Id: Ia75c76ae114c16a57c26aafa159560639baea707
2024-02-06 08:21:32 +01:00
Oriol Prieto Gascó
0151f72e00 Merge "Set the container field of aconfig flags" into main 2024-02-06 00:38:04 +00:00
Zhi Dou
d43b446ebb aconfig_proto: add doc in aconfig.proto file
This change adds docs in aconfig.proto file and adds more detail in the
error message for bad package, name and namespace.

Bug: 318759389
Test: atest aconfig.test
Change-Id: I0d45495cd864506b2fcc06ad47e3ffbd6caca9fb
2024-02-05 16:41:56 +00:00
Oriol Prieto Gasco
c6343b169b Set the container field of aconfig flags
Test: atest aconfig.test
Bug: 312769710
Change-Id: Ia4e3f97e23d6113446d567db6bc1410c300ea667
2024-02-05 16:30:04 +00:00
Dennis Shen
7bb9cda6c4 aconfig: update mapped_file
Minor change to mapped_file module, create utility function to verify
file is readonly and map. Also, update the unit test to create temp pb
file instead of writing to the test dir.

Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: Id903ed458613e4aac8d2cbb1664fd8293de1a494
2024-01-31 19:01:56 +00:00
Dennis Shen
c4cb665612 Merge "aconfig: create memory map file module" into main 2024-01-31 17:10:35 +00:00
Dennis Shen
19370a0a31 aconfig: create memory map file module
This module is repsonsible for finding the storage file location based on a
pb file and then map these storage files into memory using memmap2
crate. The mapped files are cached in a static hashmap in this module.

Note that memmap2 crate has not been introduced to AOSP yet as a 3p
crate. It is in the process of importing to AOSP ATM. So in src/lib.rs,
we only include this module if we are building the target using cargo.

Also, the test storage files: package.map, flag.map and flag.val are
generated based on the storage test aconfig files in
aconfig/aconfig/tests dir. With aconfig create-cache command first to
produce cache files, and then aconfig create-storage command to create
each storage file.

aconfig create-cache --package com.android.aconfig.storage.test_1 --container system --declarations ./storage_test_1.aconfig --cache com.android.aconfig.storage.test_1.cache

aconfig create-cache --package com.android.aconfig.storage.test_2 --container system --declarations ./storage_test_2.aconfig --cache com.android.aconfig.storage.test_2.cache

aconfig create-cache --package com.android.aconfig.storage.test_4 --container system --declarations ./storage_test_4.aconfig --cache com.android.aconfig.storage.test_4.cache

aconfig create-storage --container system  --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file flag_val --out ./flag.value

aconfig create-storage --container system  --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file package_map --out ./package.map

aconfig create-storage --container system  --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file flag_map --out ./flag.map

Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: Id4bd26ce1a2513cdda201b479cec2b8c04faabfe
2024-01-31 13:54:16 +00:00
Mårten Kongstad
6fdaa11d7c aconfig: fix formatting warnings
Update the rust toolchain to 1.75.0 and run `cargo fmt`.

Bug: N/A
Test: cargo fmt --check
Test: atest :all
Change-Id: I718c350f4c346b85ff3608f3101278c2ee776b36
2024-01-31 09:40:21 +01:00
Dennis Shen
eef9192987 aconfig: remove bucket_index from PackageTableNode/FlagTableNode struct
bucket index currently is a field in PackageTableNode/FlagTableNode, but this is
purely aux info that is never searilized or deserialized. Therefore we
should remove it from the struct definition. Instead aconfig should
define a wrapper struct that wraps around an instance PackageTableNode/FlagTableNode
as well as aux info like bucket_index.

Bug: 321077378
Test: atest aconfig.test && atest aconfig_storage_file.test
Change-Id: I20f2565d20b7feb5d39754e91cd6a9affb1f0e70
2024-01-30 15:16:29 +00:00
Dennis Shen
f39e4a2273 Merge "aconfig: add flag value query pub function" into main 2024-01-29 20:48:48 +00:00
Dennis Shen
9a76f645a2 Merge "aconfig: add flag table offset query function" into main 2024-01-29 19:47:23 +00:00
Dennis Shen
043a1eec4d Merge "aconfig: create package table query public function" into main 2024-01-29 19:47:15 +00:00
Dennis Shen
78bea3d66c aconfig: add flag value query pub function
Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I83dd93c5f8d640ddbe85493a470af68df1e3e69d
2024-01-29 18:54:13 +00:00
Dennis Shen
9fd970198d aconfig: add flag table offset query function
Bug: b/321077378
Test: atest aconfig.test; atest aconfig_storage_file.test
Change-Id: Ib0ec1ec809c65d8f9f1284e4214cfbb683812f1d
2024-01-29 15:11:55 +00:00
Dennis Shen
8aa9bbeb99 aconfig: create package table query public function
Bug: b/321077378
Test: atest aconfig.test
Change-Id: I097e8ebecff6d5d9e73738a7f80a63cb482bcfbe
2024-01-29 14:43:19 +00:00
Mårten Kongstad
edd678063c aconfig: fix workspace resolver warning
Fix the following warning:

  warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
  note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
  note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
  note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions

Further info: https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html

Bug: N/A
Test: cargo c # no warnings related to the resolver
Change-Id: I5ee546e4f2ba9e854026bf4baee380e89cf4a01b
2024-01-29 14:51:51 +01:00
Dennis Shen
997745dc13 aconfig: add aconfig_storage_metadata proto
Introduce a new proto to capture storage file location for each
container. This proto file will appeara as
/metadata/aconfig/storage_file_location.pb. Storage service daemon is
responsible for writing entires to it when a new storage file set is
available. The flag read lib will use this file to find the
corresponding storage file and mmap them.

Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I226e76be895805dce52a075050dcd5b42d337be8
2024-01-26 18:02:07 +00:00
Dennis Shen
c7a1c76e28 Merge "aconfig: create unit test targets for aconfig_protos and aconfig_storage_file crate" into main 2024-01-26 18:01:54 +00:00
Dennis Shen
a4294b0c6a aconfig: create unit test targets for aconfig_protos and
aconfig_storage_file crate

also added a bunch of comments to satisfy android lint requirements

Bug: b/321077378
Test: atest aconfig.test, atest aconfig_protos.test, atest aconfig_storage_files.test
Change-Id: I9bce302ac3bc98c5347e5334d915e77337ee89c4
2024-01-25 17:33:36 +00:00
Zhi Dou
b874ca75e4 aconfig: add isOptimizationEnabled in FakeFeatureFlagsImpl
This change adds isOptimizationEnabled method in FakeFeatureFlagsImpl.
This method can help test to decide whether the code using flag is
optimized.

Bug: 309406391
Test: atest aconfig.test aconfig.test.java
Change-Id: I7e7109ac06ab44f9b8dee56c76be9479f60a9148
2024-01-25 16:07:32 +00:00
Dennis Shen
cf9a752092 aconfig: create aconfig_storage_file crate
Move aconfig storage file definition into its own crate, as flag read
lib will need it as well. The new crate is placed under
aconfig_storage_file dir.

Bug: b/321077378
Test: atest aconfig.test, Cargo test at repo root level
Change-Id: I91e8ada2c9bab479ed81cf03824042f3fa460be5
2024-01-24 21:33:42 +00:00
Dennis Shen
277e5dc36e Restructure aconfig repo to be a cargo workspace with many crates
Previously, aconfig repo is the root directory of aconfig binary crate,
but it also hosts printflags crate inside, and there is no cargo support
for printflags binary crate. In addition, with more aconfig development,
more crates are being added to this repo. Thus this repo should be
configured as a Cargo workspace with multiple crates rather than a
single crate.

Note the top level Cargo.toml file specifies the crates this workspace
carries:
(1) aconfig_protos: the proto library crate that will be used by many other
crates such as aconfig binary crate and printflags binary crate
(2) aconfig: the aconfig binary crate
(3) printflags: the printflags binary crate

(1) aconfig_protos crate setup:

Inside aconfig_protos dir we set up the aconfig_protos crate, the
previously src/proto.rs is now aconfig_protos/src/lib.rs, the build.rs
is carried over to this crate.

(2) aconfig binary crate setup:

Notice its Cargo.toml file claims package dependency on aconfig_protos
crate. It no longer carries proto related module and build.rs file.

(3) printflags binary crate setup:

Similary, notice that in its Cargo.toml file, it claims package
dependency on aconfig_protos crate.

With this setup, we can Cargo build/test each crate individually when
inside a specific crate dir. But we can also run Cargo build/test at
repo root level, which will build/test all the crates in this workplace.

This is the structuring cl. The next cl is to move storage modules into
its own library crate. This storage file library crate will be used by
both aconfig binary crate as well as flag read library crate (to be
created as another new crate here).

Bug: b/321984352
Test: top and individual crate dir level Cargo build/test, m each
individual targets

Change-Id: I75833f4997f7ee554ff6c1557df9ac87f62b2732
Merged-In: I75833f4997f7ee554ff6c1557df9ac87f62b2732
2024-01-24 02:18:52 +00:00
Dennis Shen
bac87875fa aconfig: create one file at each create-storage command invocation
Based on the build system feedback, it is better to create storage file
individually per each aconfig command invocation in a makefile. Thus
updating the create-storage command to create one file at a time based
on passed in file selection.

Bug: b/321243743
Test: atest aconfig.test and manually invoke create-storage command
Change-Id: I53625c08e44d3ece4476835827c6b7d28ddd5a1b
2024-01-19 19:02:07 +00:00
Dennis Shen
12eacc1e4e Merge "aconfig: create flag value file" into main 2024-01-12 18:37:53 +00:00
Treehugger Robot
45db966e90 Merge "aconfig: update cache arg to support multiple cache files" into main 2024-01-12 14:28:19 +00:00
Dennis Shen
d4ea260758 aconfig: create flag value file
Create flag_value module to create flag value file. Flag value file
contains a header section at the start of the file, followed by a
boolean array.

Bug: b/312243587
Test: atest aconfig.test
Change-Id: If76660189d63073fbd477e1e447240e0cd029604
2024-01-12 13:44:51 +00:00
Treehugger Robot
375cb9ab07 Merge "aconfig: Print flags with namespace, and sort them" into main 2024-01-12 04:31:30 +00:00
Dennis Shen
88ec7f624f Merge "aconfig: add flag type in flag table and remove info byte from value array" into main 2024-01-11 18:43:18 +00:00
Dennis Shen
cfb65827d8 aconfig: update cache arg to support multiple cache files
Bug: b/312243587
Test: atest aconfig.test
Change-Id: I6f5f9b5ca6e2a60b8aac9ea8bf3032b00b7af7da
2024-01-11 17:13:39 +00:00
Dennis Shen
d088650481 aconfig: add flag type in flag table and remove info byte from value
array

1, add flag type to the flag table. Before flag table only stores the
mapping from (package id, flag name) to (flag id u32). The original
intent is to do bitmasking on the top byte of flag id to indicate flag
type. Now split the flag id u32 to two u16, the first represent flag
type, the second represent flag id. So after the change, the flag table
now shows the following mapping:

(package id, flag name) -> (flag type as u16, flag id as u16)

2, originally we plan to store a info byte together with each flag
value. The info byte is used by storage service damemon to mark up the
flag status, such as if it is accepting server side flag push. After
internal discussion, it is better to just create the info bytes as
another file by storage service damemon. So that the value file is
purely a flag value array.

Bug: b/312243587
test: atest aconfig.test
Change-Id: I7f953076b4269cf786bc23723078290e5ebe10bc
2024-01-11 15:30:10 +00:00
Dennis Shen
25167e387f aconfig: remove debug print out
Bug: b/312243587
Test: atest aconfig.test
Change-Id: Id1bd4b5a1e60a7906908a432f58d45d2a4a56248
2024-01-10 22:55:37 +00:00
Dennis Shen
9b5d19bdff Merge "aconfig: create flag.map storage file" into main 2024-01-08 17:30:39 +00:00
Dennis Shen
01fca9877b Merge "aconfig: update storage unit test case" into main 2024-01-08 17:30:39 +00:00
Treehugger Robot
868f3e8dba Merge "aconfig: simplify is_valid_container" into main 2024-01-08 17:28:19 +00:00
Mårten Kongstad
32c6ef5e25 aconfig: simplify is_valid_container
str::split always returns at least one item (the entire string) if the
delimiter is not found. Simplify the implementation of
is_valid_container accordingly.

Bug: N/A
Test: atest aconfig.test
Change-Id: I3e92035309a7b019912710e42e69f9bdfa538795
2024-01-08 17:26:59 +01:00
Treehugger Robot
0f2e089f97 Merge "aconfig: remove trailing whitespace in test input" into main 2024-01-08 14:53:47 +00:00
Mårten Kongstad
36d3edbf1a aconfig: remove trailing whitespace in test input
Bug: N/A
Test: atest aconfig.test
Change-Id: I248acae172fdeeb9ab9c4bb922f36b560cb44787
2024-01-08 10:07:04 +01:00