blob: b8a91e06c6605287a872163dfb6e414d0bdec647 [file] [log] [blame]
Ronald S. Bultjea742a732012-06-25 09:58:09 -07001/*
James Zernb7c05bd2024-06-11 19:15:10 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
Ronald S. Bultjea742a732012-06-25 09:58:09 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Johann123e8a62017-12-28 14:40:49 -080010 */
Yaowu Xu9c01aa12016-09-01 14:32:49 -070011
Wan-Teh Changc8b1fc22024-08-01 12:09:28 -070012#include "gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070013
Tom Finegan60e653d2018-05-22 11:34:58 -070014#include "config/aom_config.h"
15
Wan-Teh Chang1e20d2d2023-09-22 14:18:47 -070016#if !CONFIG_SHARED
17#include <string.h>
18
19#include <string>
20
George Steedc38bc8b2023-07-19 11:00:24 +010021#if AOM_ARCH_ARM
22#include "aom_ports/arm.h"
23#endif
James Zern1fbb25c2023-05-22 10:45:24 -070024#if AOM_ARCH_X86 || AOM_ARCH_X86_64
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "aom_ports/x86.h"
John Koleszar5ebe94f2012-12-23 07:20:10 -080026#endif
George Steedc38bc8b2023-07-19 11:00:24 +010027
James Zern002ad402014-01-18 13:03:31 -080028extern "C" {
Yaowu Xuf883b422016-08-30 14:01:10 -070029extern void av1_rtcd();
Yaowu Xuf883b422016-08-30 14:01:10 -070030extern void aom_dsp_rtcd();
31extern void aom_scale_rtcd();
Ronald S. Bultjea742a732012-06-25 09:58:09 -070032}
Ronald S. Bultjea742a732012-06-25 09:58:09 -070033
Wan-Teh Chang1e20d2d2023-09-22 14:18:47 -070034#if AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64
James Zernada9dd72014-01-10 19:08:44 -080035static void append_negative_gtest_filter(const char *str) {
Wan-Teh Chang5a8e91b2023-03-24 15:16:49 -070036 std::string flag_value = GTEST_FLAG_GET(filter);
James Zernada9dd72014-01-10 19:08:44 -080037 // Negative patterns begin with one '-' followed by a ':' separated list.
Wan-Teh Chang5a8e91b2023-03-24 15:16:49 -070038 if (flag_value.find('-') == std::string::npos) flag_value += '-';
Johannc4ec0322017-10-20 10:14:25 -070039 // OPT.* matches TEST() functions
40 // OPT/* matches TEST_P() functions
41 // OPT_* matches tests which have been manually sharded.
42 // We do not match OPT* because of SSE/SSE2 collisions.
43 const char *search_terminators = "./_";
44 for (size_t pos = 0; pos < strlen(search_terminators); ++pos) {
Wan-Teh Chang5a8e91b2023-03-24 15:16:49 -070045 flag_value += ":";
46 flag_value += str;
47 flag_value += search_terminators[pos];
48 flag_value += "*";
Johannc4ec0322017-10-20 10:14:25 -070049 }
Wan-Teh Chang5a8e91b2023-03-24 15:16:49 -070050 GTEST_FLAG_SET(filter, flag_value);
Ronald S. Bultjea742a732012-06-25 09:58:09 -070051}
Wan-Teh Chang1e20d2d2023-09-22 14:18:47 -070052#endif // AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64
53#endif // !CONFIG_SHARED
Ronald S. Bultjea742a732012-06-25 09:58:09 -070054
55int main(int argc, char **argv) {
Wan-Teh Chang13660752023-03-24 15:00:33 -070056 ::testing::InitGoogleTest(&argc, argv);
57
Wan-Teh Chang374fab32023-08-24 13:51:30 -070058#if !CONFIG_SHARED
George Steedc38bc8b2023-07-19 11:00:24 +010059#if AOM_ARCH_AARCH64
60 const int caps = aom_arm_cpu_caps();
61 if (!(caps & HAS_ARM_CRC32)) append_negative_gtest_filter("ARM_CRC32");
62 if (!(caps & HAS_NEON_DOTPROD)) append_negative_gtest_filter("NEON_DOTPROD");
63 if (!(caps & HAS_NEON_I8MM)) append_negative_gtest_filter("NEON_I8MM");
64 if (!(caps & HAS_SVE)) append_negative_gtest_filter("SVE");
Salome Thirot61f971f2024-02-09 11:20:58 +000065 if (!(caps & HAS_SVE2)) append_negative_gtest_filter("SVE2");
Wan-Teh Chang374fab32023-08-24 13:51:30 -070066#elif AOM_ARCH_ARM
George Steedc38bc8b2023-07-19 11:00:24 +010067 const int caps = aom_arm_cpu_caps();
68 if (!(caps & HAS_NEON)) append_negative_gtest_filter("NEON");
Wan-Teh Chang374fab32023-08-24 13:51:30 -070069#endif // AOM_ARCH_ARM
Wan-Teh Chang374fab32023-08-24 13:51:30 -070070
71#if AOM_ARCH_X86 || AOM_ARCH_X86_64
John Koleszar17b34a12012-06-22 11:53:04 -070072 const int simd_caps = x86_simd_caps();
Johannc4ec0322017-10-20 10:14:25 -070073 if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter("MMX");
74 if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter("SSE");
75 if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter("SSE2");
76 if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter("SSE3");
77 if (!(simd_caps & HAS_SSSE3)) append_negative_gtest_filter("SSSE3");
78 if (!(simd_caps & HAS_SSE4_1)) append_negative_gtest_filter("SSE4_1");
James Zerneea1d832018-03-03 12:29:42 -080079 if (!(simd_caps & HAS_SSE4_2)) append_negative_gtest_filter("SSE4_2");
Johannc4ec0322017-10-20 10:14:25 -070080 if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX");
81 if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2");
Wan-Teh Chang374fab32023-08-24 13:51:30 -070082#endif // AOM_ARCH_X86 || AOM_ARCH_X86_64
Ronald S. Bultjea742a732012-06-25 09:58:09 -070083
Wan-Teh Chang1e20d2d2023-09-22 14:18:47 -070084 // Shared library builds don't support whitebox tests that exercise internal
85 // symbols.
Yaowu Xuf883b422016-08-30 14:01:10 -070086 av1_rtcd();
Yaowu Xuf883b422016-08-30 14:01:10 -070087 aom_dsp_rtcd();
88 aom_scale_rtcd();
Johann14ef4ae2015-04-15 09:27:00 -040089#endif // !CONFIG_SHARED
John Koleszar434336b2012-12-06 13:56:25 -080090
Ronald S. Bultjea742a732012-06-25 09:58:09 -070091 return RUN_ALL_TESTS();
92}