From 01d6bb3aae26bce1a65a5de4f06cc3215b2964c7 Mon Sep 17 00:00:00 2001 From: William Escande Date: Wed, 18 Sep 2024 18:01:20 -0700 Subject: [PATCH] aconfig: cpp test-mode lib Incompatible interface between test-mode and normal mode. Bluetooth is linking the normal flag for the code that is shipped, and it is linking the test-mode library for unit testing. While trying to move some test to use the test-mode, we noticed some failure as the flag returned were not the one expected. It appear the code and the test are built against 2 different library, but linked against one. The provide interface only contains getter in normal mode, and it is alternating between getter/setter in test-mode. By moving the setter in test-mode toward the end of the interface, we are not modifying the assumed order for the code built against the normal mode. This CL is a short term fix, to make the test goes green and prevent immediat failure. An refactor of the cpp generated code should be done to avoid using 2 different version of the same symbol in 2 different libs. Bug: 311772251 Test: atest aconfig.test Change-Id: I97f6523452c451d005d2e92bfa1ef861611ab840 --- tools/aconfig/aconfig/src/codegen/cpp.rs | 32 +++++-------------- .../templates/cpp_exported_header.template | 7 ++-- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/cpp.rs b/tools/aconfig/aconfig/src/codegen/cpp.rs index 2c569da8f6..7a9c382bc7 100644 --- a/tools/aconfig/aconfig/src/codegen/cpp.rs +++ b/tools/aconfig/aconfig/src/codegen/cpp.rs @@ -283,39 +283,23 @@ public: virtual ~flag_provider_interface() = default; virtual bool disabled_ro() = 0; - - virtual void disabled_ro(bool val) = 0; - virtual bool disabled_rw() = 0; - - virtual void disabled_rw(bool val) = 0; - virtual bool disabled_rw_exported() = 0; - - virtual void disabled_rw_exported(bool val) = 0; - virtual bool disabled_rw_in_other_namespace() = 0; - - virtual void disabled_rw_in_other_namespace(bool val) = 0; - virtual bool enabled_fixed_ro() = 0; - - virtual void enabled_fixed_ro(bool val) = 0; - virtual bool enabled_fixed_ro_exported() = 0; - - virtual void enabled_fixed_ro_exported(bool val) = 0; - virtual bool enabled_ro() = 0; - - virtual void enabled_ro(bool val) = 0; - virtual bool enabled_ro_exported() = 0; - - virtual void enabled_ro_exported(bool val) = 0; - virtual bool enabled_rw() = 0; + virtual void disabled_ro(bool val) = 0; + virtual void disabled_rw(bool val) = 0; + virtual void disabled_rw_exported(bool val) = 0; + virtual void disabled_rw_in_other_namespace(bool val) = 0; + virtual void enabled_fixed_ro(bool val) = 0; + virtual void enabled_fixed_ro_exported(bool val) = 0; + virtual void enabled_ro(bool val) = 0; + virtual void enabled_ro_exported(bool val) = 0; virtual void enabled_rw(bool val) = 0; virtual void reset_flags() {} diff --git a/tools/aconfig/aconfig/templates/cpp_exported_header.template b/tools/aconfig/aconfig/templates/cpp_exported_header.template index 0f7853e405..4643c9775c 100644 --- a/tools/aconfig/aconfig/templates/cpp_exported_header.template +++ b/tools/aconfig/aconfig/templates/cpp_exported_header.template @@ -27,12 +27,13 @@ public: {{ -for item in class_elements}} virtual bool {item.flag_name}() = 0; - {{ -if is_test_mode }} - virtual void {item.flag_name}(bool val) = 0; - {{ -endif }} {{ -endfor }} {{ -if is_test_mode }} + {{ -for item in class_elements}} + virtual void {item.flag_name}(bool val) = 0; + {{ -endfor }} + virtual void reset_flags() \{} {{ -endif }} };