blob: 4db050e30ac9428e276eb8649887a41aea239727 [file] [log] [blame]
Ronald S. Bultjea742a732012-06-25 09:58:09 -07001/*
Krishna Rapaka7319db52021-09-28 20:35:29 -07002 * Copyright (c) 2021, Alliance for Open Media. All rights reserved
Ronald S. Bultjea742a732012-06-25 09:58:09 -07003 *
Vibhoothi41c6dd72021-10-12 18:48:26 +00004 * This source code is subject to the terms of the BSD 3-Clause Clear License
5 * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6 * License was not distributed with this source code in the LICENSE file, you
7 * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the
8 * Alliance for Open Media Patent License 1.0 was not distributed with this
9 * source code in the PATENTS file, you can obtain it at
10 * aomedia.org/license/patent-license/.
Johann123e8a62017-12-28 14:40:49 -080011 */
Yaowu Xu9c01aa12016-09-01 14:32:49 -070012
Johannc4ec0322017-10-20 10:14:25 -070013#include <string.h>
14
Ronald S. Bultjea742a732012-06-25 09:58:09 -070015#include <string>
Jingning Han097d59c2015-07-29 14:51:36 -070016
Tom Finegan7a07ece2017-02-07 17:14:05 -080017#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070018
Tom Finegan60e653d2018-05-22 11:34:58 -070019#include "config/aom_config.h"
20
John Koleszar5ebe94f2012-12-23 07:20:10 -080021#if ARCH_X86 || ARCH_X86_64
Yaowu Xuc27fc142016-08-22 16:08:15 -070022#include "aom_ports/x86.h"
John Koleszar5ebe94f2012-12-23 07:20:10 -080023#endif
James Zern002ad402014-01-18 13:03:31 -080024extern "C" {
Yaowu Xuf883b422016-08-30 14:01:10 -070025extern void av1_rtcd();
Yaowu Xuf883b422016-08-30 14:01:10 -070026extern 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");
James Zerneea1d832018-03-03 12:29:42 -080061 if (!(simd_caps & HAS_SSE4_2)) append_negative_gtest_filter("SSE4_2");
Johannc4ec0322017-10-20 10:14:25 -070062 if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX");
63 if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2");
Johann95633d02015-09-01 12:47:43 -070064#endif // ARCH_X86 || ARCH_X86_64
Ronald S. Bultjea742a732012-06-25 09:58:09 -070065
Johannf152ff62018-02-08 14:33:07 -080066// Shared library builds don't support whitebox tests that exercise internal
67// symbols.
John Koleszar5ebe94f2012-12-23 07:20:10 -080068#if !CONFIG_SHARED
Yaowu Xuf883b422016-08-30 14:01:10 -070069 av1_rtcd();
Yaowu Xuf883b422016-08-30 14:01:10 -070070 aom_dsp_rtcd();
71 aom_scale_rtcd();
Johann14ef4ae2015-04-15 09:27:00 -040072#endif // !CONFIG_SHARED
John Koleszar434336b2012-12-06 13:56:25 -080073
Ronald S. Bultjea742a732012-06-25 09:58:09 -070074 return RUN_ALL_TESTS();
75}