Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a447b809 authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge "audio: Add VTS execution tracer" into main am: 4a0e25ba

parents 0ee843a6 4a0e25ba
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -40,7 +40,10 @@ cc_defaults {
        "general-tests",
        "vts",
    ],
    srcs: [":effectCommonFile"],
    srcs: [
        ":effectCommonFile",
        "TestUtils.cpp",
    ],
}

cc_test {
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 "TestUtils.h"

#define LOG_TAG "VtsHalAudio_TestUtils"

#include <android-base/logging.h>

namespace android::hardware::audio::common::testing {

namespace detail {
void TestExecutionTracer::OnTestStart(const ::testing::TestInfo& test_info) {
    TraceTestState("Started", test_info);
}

void TestExecutionTracer::OnTestEnd(const ::testing::TestInfo& test_info) {
    TraceTestState("Completed", test_info);
}

void TestExecutionTracer::OnTestPartResult(const ::testing::TestPartResult& result) {
    LOG(INFO) << result;
}

void TestExecutionTracer::TraceTestState(const std::string& state,
                                         const ::testing::TestInfo& test_info) {
    LOG(INFO) << state << " " << test_info.test_suite_name() << "::" << test_info.name();
}
}
}
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -22,11 +22,21 @@

#include <android/binder_auto_utils.h>
#include <gtest/gtest.h>
#include <system/audio_aidl_utils.h>

namespace android::hardware::audio::common::testing {

namespace detail {

class TestExecutionTracer : public ::testing::EmptyTestEventListener {
  public:
    void OnTestStart(const ::testing::TestInfo& test_info) override;
    void OnTestEnd(const ::testing::TestInfo& test_info) override;
    void OnTestPartResult(const ::testing::TestPartResult& result) override;
  private:
    static void TraceTestState(const std::string& state, const ::testing::TestInfo& test_info);
};

inline ::testing::AssertionResult assertIsOk(const char* expr, const ::ndk::ScopedAStatus& status) {
    if (status.isOk()) {
        return ::testing::AssertionSuccess();
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
using aidl::android::hardware::audio::effect::Range;
using android::hardware::audio::common::testing::detail::TestExecutionTracer;

enum ParamName { PARAM_INSTANCE_NAME, PARAM_ECHO_DELAY, PARAM_MOBILE_MODE };
using AECParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
@@ -178,6 +179,7 @@ GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AECParamTest);

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    ABinderProcess_setThreadPoolMaxThreadCount(1);
    ABinderProcess_startThreadPool();
    return RUN_ALL_TESTS();
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ using aidl::android::hardware::audio::effect::getEffectTypeUuidAutomaticGainCont
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
using android::hardware::audio::common::testing::detail::TestExecutionTracer;

enum ParamName {
    PARAM_INSTANCE_NAME,
@@ -189,6 +190,7 @@ GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AGC1ParamTest);

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    ABinderProcess_setThreadPoolMaxThreadCount(1);
    ABinderProcess_startThreadPool();
    return RUN_ALL_TESTS();
Loading