xref: /aosp_15_r20/external/libaom/test/test_libaom.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
15*77c1e3ccSAndroid Build Coastguard Worker 
16*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_SHARED
17*77c1e3ccSAndroid Build Coastguard Worker #include <string.h>
18*77c1e3ccSAndroid Build Coastguard Worker 
19*77c1e3ccSAndroid Build Coastguard Worker #include <string>
20*77c1e3ccSAndroid Build Coastguard Worker 
21*77c1e3ccSAndroid Build Coastguard Worker #if AOM_ARCH_ARM
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/arm.h"
23*77c1e3ccSAndroid Build Coastguard Worker #endif
24*77c1e3ccSAndroid Build Coastguard Worker #if AOM_ARCH_X86 || AOM_ARCH_X86_64
25*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/x86.h"
26*77c1e3ccSAndroid Build Coastguard Worker #endif
27*77c1e3ccSAndroid Build Coastguard Worker 
28*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
29*77c1e3ccSAndroid Build Coastguard Worker extern void av1_rtcd();
30*77c1e3ccSAndroid Build Coastguard Worker extern void aom_dsp_rtcd();
31*77c1e3ccSAndroid Build Coastguard Worker extern void aom_scale_rtcd();
32*77c1e3ccSAndroid Build Coastguard Worker }
33*77c1e3ccSAndroid Build Coastguard Worker 
34*77c1e3ccSAndroid Build Coastguard Worker #if AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64
append_negative_gtest_filter(const char * str)35*77c1e3ccSAndroid Build Coastguard Worker static void append_negative_gtest_filter(const char *str) {
36*77c1e3ccSAndroid Build Coastguard Worker   std::string flag_value = GTEST_FLAG_GET(filter);
37*77c1e3ccSAndroid Build Coastguard Worker   // Negative patterns begin with one '-' followed by a ':' separated list.
38*77c1e3ccSAndroid Build Coastguard Worker   if (flag_value.find('-') == std::string::npos) flag_value += '-';
39*77c1e3ccSAndroid Build Coastguard Worker   // OPT.* matches TEST() functions
40*77c1e3ccSAndroid Build Coastguard Worker   // OPT/* matches TEST_P() functions
41*77c1e3ccSAndroid Build Coastguard Worker   // OPT_* matches tests which have been manually sharded.
42*77c1e3ccSAndroid Build Coastguard Worker   // We do not match OPT* because of SSE/SSE2 collisions.
43*77c1e3ccSAndroid Build Coastguard Worker   const char *search_terminators = "./_";
44*77c1e3ccSAndroid Build Coastguard Worker   for (size_t pos = 0; pos < strlen(search_terminators); ++pos) {
45*77c1e3ccSAndroid Build Coastguard Worker     flag_value += ":";
46*77c1e3ccSAndroid Build Coastguard Worker     flag_value += str;
47*77c1e3ccSAndroid Build Coastguard Worker     flag_value += search_terminators[pos];
48*77c1e3ccSAndroid Build Coastguard Worker     flag_value += "*";
49*77c1e3ccSAndroid Build Coastguard Worker   }
50*77c1e3ccSAndroid Build Coastguard Worker   GTEST_FLAG_SET(filter, flag_value);
51*77c1e3ccSAndroid Build Coastguard Worker }
52*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64
53*77c1e3ccSAndroid Build Coastguard Worker #endif  // !CONFIG_SHARED
54*77c1e3ccSAndroid Build Coastguard Worker 
main(int argc,char ** argv)55*77c1e3ccSAndroid Build Coastguard Worker int main(int argc, char **argv) {
56*77c1e3ccSAndroid Build Coastguard Worker   ::testing::InitGoogleTest(&argc, argv);
57*77c1e3ccSAndroid Build Coastguard Worker 
58*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_SHARED
59*77c1e3ccSAndroid Build Coastguard Worker #if AOM_ARCH_AARCH64
60*77c1e3ccSAndroid Build Coastguard Worker   const int caps = aom_arm_cpu_caps();
61*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_ARM_CRC32)) append_negative_gtest_filter("ARM_CRC32");
62*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_NEON_DOTPROD)) append_negative_gtest_filter("NEON_DOTPROD");
63*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_NEON_I8MM)) append_negative_gtest_filter("NEON_I8MM");
64*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_SVE)) append_negative_gtest_filter("SVE");
65*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_SVE2)) append_negative_gtest_filter("SVE2");
66*77c1e3ccSAndroid Build Coastguard Worker #elif AOM_ARCH_ARM
67*77c1e3ccSAndroid Build Coastguard Worker   const int caps = aom_arm_cpu_caps();
68*77c1e3ccSAndroid Build Coastguard Worker   if (!(caps & HAS_NEON)) append_negative_gtest_filter("NEON");
69*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_ARCH_ARM
70*77c1e3ccSAndroid Build Coastguard Worker 
71*77c1e3ccSAndroid Build Coastguard Worker #if AOM_ARCH_X86 || AOM_ARCH_X86_64
72*77c1e3ccSAndroid Build Coastguard Worker   const int simd_caps = x86_simd_caps();
73*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter("MMX");
74*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter("SSE");
75*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter("SSE2");
76*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter("SSE3");
77*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSSE3)) append_negative_gtest_filter("SSSE3");
78*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSE4_1)) append_negative_gtest_filter("SSE4_1");
79*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_SSE4_2)) append_negative_gtest_filter("SSE4_2");
80*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX");
81*77c1e3ccSAndroid Build Coastguard Worker   if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2");
82*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_ARCH_X86 || AOM_ARCH_X86_64
83*77c1e3ccSAndroid Build Coastguard Worker 
84*77c1e3ccSAndroid Build Coastguard Worker   // Shared library builds don't support whitebox tests that exercise internal
85*77c1e3ccSAndroid Build Coastguard Worker   // symbols.
86*77c1e3ccSAndroid Build Coastguard Worker   av1_rtcd();
87*77c1e3ccSAndroid Build Coastguard Worker   aom_dsp_rtcd();
88*77c1e3ccSAndroid Build Coastguard Worker   aom_scale_rtcd();
89*77c1e3ccSAndroid Build Coastguard Worker #endif  // !CONFIG_SHARED
90*77c1e3ccSAndroid Build Coastguard Worker 
91*77c1e3ccSAndroid Build Coastguard Worker   return RUN_ALL_TESTS();
92*77c1e3ccSAndroid Build Coastguard Worker }
93