Merge branch 'RM.003' of https://gitee.com/wangchao582/xts_hats_hdi into RM.003

This commit is contained in:
wangchao582 2023-12-20 16:55:49 +08:00
commit 66c3c54d25
4 changed files with 234 additions and 4 deletions

View File

@ -23,12 +23,13 @@ group("hdi_base_common") {
if (hats_rich == false) {
deps = [
"common/adapter:HatsHdfAudioIdlAdapterTest",
"common/adapter_additional:HatsHdfAudioIdlAdapterAdditionalTest",
"common/adapter_additional:HatsHdfAudioIdlAdapterTestAdditional",
"common/capture:HatsHdfAudioIdlCaptureTest",
"common/capture_additional:HatsHdfAudioIdlCaptureAdditionalTest",
"common/capture_additional:HatsHdfAudioIdlCaptureTestAdditional",
"common/manager:HatsHdfAudioIdlManagerTest",
"common/manager_additional:HatsHdfAudioIdlManagerAdditionalTest",
"common/render:HatsHdfAudioIdlRenderTest",
"common/render_additional:HatsHdfAudioIdlRenderAdditionalTest",
"common/render_additional:HatsHdfAudioIdlRenderTestAdditional",
#"benchmarktest:HatsHdfAudioBenchmarkTest"
]
@ -57,7 +58,7 @@ group("hdi_effect_additional") {
testonly = true
}
if (hats_rich == false) {
deps = [ "effect_additional:HatsHdfAudioEffectAdditionalTest" ]
deps = [ "effect_additional:HatsHdfAudioEffectTestAdditional" ]
} else {
}
}

View File

@ -0,0 +1,38 @@
# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
# 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.
import("//build/ohos_var.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hats/audio"
ohos_moduletest_suite("HatsHdfAudioIdlManagerAdditionalTest") {
module_out_path = module_output_path
sources = [ "src/AudioManagerCommonTest.cpp" ]
configs = [ ":audio_idl_manager_additional" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
external_deps = [
"c_utils:utils",
"drivers_interface_audio:audio_idl_headers",
"drivers_interface_audio:libaudio_proxy_2.0",
"hdf_core:libhdf_utils",
"hilog:libhilog",
]
subsystem_name = "xts"
part_name = "hats"
}
config("audio_idl_manager_additional") {
include_dirs = []
}

View File

@ -0,0 +1,18 @@
{
"kits": [
{
"push": [
"HatsHdfAudioIdlManagerAdditionalTest->/data/local/tmp/HatsHdfAudioIdlManagerAdditionalTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "HatsHdfAudioIdlManagerAdditionalTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for HatsHdfAudioIdlManagerAdditionalTest Tests"
}

View File

@ -0,0 +1,173 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* 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 <climits>
#include <gtest/gtest.h>
#include "hdf_dlist.h"
#include "osal_mem.h"
#include "v2_0/iaudio_manager.h"
using namespace std;
using namespace testing::ext;
namespace {
static const uint32_t g_audioAdapterNumMax = 5;
struct IAudioManager *g_manager = nullptr;
class HdfAudioUtManagerTestAdditional : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
void AudioAdapterDescriptorFree(struct AudioAdapterDescriptor *dataBlock, bool freeSelf);
void ReleaseAdapterDescs(struct AudioAdapterDescriptor **descs, uint32_t descsLen);
};
void HdfAudioUtManagerTestAdditional::AudioAdapterDescriptorFree(struct AudioAdapterDescriptor *dataBlock, bool freeSelf)
{
if (dataBlock == nullptr) {
return;
}
if (dataBlock->adapterName != nullptr) {
OsalMemFree(dataBlock->adapterName);
dataBlock->adapterName = nullptr;
}
if (dataBlock->ports != nullptr) {
OsalMemFree(dataBlock->ports);
}
if (freeSelf) {
OsalMemFree(dataBlock);
}
}
void HdfAudioUtManagerTestAdditional::ReleaseAdapterDescs(struct AudioAdapterDescriptor **descs, uint32_t descsLen)
{
if ((descsLen > 0) && (descs != nullptr) && ((*descs) != nullptr)) {
for (uint32_t i = 0; i < descsLen; i++) {
AudioAdapterDescriptorFree(&(*descs)[i], false);
}
OsalMemFree(*descs);
*descs = nullptr;
}
}
void HdfAudioUtManagerTestAdditional::SetUp()
{
}
void HdfAudioUtManagerTestAdditional::TearDown()
{
}
void HdfAudioUtManagerTestAdditional::SetUpTestCase()
{
g_manager = IAudioManagerGet(false);
ASSERT_NE(g_manager, nullptr);
}
void HdfAudioUtManagerTestAdditional::TearDownTestCase()
{
IAudioManagerRelease(g_manager, false);
}
/**
* @tc.number : SUB_Driver_Audio_GetAllAdapters_0800
* @tc.name : testGetAllAdapters001
* @tc.desc : Reliability of function(GetAllAdapters)
*/
HWTEST_F(HdfAudioUtManagerTestAdditional, testGetAllAdapters001, Function | MediumTest | Level1)
{
uint32_t size = g_audioAdapterNumMax;
struct AudioAdapterDescriptor *descs = (struct AudioAdapterDescriptor *)OsalMemCalloc(
sizeof(struct AudioAdapterDescriptor) * (g_audioAdapterNumMax));
int i = 0;
int32_t ret = 0;
for(i = 0; i < 1000;i++){
ret |= g_manager->GetAllAdapters(g_manager, descs, &size);
}
EXPECT_EQ(0, ret);
ReleaseAdapterDescs(&descs, g_audioAdapterNumMax);
}
/**
* @tc.number : SUB_Driver_Audio_LoadAdapter_0700
* @tc.name : testLoadAdapter001
* @tc.desc : Reliability of function(LoadAdapter)
*/
HWTEST_F(HdfAudioUtManagerTestAdditional, testLoadAdapter001, Function | MediumTest | Level1)
{
uint32_t size = g_audioAdapterNumMax;
struct IAudioAdapter *adapter = nullptr;
struct AudioAdapterDescriptor *descs = (struct AudioAdapterDescriptor *)OsalMemCalloc(
sizeof(struct AudioAdapterDescriptor) * (g_audioAdapterNumMax));
int i = 0;
int32_t ret = 0;
ASSERT_EQ(HDF_SUCCESS, g_manager->GetAllAdapters(g_manager, descs, &size));
if (size > g_audioAdapterNumMax) {
ReleaseAdapterDescs(&descs, g_audioAdapterNumMax);
ASSERT_GE(g_audioAdapterNumMax, size);
}
for(i = 0; i < 1000;i++){
ret |= g_manager->LoadAdapter(g_manager, descs, &adapter);
g_manager->UnloadAdapter(g_manager, descs[0].adapterName);
}
EXPECT_EQ(HDF_SUCCESS,ret);
ReleaseAdapterDescs(&descs, g_audioAdapterNumMax);
}
/**
* @tc.number : SUB_Driver_Audio_UnloadAdapter_0300
* @tc.name : testUnloadAdapter001
* @tc.desc : Reliability of function(UnloadAdapter)
*/
HWTEST_F(HdfAudioUtManagerTestAdditional, testUnloadAdapter001, Function | MediumTest | Level1)
{
uint32_t size = g_audioAdapterNumMax;
struct IAudioAdapter *adapter = nullptr;
struct AudioAdapterDescriptor *descs = (struct AudioAdapterDescriptor *)OsalMemCalloc(
sizeof(struct AudioAdapterDescriptor) * (g_audioAdapterNumMax));
int i = 0;
int32_t ret = 0;
ASSERT_EQ(HDF_SUCCESS, g_manager->GetAllAdapters(g_manager, descs, &size));
if (size > g_audioAdapterNumMax) {
ReleaseAdapterDescs(&descs, g_audioAdapterNumMax);
ASSERT_GE(g_audioAdapterNumMax, size);
}
for(i = 0; i < 1000;i++){
g_manager->LoadAdapter(g_manager, descs, &adapter);
ret |= g_manager->UnloadAdapter(g_manager, descs[0].adapterName);
}
EXPECT_EQ(HDF_SUCCESS,ret);
ReleaseAdapterDescs(&descs, g_audioAdapterNumMax);
}
/**
* @tc.number : SUB_Driver_Audio_ReleaseAudioManagerObject_0200
* @tc.name : testReleaseAudioManagerObject001
* @tc.desc : Reliability of function(ReleaseAudioManagerObject)
*/
HWTEST_F(HdfAudioUtManagerTestAdditional, testReleaseAudioManagerObject001, Function | MediumTest | Level2)
{
int i = 0;
int32_t ret = 0;
for(i = 0; i < 1000;i++){
ret |= g_manager->ReleaseAudioManagerObject(nullptr);
}
EXPECT_EQ(HDF_ERR_INVALID_OBJECT,ret);
}
}