Merge changes from topic "aconfig-misc-fixes-2023-09-04" into main

* changes:
  aconfig: add invariant checks for `is_fixed_read_only`
  aconfig: re-enable development with cargo
This commit is contained in:
Treehugger Robot
2023-09-05 17:21:22 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 4 deletions

View File

@@ -215,6 +215,17 @@ pub mod parsed_flag {
super::tracepoint::verify_fields(tp)?;
}
ensure!(pf.bug.len() == 1, "bad flag declaration: exactly one bug required");
if pf.is_fixed_read_only() {
ensure!(
pf.permission() == ProtoFlagPermission::READ_ONLY,
"bad parsed flag: flag is is_fixed_read_only but permission is not READ_ONLY"
);
for tp in pf.trace.iter() {
ensure!(tp.permission() == ProtoFlagPermission::READ_ONLY,
"bad parsed flag: flag is is_fixed_read_only but a tracepoint's permission is not READ_ONLY"
);
}
}
Ok(())
}
@@ -547,7 +558,7 @@ parsed_flag {
description: "This is the description of the second flag."
bug: "SOME_BUG"
state: ENABLED
permission: READ_WRITE
permission: READ_ONLY
trace {
source: "flags.declarations"
state: DISABLED
@@ -556,7 +567,7 @@ parsed_flag {
trace {
source: "flags.values"
state: ENABLED
permission: READ_WRITE
permission: READ_ONLY
}
is_fixed_read_only: true
}
@@ -570,14 +581,14 @@ parsed_flag {
assert_eq!(second.description(), "This is the description of the second flag.");
assert_eq!(second.bug, vec!["SOME_BUG"]);
assert_eq!(second.state(), ProtoFlagState::ENABLED);
assert_eq!(second.permission(), ProtoFlagPermission::READ_WRITE);
assert_eq!(second.permission(), ProtoFlagPermission::READ_ONLY);
assert_eq!(2, second.trace.len());
assert_eq!(second.trace[0].source(), "flags.declarations");
assert_eq!(second.trace[0].state(), ProtoFlagState::DISABLED);
assert_eq!(second.trace[0].permission(), ProtoFlagPermission::READ_ONLY);
assert_eq!(second.trace[1].source(), "flags.values");
assert_eq!(second.trace[1].state(), ProtoFlagState::ENABLED);
assert_eq!(second.trace[1].permission(), ProtoFlagPermission::READ_WRITE);
assert_eq!(second.trace[1].permission(), ProtoFlagPermission::READ_ONLY);
assert!(second.is_fixed_read_only());
// valid input: empty

View File

@@ -1,3 +1,4 @@
#[cfg(not(feature = "cargo"))]
#[test]
fn test_flags() {
assert!(!aconfig_test_rust_library::disabled_ro());

View File

@@ -1,3 +1,4 @@
#[cfg(not(feature = "cargo"))]
#[test]
fn test_flags() {
assert!(!aconfig_test_rust_library::disabled_ro());