1 // Copyright 2023 The libgav1 Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "absl/strings/match.h"
16 #include "gtest/gtest.h"
17 #include "src/dsp/x86/common_avx2_test.h"
18 #include "src/dsp/x86/common_sse4_test.h"
19 #include "src/utils/cpu.h"
20
21 namespace libgav1 {
22 namespace dsp {
23 namespace {
24
25 class CommonDspTest : public ::testing::Test {
26 protected:
SetUp()27 void SetUp() override {
28 const testing::TestInfo* const test_info =
29 testing::UnitTest::GetInstance()->current_test_info();
30 const char* const test_case = test_info->name();
31 if (absl::StartsWith(test_case, "SSE41")) {
32 if ((GetCpuInfo() & kSSE4_1) == 0) GTEST_SKIP() << "No SSE4.1 support!";
33 } else if (absl::StartsWith(test_case, "AVX2")) {
34 if ((GetCpuInfo() & kAVX2) == 0) GTEST_SKIP() << "No AVX2 support!";
35 } else {
36 FAIL() << "Unrecognized architecture prefix in test case name: "
37 << test_case;
38 }
39 }
40 };
41
42 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CommonDspTest);
43
44 #if LIBGAV1_ENABLE_AVX2
TEST_F(CommonDspTest,AVX2RightShiftWithRoundingS16)45 TEST_F(CommonDspTest, AVX2RightShiftWithRoundingS16) {
46 AVX2RightShiftWithRoundingS16Test();
47 }
48 #endif // LIBGAV1_ENABLE_AVX2
49
50 #if LIBGAV1_ENABLE_SSE4_1
TEST_F(CommonDspTest,SSE41RightShiftWithRoundingS16)51 TEST_F(CommonDspTest, SSE41RightShiftWithRoundingS16) {
52 SSE41RightShiftWithRoundingS16Test();
53 }
54 #endif // LIBGAV1_ENABLE_SSE41
55
56 } // namespace
57 } // namespace dsp
58 } // namespace libgav1
59