OSDN Git Service

Audio VTS: Look for Audio policy config in all supported folders
authorKevin Rocard <krocard@google.com>
Tue, 22 Aug 2017 01:32:49 +0000 (18:32 -0700)
committerKevin Rocard <krocard@google.com>
Wed, 23 Aug 2017 01:24:44 +0000 (01:24 +0000)
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>
audio/2.0/vts/functional/ValidateAudioConfiguration.cpp

index 01324c8..5fc1b3d 100644 (file)
  * limitations under the License.
  */
 
+#include <string>
+#include <unistd.h>
+
 #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);
+        }
+    }
 }