From 7cb138a6507cd0bece3c1de083debb562a735ae6 Mon Sep 17 00:00:00 2001 From: Harish Mahendrakar Date: Thu, 24 Sep 2026 13:58:19 -0700 Subject: [PATCH] tests: Decouple gtest headers from common test utilities Remove unused includes from TestCommon.cc, func_selector.h, and func_selector.cc. Wrap compare_output in TestCommon.h with #if __has_include() so that common test utilities can be reused by targets that do not depend on gtest (such as benchmarks). --- tests/common/TestCommon.cc | 2 -- tests/common/TestCommon.h | 6 ++++-- tests/common/func_selector.cc | 35 +++++++++++++++++------------------ tests/common/func_selector.h | 7 +++---- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/tests/common/TestCommon.cc b/tests/common/TestCommon.cc index d07f5bd5..fef1883a 100644 --- a/tests/common/TestCommon.cc +++ b/tests/common/TestCommon.cc @@ -16,8 +16,6 @@ * ******************************************************************************/ -#include - #include #include #include diff --git a/tests/common/TestCommon.h b/tests/common/TestCommon.h index 200419ae..6c407dd0 100644 --- a/tests/common/TestCommon.h +++ b/tests/common/TestCommon.h @@ -18,8 +18,6 @@ #pragma once -#include - #include #include #include @@ -49,6 +47,9 @@ const std::vector>& getChromaPUBlockSizes(); const std::vector& getSrc8Buf(); const std::vector& getTstArch(); +#if __has_include() +#include + // Compare outputs template static void compare_output(const std::vector& ref, @@ -62,5 +63,6 @@ static void compare_output(const std::vector& ref, << ht; } } +#endif std::string get_arch_str(IV_ARCH_T arch); diff --git a/tests/common/func_selector.cc b/tests/common/func_selector.cc index 44c88ace..72315d17 100644 --- a/tests/common/func_selector.cc +++ b/tests/common/func_selector.cc @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -35,7 +34,7 @@ const ihevc_func_selector_t ref = []() { ihevc_func_selector_t ret = {}; -#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ defined(_M_IX86) ihevc_init_function_ptr_generic(&ret); #elif defined(__aarch64__) || defined(__arm__) @@ -44,7 +43,7 @@ const ihevc_func_selector_t ref = []() { return ret; }(); -#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ defined(_M_IX86) const ihevc_func_selector_t test_ssse3 = []() { ihevc_func_selector_t ret = {}; @@ -87,28 +86,28 @@ const ihevc_func_selector_t test_arm32 = []() { }(); #endif -const ihevc_func_selector_t *get_ref_func_ptr() { return &ref; } +const ihevc_func_selector_t* get_ref_func_ptr() { return &ref; } -const ihevc_func_selector_t *get_tst_func_ptr(IV_ARCH_T arch) { +const ihevc_func_selector_t* get_tst_func_ptr(IV_ARCH_T arch) { switch (arch) { -#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \ defined(_M_IX86) - case ARCH_X86_SSSE3: - return &test_ssse3; - case ARCH_X86_SSE42: - return &test_sse42; + case ARCH_X86_SSSE3: + return &test_ssse3; + case ARCH_X86_SSE42: + return &test_sse42; #ifndef DISABLE_AVX2 - case ARCH_X86_AVX2: - return &test_avx2; + case ARCH_X86_AVX2: + return &test_avx2; #endif #elif defined(__aarch64__) - case ARCH_ARMV8_GENERIC: - return &test_arm64; + case ARCH_ARMV8_GENERIC: + return &test_arm64; #elif defined(__arm__) - case ARCH_ARM_A9Q: - return &test_arm32; + case ARCH_ARM_A9Q: + return &test_arm32; #endif - default: - return nullptr; + default: + return nullptr; } } diff --git a/tests/common/func_selector.h b/tests/common/func_selector.h index 2d49f5e6..0c5d8731 100644 --- a/tests/common/func_selector.h +++ b/tests/common/func_selector.h @@ -19,7 +19,6 @@ #define __FUNC_SELECTOR_H__ #include #include -#include #include #include #include @@ -33,7 +32,7 @@ #include "iv.h" // clang-format on -const ihevc_func_selector_t *get_ref_func_ptr(); -const ihevc_func_selector_t *get_tst_func_ptr(IV_ARCH_T arch); +const ihevc_func_selector_t* get_ref_func_ptr(); +const ihevc_func_selector_t* get_tst_func_ptr(IV_ARCH_T arch); -#endif /* __FUNC_SELECTOR_H__ */ \ No newline at end of file +#endif /* __FUNC_SELECTOR_H__ */