Files
hardware_interfaces/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp

33 lines
1.2 KiB
C++
Raw Normal View History

/*
* 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 <unistd.h>
Audio VTS: improve audio policy validation error messages If multiple config are found, each will be validated before failing the test. Also add a missing new line before dumping libxml2 errors. Test: run the following script to check for regressions and test that invalid config make the test fail. runTest() {( set -xu local readonly MODULE=$1 local readonly TEST=$2 local readonly XML=$3 runVTS() { vts-tradefed run commandAndExit vts \ --skip-all-system-status-check --primary-abi-only \ --skip-preconditions --module $MODULE -t $TEST | awk '/FAILED: 0/{e=1} {print} END {exit !e}'; } local FAIL=0 # used instead of return if clean up is needed echo "# Test valid config" runVTS || return 1 echo "# Test multiple invalid match" adb shell touch /system/etc/$XML runVTS && FAIL=2 adb shell rm /system/etc/$XML echo "# Test multiple valid match (not supported if xinclude)" if !adb shell grep -q xi:include /vendor/etc/$XML; then adb shell cp /{vendor,system}/etc/$XML runVTS || FAIL=3 adb shell rm /system/etc/$XML fi echo "# Test invalid config" adb shell sed -i "'2i<fuu/>'" /vendor/etc/$XML runVTS && FAIL=4 adb shell sed -i 2d /vendor/etc/$XML echo "#Test no config" adb shell mv /vendor/etc/$XML{,.hide} runVTS && FAIL=5 adb shell mv /vendor/etc/$XML{.hide,} echo "# Test that the test did not break the config" runVTS || FAIL=6 return $FAIL )} runTest VtsHalAudioV2_0Target CheckConfig.audioPolicyConfigurationValidation audio_policy_configuration.xml && runTest VtsHalAudioEffectV2_0Target CheckConfig.audioEffectsConfigurationValidation audio_effects.xml && echo TEST PASSED Bug: 64881365 Change-Id: If0443f85e0d687eed04819337519e4d9f09f5ca9 Signed-off-by: Kevin Rocard <krocard@google.com>
2017-08-21 18:32:49 -07:00
#include <iterator>
#include <media/EffectsConfig.h>
#include "utility/ValidateXml.h"
TEST(CheckConfig, audioEffectsConfigurationValidation) {
RecordProperty("description",
"Verify that the effects configuration file is valid according to the schema");
Audio VTS: improve audio policy validation error messages If multiple config are found, each will be validated before failing the test. Also add a missing new line before dumping libxml2 errors. Test: run the following script to check for regressions and test that invalid config make the test fail. runTest() {( set -xu local readonly MODULE=$1 local readonly TEST=$2 local readonly XML=$3 runVTS() { vts-tradefed run commandAndExit vts \ --skip-all-system-status-check --primary-abi-only \ --skip-preconditions --module $MODULE -t $TEST | awk '/FAILED: 0/{e=1} {print} END {exit !e}'; } local FAIL=0 # used instead of return if clean up is needed echo "# Test valid config" runVTS || return 1 echo "# Test multiple invalid match" adb shell touch /system/etc/$XML runVTS && FAIL=2 adb shell rm /system/etc/$XML echo "# Test multiple valid match (not supported if xinclude)" if !adb shell grep -q xi:include /vendor/etc/$XML; then adb shell cp /{vendor,system}/etc/$XML runVTS || FAIL=3 adb shell rm /system/etc/$XML fi echo "# Test invalid config" adb shell sed -i "'2i<fuu/>'" /vendor/etc/$XML runVTS && FAIL=4 adb shell sed -i 2d /vendor/etc/$XML echo "#Test no config" adb shell mv /vendor/etc/$XML{,.hide} runVTS && FAIL=5 adb shell mv /vendor/etc/$XML{.hide,} echo "# Test that the test did not break the config" runVTS || FAIL=6 return $FAIL )} runTest VtsHalAudioV2_0Target CheckConfig.audioPolicyConfigurationValidation audio_policy_configuration.xml && runTest VtsHalAudioEffectV2_0Target CheckConfig.audioEffectsConfigurationValidation audio_effects.xml && echo TEST PASSED Bug: 64881365 Change-Id: If0443f85e0d687eed04819337519e4d9f09f5ca9 Signed-off-by: Kevin Rocard <krocard@google.com>
2017-08-21 18:32:49 -07:00
using namespace android::effectsConfig;
std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS));
VTS: Do not require XML for Audio effect V2 In O, the Audio effect V2 HAL allows not to have an audio effect XML configuration but to use a .conf format. In P, before this patch, the Audio effect V2 HAL _requires_ to have an audio effect XML configuration and forbids the use of a .conf format. This is discouraged by Treble as it means that an unchanged HAL V2 implementation that was compatible with O VTS will not be with P VTS. As a result, revert to the Oreo behavior for Audio Effect V2 VTS. Note that the audio effect V4 VTS is not changed by this patch and still requires an audio effect XML configuration. Aka device _updating_ to P will not have to upgrade to XML but new devices lunching on P are still required to have an audio effect XML configuration. This commit only changes VTS code. Test: cd hardware/interfaces/audio/effect/ mmm 2.0/vts/functional 4.0/vts/functional && adb sync data adb push *.0/xml/audio_effects_conf_V*.xsd /data/local/tmp/ adb shell cd /data/nativetest64 OPS=--gtest_filter=CheckConfig.audioEffectsConfigurationValidation VtsHalAudioEffectV2_0TargetTest/VtsHalAudioEffectV2_0TargetTest $OPS VtsHalAudioEffectV4_0TargetTest/VtsHalAudioEffectV4_0TargetTest $OPS rm /{odm,vendor,system}/etc/audio_effects.xml || true VtsHalAudioEffectV2_0TargetTest/VtsHalAudioEffectV2_0TargetTest $OPS ! VtsHalAudioEffectV4_0TargetTest/VtsHalAudioEffectV4_0TargetTest $OPS Bug: 111421676 Change-Id: Ifb15d65ae4aa65759c8ebaa91cbc8c02234030dc Merged-In: Ifb15d65ae4aa65759c8ebaa91cbc8c02234030dc Signed-off-by: Kevin Rocard <krocard@google.com> (cherry picked from commit b41b575475f3c93fe30216b9cdb2db441b92854b)
2018-07-19 13:31:47 -07:00
EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
"/data/local/tmp/audio_effects_conf_V2_0.xsd");
}