Merge "Convert VtsHalAudioV*_0TargetTest to parameterized gtest" am: 1b03269ec7
am: e904793d4b
Change-Id: Ib7d0098575ca6f5fd6b963e5f016956b7fb6d2ba
This commit is contained in:
commit
daa2999781
12 changed files with 257 additions and 315 deletions
20
audio/2.0/config/Android.bp
Normal file
20
audio/2.0/config/Android.bp
Normal file
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// Copyright (C) 2020 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.
|
||||
//
|
||||
|
||||
filegroup {
|
||||
name: "audio_policy_configuration_V2_0",
|
||||
srcs: ["audio_policy_configuration.xsd"],
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace common {
|
||||
namespace test {
|
||||
namespace utility {
|
||||
|
||||
/** Register callback for static object destruction
|
||||
* Avoid destroying static objects after main return.
|
||||
* Post main return destruction leads to incorrect gtest timing measurements as
|
||||
* well as harder debuging if anything goes wrong during destruction. */
|
||||
class EnvironmentTearDown {
|
||||
public:
|
||||
using TearDownFunc = std::function<void()>;
|
||||
void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_front(std::move(tearDown)); }
|
||||
|
||||
protected:
|
||||
void executeAllTearDowns() {
|
||||
// Call the tear downs in reverse order of insertion
|
||||
for (auto& tearDown : tearDowns) {
|
||||
tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<TearDownFunc> tearDowns;
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
} // namespace test
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
|
|
@ -18,8 +18,11 @@ cc_defaults {
|
|||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
shared_libs: [
|
||||
static_libs: [
|
||||
"libaudiofoundation",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
|
@ -52,7 +55,7 @@ cc_library_shared {
|
|||
"-DMAJOR_VERSION=2",
|
||||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
|
@ -68,7 +71,7 @@ cc_library_shared {
|
|||
"-DMAJOR_VERSION=4",
|
||||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
|
@ -83,7 +86,7 @@ cc_library_shared {
|
|||
"-DMAJOR_VERSION=5",
|
||||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
|
@ -98,5 +101,5 @@ cc_library_shared {
|
|||
"-DMAJOR_VERSION=6",
|
||||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "utility/EnvironmentTearDown.h"
|
||||
|
||||
class Environment : public ::android::hardware::audio::common::test::utility::EnvironmentTearDown,
|
||||
public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
private:
|
||||
void HidlTearDown() override {
|
||||
executeAllTearDowns();
|
||||
VtsHalHidlTargetTestEnvBase::HidlTearDown();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H
|
|
@ -17,54 +17,6 @@
|
|||
// pull in all the <= 5.0 tests
|
||||
#include "5.0/AudioPrimaryHidlHalTest.cpp"
|
||||
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() {
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto factories =
|
||||
::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
|
||||
for (const auto& factoryName : factories) {
|
||||
result.emplace_back(factoryName,
|
||||
DeviceManager::getInstance().getPrimary(factoryName) != nullptr
|
||||
? DeviceManager::kPrimaryDevice
|
||||
: "");
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() {
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto primary = std::find_if(
|
||||
getDeviceParameters().begin(), getDeviceParameters().end(), [](const auto& elem) {
|
||||
return std::get<PARAM_DEVICE_NAME>(elem) == DeviceManager::kPrimaryDevice;
|
||||
});
|
||||
if (primary != getDeviceParameters().end()) result.push_back(*primary);
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceParameter>& getDeviceParameters() {
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto factories =
|
||||
::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
|
||||
const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames();
|
||||
result.reserve(devices.size());
|
||||
for (const auto& factoryName : factories) {
|
||||
for (const auto& deviceName : devices) {
|
||||
if (DeviceManager::getInstance().get(factoryName, deviceName) != nullptr) {
|
||||
result.emplace_back(factoryName, deviceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() {
|
||||
static std::vector<DeviceConfigParameter> parameters = [] {
|
||||
std::vector<DeviceConfigParameter> result;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_AUDIO_CORE_6_0_ENVIRONMENT_TEARDOWN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_CORE_6_0_ENVIRONMENT_TEARDOWN_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "utility/EnvironmentTearDown.h"
|
||||
|
||||
class Environment : public ::android::hardware::audio::common::test::utility::EnvironmentTearDown,
|
||||
public ::testing::Environment {
|
||||
public:
|
||||
void init(int* /*argc*/, char** /*argv*/) {} // emulate VtsHalHidlTargetTestEnvBase
|
||||
private:
|
||||
void TearDown() override { executeAllTearDowns(); }
|
||||
};
|
||||
|
||||
// FIXME: Will be removed while making getDeviceParameters to use the config
|
||||
static constexpr const char* kDefaultServiceName = "default";
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_CORE_6_0_ENVIRONMENT_TEARDOWN_H
|
|
@ -31,7 +31,10 @@ cc_defaults {
|
|||
header_libs: [
|
||||
"android.hardware.audio.common.util@all-versions",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts-core",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
|
@ -49,6 +52,12 @@ cc_test {
|
|||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
],
|
||||
data: [
|
||||
":audio_policy_configuration_V2_0",
|
||||
],
|
||||
// Use test_config for vts-core suite.
|
||||
// TODO(b/146104851): Add auto-gen rules and remove it.
|
||||
test_config: "VtsHalAudioV2_0TargetTest.xml",
|
||||
}
|
||||
|
||||
cc_test {
|
||||
|
@ -66,6 +75,12 @@ cc_test {
|
|||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
],
|
||||
data: [
|
||||
":audio_policy_configuration_V4_0",
|
||||
],
|
||||
// Use test_config for vts-core suite.
|
||||
// TODO(b/146104851): Add auto-gen rules and remove it.
|
||||
test_config: "VtsHalAudioV4_0TargetTest.xml",
|
||||
}
|
||||
|
||||
cc_test {
|
||||
|
@ -83,6 +98,12 @@ cc_test {
|
|||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
],
|
||||
data: [
|
||||
":audio_policy_configuration_V5_0",
|
||||
],
|
||||
// Use test_config for vts-core suite.
|
||||
// TODO(b/146104851): Add auto-gen rules and remove it.
|
||||
test_config: "VtsHalAudioV5_0TargetTest.xml",
|
||||
}
|
||||
|
||||
cc_test {
|
||||
|
@ -100,14 +121,10 @@ cc_test {
|
|||
"-DMINOR_VERSION=0",
|
||||
"-include common/all-versions/VersionMacro.h",
|
||||
],
|
||||
// Use test_config for vts-core suite.
|
||||
// TODO(b/146104851): Add auto-gen rules and remove it.
|
||||
test_config: "VtsHalAudioV6_0TargetTest.xml",
|
||||
data: [
|
||||
":audio_policy_configuration_V6_0",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts-core",
|
||||
],
|
||||
// Use test_config for vts-core suite.
|
||||
// TODO(b/146104851): Add auto-gen rules and remove it.
|
||||
test_config: "VtsHalAudioV6_0TargetTest.xml",
|
||||
}
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#endif
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h)
|
||||
|
@ -49,10 +45,8 @@
|
|||
#include <Serializer.h>
|
||||
#include <fmq/EventFlag.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#if MAJOR_VERSION >= 6
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#endif
|
||||
|
||||
#include <common/all-versions/VersionUtils.h>
|
||||
|
||||
|
@ -61,12 +55,6 @@
|
|||
#include "utility/ReturnIn.h"
|
||||
#include "utility/ValidateXml.h"
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
#include "2.0/EnvironmentTearDown.h"
|
||||
#elif MAJOR_VERSION >= 6
|
||||
#include "6.0/EnvironmentTearDown.h"
|
||||
#endif
|
||||
|
||||
/** Provide version specific functions that are used in the generic tests */
|
||||
#if MAJOR_VERSION == 2
|
||||
#include "2.0/AudioPrimaryHidlHalUtils.h"
|
||||
|
@ -114,30 +102,10 @@ static auto okOrInvalidStateOrNotSupported = {Result::OK, Result::INVALID_STATE,
|
|||
static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
|
||||
static auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// Environment /////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AudioHidlTestEnvironment : public ::Environment {
|
||||
public:
|
||||
#if MAJOR_VERSION <= 5
|
||||
void registerTestServices() override { registerTestService<IDevicesFactory>(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// Instance to register global tearDown
|
||||
static AudioHidlTestEnvironment* environment;
|
||||
|
||||
#define AUDIO_PRIMARY_HIDL_HAL_TEST
|
||||
#include "DeviceManager.h"
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
using HidlTestBase = ::testing::VtsHalHidlTargetTestBase;
|
||||
#elif MAJOR_VERSION >= 6
|
||||
using HidlTestBase = ::testing::Test;
|
||||
#endif
|
||||
|
||||
class HidlTest : public HidlTestBase {
|
||||
class HidlTest : public ::testing::Test {
|
||||
public:
|
||||
virtual ~HidlTest() = default;
|
||||
// public access to avoid annoyances when using this method in template classes
|
||||
|
@ -174,15 +142,6 @@ static constexpr char kConfigFileName[] = "audio_policy_configuration.xml";
|
|||
#define QUOTE(x) #x
|
||||
#define STRINGIFY(x) QUOTE(x)
|
||||
|
||||
TEST(CheckConfig, audioPolicyConfigurationValidation) {
|
||||
RecordProperty("description",
|
||||
"Verify that the audio policy configuration file "
|
||||
"is valid according to the schema");
|
||||
|
||||
const char* xsd = "/data/local/tmp/audio_policy_configuration_" STRINGIFY(CPP_VERSION) ".xsd";
|
||||
EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(kConfigFileName, kConfigLocations, xsd);
|
||||
}
|
||||
|
||||
struct PolicyConfigData {
|
||||
android::HwModuleCollection hwModules;
|
||||
android::DeviceVector availableOutputDevices;
|
||||
|
@ -254,32 +213,11 @@ class PolicyConfig : private PolicyConfigData, public AudioPolicyConfig {
|
|||
const PolicyConfig& getCachedPolicyConfig() {
|
||||
static std::unique_ptr<PolicyConfig> policyConfig = [] {
|
||||
auto config = std::make_unique<PolicyConfig>();
|
||||
environment->registerTearDown([] { policyConfig.reset(); });
|
||||
return config;
|
||||
}();
|
||||
return *policyConfig;
|
||||
}
|
||||
|
||||
class AudioPolicyConfigTest : public HidlTestBase {
|
||||
public:
|
||||
void SetUp() override {
|
||||
ASSERT_NO_FATAL_FAILURE(HidlTestBase::SetUp()); // setup base
|
||||
auto& policyConfig = getCachedPolicyConfig();
|
||||
ASSERT_EQ(0, policyConfig.getStatus()) << policyConfig.getError();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(AudioPolicyConfigTest, LoadAudioPolicyXMLConfiguration) {
|
||||
doc::test("Test parsing audio_policy_configuration.xml (called in SetUp)");
|
||||
}
|
||||
|
||||
TEST_F(AudioPolicyConfigTest, HasPrimaryModule) {
|
||||
auto& policyConfig = getCachedPolicyConfig();
|
||||
ASSERT_TRUE(policyConfig.getPrimaryModule() != nullptr)
|
||||
<< "Could not find primary module in configuration file: "
|
||||
<< policyConfig.getFilePath();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Test parameter types and definitions ////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -290,53 +228,59 @@ using DeviceParameter = std::tuple<std::string, std::string>;
|
|||
static inline std::string DeviceParameterToString(
|
||||
const ::testing::TestParamInfo<DeviceParameter>& info) {
|
||||
const auto& deviceName = std::get<PARAM_DEVICE_NAME>(info.param);
|
||||
#if MAJOR_VERSION <= 5
|
||||
return !deviceName.empty() ? deviceName : std::to_string(info.index);
|
||||
#elif MAJOR_VERSION >= 6
|
||||
const auto factoryName =
|
||||
::android::hardware::PrintInstanceNameToString(::testing::TestParamInfo<std::string>{
|
||||
std::get<PARAM_FACTORY_NAME>(info.param), info.index});
|
||||
return !deviceName.empty() ? factoryName + "_" + deviceName : factoryName;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
// For V2..5 the factory is looked up using the instance name passed
|
||||
// in the environment, only one factory is returned. This is because the VTS
|
||||
// framework will call the test for each instance. Only the primary device of
|
||||
// the default service factory can be tested.
|
||||
|
||||
// Return a pair of <"default", "primary"> or <[non-default name], "">
|
||||
// This is used to parametrize device factory tests.
|
||||
// The device name is used to indicate whether IPrimaryDevice is required.
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() {
|
||||
static std::vector<DeviceParameter> parameters = {
|
||||
{environment->getServiceName<IDevicesFactory>(),
|
||||
environment->getServiceName<IDevicesFactory>() == kDefaultServiceName
|
||||
? DeviceManager::kPrimaryDevice
|
||||
: ""}};
|
||||
return parameters;
|
||||
}
|
||||
// Return a pair of <"default", "primary"> or nothing.
|
||||
// This is used to parametrize primary device tests.
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() {
|
||||
static std::vector<DeviceParameter> parameters =
|
||||
!std::get<PARAM_DEVICE_NAME>(*getDeviceParametersForFactoryTests().begin()).empty()
|
||||
? getDeviceParametersForFactoryTests()
|
||||
: std::vector<DeviceParameter>{};
|
||||
return parameters;
|
||||
}
|
||||
// In V2..5 device tests must only test the primary device.
|
||||
// No device tests are executed for non-primary devices.
|
||||
const std::vector<DeviceParameter>& getDeviceParameters() {
|
||||
return getDeviceParametersForPrimaryDeviceTests();
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto factories =
|
||||
::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
|
||||
const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames();
|
||||
result.reserve(devices.size());
|
||||
for (const auto& factoryName : factories) {
|
||||
for (const auto& deviceName : devices) {
|
||||
if (DeviceManager::getInstance().get(factoryName, deviceName) != nullptr) {
|
||||
result.emplace_back(factoryName, deviceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() {
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto factories =
|
||||
::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
|
||||
for (const auto& factoryName : factories) {
|
||||
result.emplace_back(factoryName,
|
||||
DeviceManager::getInstance().getPrimary(factoryName) != nullptr
|
||||
? DeviceManager::kPrimaryDevice
|
||||
: "");
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() {
|
||||
static std::vector<DeviceParameter> parameters = [] {
|
||||
std::vector<DeviceParameter> result;
|
||||
const auto primary = std::find_if(
|
||||
getDeviceParameters().begin(), getDeviceParameters().end(), [](const auto& elem) {
|
||||
return std::get<PARAM_DEVICE_NAME>(elem) == DeviceManager::kPrimaryDevice;
|
||||
});
|
||||
if (primary != getDeviceParameters().end()) result.push_back(*primary);
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
#elif MAJOR_VERSION >= 6
|
||||
// For V6 and above these functions are implemented in 6.0/AudioPrimaryHidlHalTest.cpp
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests();
|
||||
const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests();
|
||||
const std::vector<DeviceParameter>& getDeviceParameters();
|
||||
#endif
|
||||
|
||||
class AudioHidlTestWithDeviceParameter : public HidlTest,
|
||||
public ::testing::WithParamInterface<DeviceParameter> {
|
||||
|
@ -349,6 +293,44 @@ class AudioHidlTestWithDeviceParameter : public HidlTest,
|
|||
}
|
||||
};
|
||||
|
||||
TEST(CheckConfig, audioPolicyConfigurationValidation) {
|
||||
auto deviceParameters = getDeviceParametersForFactoryTests();
|
||||
if (deviceParameters.size() == 0) {
|
||||
GTEST_SKIP() << "Skipping audioPolicyConfigurationValidation because no device parameter "
|
||||
"is found.";
|
||||
}
|
||||
RecordProperty("description",
|
||||
"Verify that the audio policy configuration file "
|
||||
"is valid according to the schema");
|
||||
|
||||
const char* xsd = "/data/local/tmp/audio_policy_configuration_" STRINGIFY(CPP_VERSION) ".xsd";
|
||||
EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(kConfigFileName, kConfigLocations, xsd);
|
||||
}
|
||||
|
||||
class AudioPolicyConfigTest : public AudioHidlTestWithDeviceParameter {
|
||||
public:
|
||||
void SetUp() override {
|
||||
ASSERT_NO_FATAL_FAILURE(AudioHidlTestWithDeviceParameter::SetUp()); // setup base
|
||||
auto& policyConfig = getCachedPolicyConfig();
|
||||
ASSERT_EQ(0, policyConfig.getStatus()) << policyConfig.getError();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(AudioPolicyConfigTest, LoadAudioPolicyXMLConfiguration) {
|
||||
doc::test("Test parsing audio_policy_configuration.xml (called in SetUp)");
|
||||
}
|
||||
|
||||
TEST_P(AudioPolicyConfigTest, HasPrimaryModule) {
|
||||
auto& policyConfig = getCachedPolicyConfig();
|
||||
ASSERT_TRUE(policyConfig.getPrimaryModule() != nullptr)
|
||||
<< "Could not find primary module in configuration file: "
|
||||
<< policyConfig.getFilePath();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(AudioHidl, AudioPolicyConfigTest,
|
||||
::testing::ValuesIn(getDeviceParametersForFactoryTests()),
|
||||
&DeviceParameterToString);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// getService audio_devices_factory //////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1576,20 +1558,3 @@ TEST_P(BoolAccessorPrimaryHidlTest, setGetHac) {
|
|||
testAccessors<OPTIONAL>("HAC", Initial{false}, {true}, &IPrimaryDevice::setHacEnabled,
|
||||
&IPrimaryDevice::getHacEnabled);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////// Clean caches on global tear down ////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
environment = new AudioHidlTestEnvironment;
|
||||
// For V2..5 it's critical to initialize environment before GTest.
|
||||
// The environment parses the service name from the command line,
|
||||
// then it can be used in GTest parameter generators which are
|
||||
// initialized during the call to InitGoogleTest.
|
||||
environment->init(&argc, argv);
|
||||
::testing::AddGlobalTestEnvironment(environment);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,6 @@ class InterfaceManager {
|
|||
auto existing = instances.find(name);
|
||||
if (existing != instances.end()) return existing->second;
|
||||
auto [inserted, _] = instances.emplace(name, Derived::createInterfaceInstance(name));
|
||||
if (inserted->second) {
|
||||
environment->registerTearDown(
|
||||
[name]() { (void)Derived::getInstance().reset(name, false); });
|
||||
}
|
||||
return inserted->second;
|
||||
}
|
||||
|
||||
|
@ -75,11 +71,7 @@ class DevicesFactoryManager
|
|||
return instance;
|
||||
}
|
||||
static sp<IDevicesFactory> createInterfaceInstance(const std::string& name) {
|
||||
#if MAJOR_VERSION <= 5
|
||||
return ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(name);
|
||||
#elif MAJOR_VERSION >= 6
|
||||
return IDevicesFactory::getService(name);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 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.
|
||||
-->
|
||||
<configuration description="Runs VtsHalAudioV2_0TargetTest.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-native" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
|
||||
<option name="run-command" value="stop"/>
|
||||
<option name="run-command" value="setprop vts.native_server.on 1"/>
|
||||
<option name="teardown-command" value="start"/>
|
||||
<option name="teardown-command" value="setprop vts.native_server.on 0"/>
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push-file" key="VtsHalAudioV2_0TargetTest" value="/data/local/tmp/VtsHalAudioV2_0TargetTest" />
|
||||
<option name="push-file" key="audio_policy_configuration.xsd" value="/data/local/tmp/audio_policy_configuration_V2_0.xsd" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="VtsHalAudioV2_0TargetTest" />
|
||||
</test>
|
||||
</configuration>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 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.
|
||||
-->
|
||||
<configuration description="Runs VtsHalAudioV4_0TargetTest.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-native" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
|
||||
<option name="run-command" value="stop"/>
|
||||
<option name="run-command" value="setprop vts.native_server.on 1"/>
|
||||
<option name="teardown-command" value="start"/>
|
||||
<option name="teardown-command" value="setprop vts.native_server.on 0"/>
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push-file" key="VtsHalAudioV4_0TargetTest" value="/data/local/tmp/VtsHalAudioV4_0TargetTest" />
|
||||
<option name="push-file" key="audio_policy_configuration_V4_0.xsd" value="/data/local/tmp/audio_policy_configuration_V4_0.xsd" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="VtsHalAudioV4_0TargetTest" />
|
||||
</test>
|
||||
</configuration>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 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.
|
||||
-->
|
||||
<configuration description="Runs VtsHalAudioV5_0TargetTest.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-native" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
|
||||
<option name="run-command" value="stop"/>
|
||||
<option name="run-command" value="setprop vts.native_server.on 1"/>
|
||||
<option name="teardown-command" value="start"/>
|
||||
<option name="teardown-command" value="setprop vts.native_server.on 0"/>
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push-file" key="VtsHalAudioV5_0TargetTest" value="/data/local/tmp/VtsHalAudioV5_0TargetTest" />
|
||||
<option name="push-file" key="audio_policy_configuration_V5_0.xsd" value="/data/local/tmp/audio_policy_configuration_V5_0.xsd" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="VtsHalAudioV5_0TargetTest" />
|
||||
</test>
|
||||
</configuration>
|
Loading…
Reference in a new issue