• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * 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.
10  */
11 
12 #include <string.h>
13 
14 #include <string>
15 
16 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
17 
18 #include "config/aom_config.h"
19 
20 #if ARCH_X86 || ARCH_X86_64
21 #include "aom_ports/x86.h"
22 #endif
23 extern "C" {
24 extern void av1_rtcd();
25 extern void aom_dsp_rtcd();
26 extern void aom_scale_rtcd();
27 }
28 
29 #if ARCH_X86 || ARCH_X86_64
append_negative_gtest_filter(const char * str)30 static void append_negative_gtest_filter(const char *str) {
31   std::string filter = ::testing::FLAGS_gtest_filter;
32   // Negative patterns begin with one '-' followed by a ':' separated list.
33   if (filter.find('-') == std::string::npos) filter += '-';
34   // OPT.* matches TEST() functions
35   // OPT/* matches TEST_P() functions
36   // OPT_* matches tests which have been manually sharded.
37   // We do not match OPT* because of SSE/SSE2 collisions.
38   const char *search_terminators = "./_";
39   for (size_t pos = 0; pos < strlen(search_terminators); ++pos) {
40     filter += ":";
41     filter += str;
42     filter += search_terminators[pos];
43     filter += "*";
44   }
45   ::testing::FLAGS_gtest_filter = filter;
46 }
47 #endif  // ARCH_X86 || ARCH_X86_64
48 
main(int argc,char ** argv)49 int main(int argc, char **argv) {
50   ::testing::InitGoogleTest(&argc, argv);
51 
52 #if ARCH_X86 || ARCH_X86_64
53   const int simd_caps = x86_simd_caps();
54   if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter("MMX");
55   if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter("SSE");
56   if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter("SSE2");
57   if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter("SSE3");
58   if (!(simd_caps & HAS_SSSE3)) append_negative_gtest_filter("SSSE3");
59   if (!(simd_caps & HAS_SSE4_1)) append_negative_gtest_filter("SSE4_1");
60   if (!(simd_caps & HAS_SSE4_2)) append_negative_gtest_filter("SSE4_2");
61   if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX");
62   if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2");
63 #endif  // ARCH_X86 || ARCH_X86_64
64 
65 // Shared library builds don't support whitebox tests that exercise internal
66 // symbols.
67 #if !CONFIG_SHARED
68   av1_rtcd();
69   aom_dsp_rtcd();
70   aom_scale_rtcd();
71 #endif  // !CONFIG_SHARED
72 
73   return RUN_ALL_TESTS();
74 }
75