mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
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 <krocard@google.com>
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <string>
|
|
#include <unistd.h>
|
|
|
|
#include "utility/ValidateXml.h"
|
|
|
|
TEST(CheckConfig, audioPolicyConfigurationValidation) {
|
|
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);
|
|
}
|
|
}
|
|
}
|