xref: /aosp_15_r20/external/libvpx/test/init_vpx_test.cc (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2023 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "test/init_vpx_test.h"
12 
13 #include "./vpx_config.h"
14 
15 #if !CONFIG_SHARED
16 #include <string>
17 #include "gtest/gtest.h"
18 #if VPX_ARCH_ARM
19 #include "vpx_ports/arm.h"
20 #endif
21 #if VPX_ARCH_X86 || VPX_ARCH_X86_64
22 #include "vpx_ports/x86.h"
23 #endif
24 extern "C" {
25 #if CONFIG_VP8
26 extern void vp8_rtcd();
27 #endif  // CONFIG_VP8
28 #if CONFIG_VP9
29 extern void vp9_rtcd();
30 #endif  // CONFIG_VP9
31 extern void vpx_dsp_rtcd();
32 extern void vpx_scale_rtcd();
33 }
34 
35 #if VPX_ARCH_ARM || VPX_ARCH_X86 || VPX_ARCH_X86_64
append_negative_gtest_filter(const char * str)36 static void append_negative_gtest_filter(const char *str) {
37   std::string filter = GTEST_FLAG_GET(filter);
38   // Negative patterns begin with one '-' followed by a ':' separated list.
39   if (filter.find('-') == std::string::npos) filter += '-';
40   filter += str;
41   GTEST_FLAG_SET(filter, filter);
42 }
43 #endif  // VPX_ARCH_ARM || VPX_ARCH_X86 || VPX_ARCH_X86_64
44 #endif  // !CONFIG_SHARED
45 
46 namespace libvpx_test {
init_vpx_test()47 void init_vpx_test() {
48 #if !CONFIG_SHARED
49 #if VPX_ARCH_AARCH64
50   const int caps = arm_cpu_caps();
51   if (!(caps & HAS_NEON_DOTPROD)) {
52     append_negative_gtest_filter(":NEON_DOTPROD.*:NEON_DOTPROD/*");
53   }
54   if (!(caps & HAS_NEON_I8MM)) {
55     append_negative_gtest_filter(":NEON_I8MM.*:NEON_I8MM/*");
56   }
57   if (!(caps & HAS_SVE)) {
58     append_negative_gtest_filter(":SVE.*:SVE/*");
59   }
60   if (!(caps & HAS_SVE2)) {
61     append_negative_gtest_filter(":SVE2.*:SVE2/*");
62   }
63 #elif VPX_ARCH_ARM
64   const int caps = arm_cpu_caps();
65   if (!(caps & HAS_NEON)) append_negative_gtest_filter(":NEON.*:NEON/*");
66 #endif  // VPX_ARCH_ARM
67 
68 #if VPX_ARCH_X86 || VPX_ARCH_X86_64
69   const int simd_caps = x86_simd_caps();
70   if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter(":MMX.*:MMX/*");
71   if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter(":SSE.*:SSE/*");
72   if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter(":SSE2.*:SSE2/*");
73   if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter(":SSE3.*:SSE3/*");
74   if (!(simd_caps & HAS_SSSE3)) {
75     append_negative_gtest_filter(":SSSE3.*:SSSE3/*");
76   }
77   if (!(simd_caps & HAS_SSE4_1)) {
78     append_negative_gtest_filter(":SSE4_1.*:SSE4_1/*");
79   }
80   if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter(":AVX.*:AVX/*");
81   if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter(":AVX2.*:AVX2/*");
82   if (!(simd_caps & HAS_AVX512)) {
83     append_negative_gtest_filter(":AVX512.*:AVX512/*");
84   }
85 #endif  // VPX_ARCH_X86 || VPX_ARCH_X86_64
86 
87   // Shared library builds don't support whitebox tests that exercise internal
88   // symbols.
89 #if CONFIG_VP8
90   vp8_rtcd();
91 #endif  // CONFIG_VP8
92 #if CONFIG_VP9
93   vp9_rtcd();
94 #endif  // CONFIG_VP9
95   vpx_dsp_rtcd();
96   vpx_scale_rtcd();
97 #endif  // !CONFIG_SHARED
98 }
99 }  // namespace libvpx_test
100