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

Commit f84a5583 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

libaudioclient: Align test execution tracing

Extract TestExecutionTracer helper and use it in all unit
tests.

Bug: 318423731
Test: m audiorecord_tests audiotrack_tests audioeffect_tests \
        audioeffect_analysis audiorouting_tests \
        audioclient_serialization_tests trackplayerbase_tests \
        audiosystem_tests
Change-Id: Ib588e560f5993e86689ac8fe65e129a967ecf874
parent 7295f0b3
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ cc_defaults {
        "libaudioutils",
    ],
    data: ["bbb*.raw"],
    srcs: [
        "audio_test_utils.cpp",
        "test_execution_tracer.cpp",
    ],
    test_config_template: "audio_test_template.xml",
}

@@ -141,7 +145,6 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audiorecord_tests.cpp",
        "audio_test_utils.cpp",
    ],
}

@@ -150,7 +153,6 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audiotrack_tests.cpp",
        "audio_test_utils.cpp",
    ],
}

@@ -159,7 +161,6 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audioeffect_tests.cpp",
        "audio_test_utils.cpp",
    ],
}

@@ -172,7 +173,6 @@ cc_test {
    ],
    srcs: [
        "audioeffect_analyser.cpp",
        "audio_test_utils.cpp",
    ],
    static_libs: [
        "libpffft",
@@ -184,7 +184,6 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audiorouting_tests.cpp",
        "audio_test_utils.cpp",
    ],
}

@@ -193,14 +192,15 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audioclient_serialization_tests.cpp",
        "audio_test_utils.cpp",
    ],
}

cc_test {
    name: "trackplayerbase_tests",
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: ["trackplayerbase_tests.cpp"],
    srcs: [
        "trackplayerbase_tests.cpp",
    ],
}

cc_test {
@@ -208,6 +208,5 @@ cc_test {
    defaults: ["libaudioclient_gtests_defaults"],
    srcs: [
        "audiosystem_tests.cpp",
        "audio_test_utils.cpp",
    ],
}
+15 −4
Original line number Diff line number Diff line
@@ -15,18 +15,23 @@
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "AudioClientSerializationUnitTests"
#define LOG_TAG "AudioClientSerializationTests"

#include <cstdint>
#include <cstdlib>
#include <ctime>

#include <gtest/gtest.h>
#include <vector>

#include <android_audio_policy_configuration_V7_0-enums.h>
#include <gtest/gtest.h>
#include <media/AudioPolicy.h>
#include <media/AudioProductStrategy.h>
#include <media/AudioVolumeGroup.h>
#include <media/VolumeGroupAttributes.h>
#include <system/audio.h>
#include <xsdc/XsdcSupport.h>

#include "audio_test_utils.h"
#include "test_execution_tracer.h"

using namespace android;
namespace xsd {
@@ -310,3 +315,9 @@ TEST_P(AudioAttributesParameterizedTest, AudioAttributesBinderization) {
// audioStream
INSTANTIATE_TEST_SUITE_P(SerializationParameterizedTests, AudioAttributesParameterizedTest,
                         ::testing::Combine(testing::ValuesIn(kStreamtypes)));

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    return RUN_ALL_TESTS();
}
+15 −5
Original line number Diff line number Diff line
@@ -14,23 +14,26 @@
 * limitations under the License.
 */

#include <fstream>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

// #define LOG_NDEBUG 0
#define LOG_TAG "AudioEffectAnalyser"

#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <binder/ProcessState.h>
#include <gtest/gtest.h>
#include <media/AudioEffect.h>
#include <system/audio_effects/effect_bassboost.h>
#include <system/audio_effects/effect_equalizer.h>
#include <fstream>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

#include "audio_test_utils.h"
#include "pffft.hpp"
#include "test_execution_tracer.h"

#define CHECK_OK(expr, msg) \
    mStatus = (expr);       \
@@ -417,3 +420,10 @@ TEST(AudioEffectTest, CheckBassBoostEffect) {
        prevGain = diffB;
    }
}

int main(int argc, char** argv) {
    android::ProcessState::self()->startThreadPool();
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    return RUN_ALL_TESTS();
}
+10 −1
Original line number Diff line number Diff line
@@ -15,8 +15,9 @@
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "AudioEffectUnitTests"
#define LOG_TAG "AudioEffectTests"

#include <binder/ProcessState.h>
#include <gtest/gtest.h>
#include <media/AudioEffect.h>
#include <system/audio_effects/effect_hapticgenerator.h>
@@ -24,6 +25,7 @@
#include <system/audio_effects/effect_visualizer.h>

#include "audio_test_utils.h"
#include "test_execution_tracer.h"

using namespace android;

@@ -563,3 +565,10 @@ TEST(AudioEffectTest, TestHapticEffect) {
    EXPECT_TRUE(cb->receivedFramesProcessed)
            << "AudioEffect frames processed callback not received";
}

int main(int argc, char** argv) {
    android::ProcessState::self()->startThreadPool();
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    return RUN_ALL_TESTS();
}
+1 −20
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <gtest/gtest.h>

#include "audio_test_utils.h"
#include "test_execution_tracer.h"

using namespace android;

@@ -261,26 +262,6 @@ INSTANTIATE_TEST_SUITE_P(AudioRecordMiscInput, AudioRecordCreateTest,
                                                              AUDIO_SOURCE_UNPROCESSED)),
                         GetRecordTestName);

namespace {

class TestExecutionTracer : public ::testing::EmptyTestEventListener {
  public:
    void OnTestStart(const ::testing::TestInfo& test_info) override {
        TraceTestState("Started", test_info);
    }
    void OnTestEnd(const ::testing::TestInfo& test_info) override {
        TraceTestState("Finished", test_info);
    }
    void OnTestPartResult(const ::testing::TestPartResult& result) override { LOG(INFO) << result; }

  private:
    static void TraceTestState(const std::string& state, const ::testing::TestInfo& test_info) {
        LOG(INFO) << state << " " << test_info.test_suite_name() << "::" << test_info.name();
    }
};

}  // namespace

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