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