Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 1 | /* |
James Zern | b7c05bd | 2024-06-11 19:15:10 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved. |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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. |
Johann | 123e8a6 | 2017-12-28 14:40:49 -0800 | [diff] [blame] | 10 | */ |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 11 | |
Wan-Teh Chang | c8b1fc2 | 2024-08-01 12:09:28 -0700 | [diff] [blame] | 12 | #include "gtest/gtest.h" |
Jingning Han | 097d59c | 2015-07-29 14:51:36 -0700 | [diff] [blame] | 13 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 14 | #include "config/aom_config.h" |
| 15 | |
Wan-Teh Chang | 1e20d2d | 2023-09-22 14:18:47 -0700 | [diff] [blame] | 16 | #if !CONFIG_SHARED |
| 17 | #include <string.h> |
| 18 | |
| 19 | #include <string> |
| 20 | |
George Steed | c38bc8b | 2023-07-19 11:00:24 +0100 | [diff] [blame] | 21 | #if AOM_ARCH_ARM |
| 22 | #include "aom_ports/arm.h" |
| 23 | #endif |
James Zern | 1fbb25c | 2023-05-22 10:45:24 -0700 | [diff] [blame] | 24 | #if AOM_ARCH_X86 || AOM_ARCH_X86_64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | #include "aom_ports/x86.h" |
John Koleszar | 5ebe94f | 2012-12-23 07:20:10 -0800 | [diff] [blame] | 26 | #endif |
George Steed | c38bc8b | 2023-07-19 11:00:24 +0100 | [diff] [blame] | 27 | |
James Zern | 002ad40 | 2014-01-18 13:03:31 -0800 | [diff] [blame] | 28 | extern "C" { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | extern void av1_rtcd(); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 30 | extern void aom_dsp_rtcd(); |
| 31 | extern void aom_scale_rtcd(); |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 32 | } |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 33 | |
Wan-Teh Chang | 1e20d2d | 2023-09-22 14:18:47 -0700 | [diff] [blame] | 34 | #if AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64 |
James Zern | ada9dd7 | 2014-01-10 19:08:44 -0800 | [diff] [blame] | 35 | static void append_negative_gtest_filter(const char *str) { |
Wan-Teh Chang | 5a8e91b | 2023-03-24 15:16:49 -0700 | [diff] [blame] | 36 | std::string flag_value = GTEST_FLAG_GET(filter); |
James Zern | ada9dd7 | 2014-01-10 19:08:44 -0800 | [diff] [blame] | 37 | // Negative patterns begin with one '-' followed by a ':' separated list. |
Wan-Teh Chang | 5a8e91b | 2023-03-24 15:16:49 -0700 | [diff] [blame] | 38 | if (flag_value.find('-') == std::string::npos) flag_value += '-'; |
Johann | c4ec032 | 2017-10-20 10:14:25 -0700 | [diff] [blame] | 39 | // OPT.* matches TEST() functions |
| 40 | // OPT/* matches TEST_P() functions |
| 41 | // OPT_* matches tests which have been manually sharded. |
| 42 | // We do not match OPT* because of SSE/SSE2 collisions. |
| 43 | const char *search_terminators = "./_"; |
| 44 | for (size_t pos = 0; pos < strlen(search_terminators); ++pos) { |
Wan-Teh Chang | 5a8e91b | 2023-03-24 15:16:49 -0700 | [diff] [blame] | 45 | flag_value += ":"; |
| 46 | flag_value += str; |
| 47 | flag_value += search_terminators[pos]; |
| 48 | flag_value += "*"; |
Johann | c4ec032 | 2017-10-20 10:14:25 -0700 | [diff] [blame] | 49 | } |
Wan-Teh Chang | 5a8e91b | 2023-03-24 15:16:49 -0700 | [diff] [blame] | 50 | GTEST_FLAG_SET(filter, flag_value); |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 51 | } |
Wan-Teh Chang | 1e20d2d | 2023-09-22 14:18:47 -0700 | [diff] [blame] | 52 | #endif // AOM_ARCH_ARM || AOM_ARCH_X86 || AOM_ARCH_X86_64 |
| 53 | #endif // !CONFIG_SHARED |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 54 | |
| 55 | int main(int argc, char **argv) { |
Wan-Teh Chang | 1366075 | 2023-03-24 15:00:33 -0700 | [diff] [blame] | 56 | ::testing::InitGoogleTest(&argc, argv); |
| 57 | |
Wan-Teh Chang | 374fab3 | 2023-08-24 13:51:30 -0700 | [diff] [blame] | 58 | #if !CONFIG_SHARED |
George Steed | c38bc8b | 2023-07-19 11:00:24 +0100 | [diff] [blame] | 59 | #if AOM_ARCH_AARCH64 |
| 60 | const int caps = aom_arm_cpu_caps(); |
| 61 | if (!(caps & HAS_ARM_CRC32)) append_negative_gtest_filter("ARM_CRC32"); |
| 62 | if (!(caps & HAS_NEON_DOTPROD)) append_negative_gtest_filter("NEON_DOTPROD"); |
| 63 | if (!(caps & HAS_NEON_I8MM)) append_negative_gtest_filter("NEON_I8MM"); |
| 64 | if (!(caps & HAS_SVE)) append_negative_gtest_filter("SVE"); |
Salome Thirot | 61f971f | 2024-02-09 11:20:58 +0000 | [diff] [blame] | 65 | if (!(caps & HAS_SVE2)) append_negative_gtest_filter("SVE2"); |
Wan-Teh Chang | 374fab3 | 2023-08-24 13:51:30 -0700 | [diff] [blame] | 66 | #elif AOM_ARCH_ARM |
George Steed | c38bc8b | 2023-07-19 11:00:24 +0100 | [diff] [blame] | 67 | const int caps = aom_arm_cpu_caps(); |
| 68 | if (!(caps & HAS_NEON)) append_negative_gtest_filter("NEON"); |
Wan-Teh Chang | 374fab3 | 2023-08-24 13:51:30 -0700 | [diff] [blame] | 69 | #endif // AOM_ARCH_ARM |
Wan-Teh Chang | 374fab3 | 2023-08-24 13:51:30 -0700 | [diff] [blame] | 70 | |
| 71 | #if AOM_ARCH_X86 || AOM_ARCH_X86_64 |
John Koleszar | 17b34a1 | 2012-06-22 11:53:04 -0700 | [diff] [blame] | 72 | const int simd_caps = x86_simd_caps(); |
Johann | c4ec032 | 2017-10-20 10:14:25 -0700 | [diff] [blame] | 73 | if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter("MMX"); |
| 74 | if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter("SSE"); |
| 75 | if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter("SSE2"); |
| 76 | if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter("SSE3"); |
| 77 | if (!(simd_caps & HAS_SSSE3)) append_negative_gtest_filter("SSSE3"); |
| 78 | if (!(simd_caps & HAS_SSE4_1)) append_negative_gtest_filter("SSE4_1"); |
James Zern | eea1d83 | 2018-03-03 12:29:42 -0800 | [diff] [blame] | 79 | if (!(simd_caps & HAS_SSE4_2)) append_negative_gtest_filter("SSE4_2"); |
Johann | c4ec032 | 2017-10-20 10:14:25 -0700 | [diff] [blame] | 80 | if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter("AVX"); |
| 81 | if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter("AVX2"); |
Wan-Teh Chang | 374fab3 | 2023-08-24 13:51:30 -0700 | [diff] [blame] | 82 | #endif // AOM_ARCH_X86 || AOM_ARCH_X86_64 |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 83 | |
Wan-Teh Chang | 1e20d2d | 2023-09-22 14:18:47 -0700 | [diff] [blame] | 84 | // Shared library builds don't support whitebox tests that exercise internal |
| 85 | // symbols. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 86 | av1_rtcd(); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 87 | aom_dsp_rtcd(); |
| 88 | aom_scale_rtcd(); |
Johann | 14ef4ae | 2015-04-15 09:27:00 -0400 | [diff] [blame] | 89 | #endif // !CONFIG_SHARED |
John Koleszar | 434336b | 2012-12-06 13:56:25 -0800 | [diff] [blame] | 90 | |
Ronald S. Bultje | a742a73 | 2012-06-25 09:58:09 -0700 | [diff] [blame] | 91 | return RUN_ALL_TESTS(); |
| 92 | } |