test_libvpx.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include <string>
  11. #include "third_party/googletest/src/include/gtest/gtest.h"
  12. #include "./vpx_config.h"
  13. #if ARCH_X86 || ARCH_X86_64
  14. #include "vpx_ports/x86.h"
  15. #endif
  16. extern "C" {
  17. #if CONFIG_VP8
  18. extern void vp8_rtcd();
  19. #endif // CONFIG_VP8
  20. #if CONFIG_VP9
  21. extern void vp9_rtcd();
  22. #endif // CONFIG_VP9
  23. extern void vpx_dsp_rtcd();
  24. extern void vpx_scale_rtcd();
  25. }
  26. #if ARCH_X86 || ARCH_X86_64
  27. static void append_negative_gtest_filter(const char *str) {
  28. std::string filter = ::testing::FLAGS_gtest_filter;
  29. // Negative patterns begin with one '-' followed by a ':' separated list.
  30. if (filter.find('-') == std::string::npos) filter += '-';
  31. filter += str;
  32. ::testing::FLAGS_gtest_filter = filter;
  33. }
  34. #endif // ARCH_X86 || ARCH_X86_64
  35. int main(int argc, char **argv) {
  36. ::testing::InitGoogleTest(&argc, argv);
  37. #if ARCH_X86 || ARCH_X86_64
  38. const int simd_caps = x86_simd_caps();
  39. if (!(simd_caps & HAS_MMX)) append_negative_gtest_filter(":MMX.*:MMX/*");
  40. if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter(":SSE.*:SSE/*");
  41. if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter(":SSE2.*:SSE2/*");
  42. if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter(":SSE3.*:SSE3/*");
  43. if (!(simd_caps & HAS_SSSE3)) {
  44. append_negative_gtest_filter(":SSSE3.*:SSSE3/*");
  45. }
  46. if (!(simd_caps & HAS_SSE4_1)) {
  47. append_negative_gtest_filter(":SSE4_1.*:SSE4_1/*");
  48. }
  49. if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter(":AVX.*:AVX/*");
  50. if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter(":AVX2.*:AVX2/*");
  51. if (!(simd_caps & HAS_AVX512)) {
  52. append_negative_gtest_filter(":AVX512.*:AVX512/*");
  53. }
  54. #endif // ARCH_X86 || ARCH_X86_64
  55. #if !CONFIG_SHARED
  56. // Shared library builds don't support whitebox tests
  57. // that exercise internal symbols.
  58. #if CONFIG_VP8
  59. vp8_rtcd();
  60. #endif // CONFIG_VP8
  61. #if CONFIG_VP9
  62. vp9_rtcd();
  63. #endif // CONFIG_VP9
  64. vpx_dsp_rtcd();
  65. vpx_scale_rtcd();
  66. #endif // !CONFIG_SHARED
  67. return RUN_ALL_TESTS();
  68. }