blob: 534d9647376a02d34798b69889a3320277ef4331 [file] [log] [blame]
Ronald S. Bultjea742a732012-06-25 09:58:09 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -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.
10*/
11
Johannc4ec0322017-10-20 10:14:25 -070012#include <string.h>
13
Ronald S. Bultjea742a732012-06-25 09:58:09 -070014#include <string>
Jingning Han097d59c2015-07-29 14:51:36 -070015
Tom Finegan7a07ece2017-02-07 17:14:05 -080016#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "./aom_config.h"
John Koleszar5ebe94f2012-12-23 07:20:10 -080019#if ARCH_X86 || ARCH_X86_64
Yaowu Xuc27fc142016-08-22 16:08:15 -070020#include "aom_ports/x86.h"
John Koleszar5ebe94f2012-12-23 07:20:10 -080021#endif
James Zern002ad402014-01-18 13:03:31 -080022extern "C" {
Yaowu Xuf883b422016-08-30 14:01:10 -070023#if CONFIG_AV1
24extern void av1_rtcd();
25#endif // CONFIG_AV1
26extern void aom_dsp_rtcd();
27extern void aom_scale_rtcd();
Ronald S. Bultjea742a732012-06-25 09:58:09 -070028}
Ronald S. Bultjea742a732012-06-25 09:58:09 -070029
Johann95633d02015-09-01 12:47:43 -070030#if ARCH_X86 || ARCH_X86_64
James Zernada9dd72014-01-10 19:08:44 -080031static void append_negative_gtest_filter(const char *str) {
Ronald S. Bultjea742a732012-06-25 09:58:09 -070032 std::string filter = ::testing::FLAGS_gtest_filter;
James Zernada9dd72014-01-10 19:08:44 -080033 // Negative patterns begin with one '-' followed by a ':' separated list.
34 if (filter.find('-') == std::string::npos) filter += '-';
Johannc4ec0322017-10-20 10:14:25 -070035 // OPT.* matches TEST() functions
36 // OPT/* matches TEST_P() functions
37 // OPT_* matches tests which have been manually sharded.
38 // We do not match OPT* because of SSE/SSE2 collisions.
39 const char *search_terminators = "./_";
40 for (size_t pos = 0; pos < strlen(search_terminators); ++pos) {
41 filter += ":";
42 filter += str;
43 filter += search_terminators[pos];
44 filter += "*";
45 }
Ronald S. Bultjea742a732012-06-25 09:58:09 -070046 ::testing::FLAGS_gtest_filter = filter;
47}
Johann95633d02015-09-01 12:47:43 -070048#endif // ARCH_X86 || ARCH_X86_64
Ronald S. Bultjea742a732012-06-25 09:58:09 -070049
50int main(int argc, char **argv) {
51 ::testing::InitGoogleTest(&argc, argv);
52
53#if ARCH_X86 || ARCH_X86_64
John Koleszar17b34a12012-06-22 11:53:04 -070054 const int simd_caps = x86_simd_caps();
Johannc4ec0322017-10-20 10:14:25 -070055 if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter("MMX");
56 if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter("SSE");
57 if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter("SSE2");
58 if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter("SSE3");
59 if (!(simd_caps & HAS_SSSE3)) append_negative_gtest_filter("SSSE3");
60 if (!(simd_caps & HAS_SSE4_1)) append_negative_gtest_filter("SSE4_1");
61 if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX");
62 if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2");
Johann95633d02015-09-01 12:47:43 -070063#endif // ARCH_X86 || ARCH_X86_64
Ronald S. Bultjea742a732012-06-25 09:58:09 -070064
John Koleszar5ebe94f2012-12-23 07:20:10 -080065#if !CONFIG_SHARED
Yaowu Xuafffa3d2013-09-05 08:45:56 -070066// Shared library builds don't support whitebox tests
67// that exercise internal symbols.
68
Yaowu Xuf883b422016-08-30 14:01:10 -070069#if CONFIG_AV1
70 av1_rtcd();
71#endif // CONFIG_AV1
72 aom_dsp_rtcd();
73 aom_scale_rtcd();
Johann14ef4ae2015-04-15 09:27:00 -040074#endif // !CONFIG_SHARED
John Koleszar434336b2012-12-06 13:56:25 -080075
Ronald S. Bultjea742a732012-06-25 09:58:09 -070076 return RUN_ALL_TESTS();
77}