From 6dcc7132816d65cc8ccd9c300c65083886fd841f Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Mon, 21 Aug 2017 18:32:49 -0700 Subject: [PATCH] Audio VTS: Look for Audio policy config in all supported folders audio_policy_configuration.xml can be loaded from the following places: - /system/etc/ - /vendor/etc - /odm/etc Nevertheless the config validation test was expecting it to be in /vendor/etc exclusively. This patch changes the test logic to: - look for the config files in all 3 folders - make sure the config is unique Test: run the following script to check for regressions and test that invalid config make the test fail. ( set -xe runVTS() { vts-tradefed run commandAndExit vts \ --skip-all-system-status-check --primary-abi-only \ --skip-preconditions --module VtsHalAudioV2_0Target \ -t CheckConfig.audioPolicyConfigurationValidation; } echo "# Test valid config" runVTS echo "# Test multiple invalid match" adb shell touch /system/etc/audio_policy_configuration.xml ! runVTS adb shell rm /system/etc/audio_policy_configuration.xml echo "# Test multiple valid match" adb shell cp /{vendor,system}/etc/audio_policy_configuration.xml ! runVTS adb shell rm /system/etc/audio_policy_configuration.xml echo "# Test invalid config" adb shell sed -i /defaultOutputDevice/p /vendor/etc/audio_policy_configuration.xml ! runVTS adb shell sed -i '"/defaultOutputDevice/{p;N;d}"' /vendor/etc/audio_policy_configuration.xml echo "# Test that the test did not break the config" runVTS ) Bug: 64881365 Change-Id: I9db5e6f727d19fd654a3cc543a2aaab196682001 Signed-off-by: Kevin Rocard --- .../functional/ValidateAudioConfiguration.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/audio/2.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/2.0/vts/functional/ValidateAudioConfiguration.cpp index 01324c87d3..5fc1b3d3e4 100644 --- a/audio/2.0/vts/functional/ValidateAudioConfiguration.cpp +++ b/audio/2.0/vts/functional/ValidateAudioConfiguration.cpp @@ -14,9 +14,24 @@ * limitations under the License. */ +#include +#include + #include "utility/ValidateXml.h" TEST(CheckConfig, audioPolicyConfigurationValidation) { - ASSERT_VALID_XML("/vendor/etc/audio_policy_configuration.xml", - "/data/local/tmp/audio_policy_configuration.xsd"); + const char* configName = "audio_policy_configuration.xml"; + const char* possibleConfigLocations[] = {"/odm/etc", "/vendor/etc", "/system/etc"}; + const char* configSchemaPath = "/data/local/tmp/audio_policy_configuration.xsd"; + + bool found = false; + for (std::string folder : possibleConfigLocations) { + const auto configPath = folder + '/' + configName; + if (access(configPath.c_str(), R_OK) == 0) { + ASSERT_FALSE(found) << "Multiple " << configName << " found in " + << ::testing::PrintToString(possibleConfigLocations); + found = true; + ASSERT_VALID_XML(configPath.c_str(), configSchemaPath); + } + } }