Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: unit_test/cpu_test.cc

Issue 1399523004: break up unittests into categories (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: bump version Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « unit_test/convert_test.cc ('k') | unit_test/math_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <string.h> 12 #include <string.h>
13 13
14 #include "libyuv/basic_types.h" 14 #include "libyuv/basic_types.h"
15 #include "libyuv/cpu_id.h" 15 #include "libyuv/cpu_id.h"
16 #include "libyuv/row.h" // For HAS_ARGBSHUFFLEROW_AVX2. 16 #include "libyuv/row.h" // For HAS_ARGBSHUFFLEROW_AVX2.
17 #include "libyuv/version.h" 17 #include "libyuv/version.h"
18 #include "../unit_test/unit_test.h" 18 #include "../unit_test/unit_test.h"
19 19
20 namespace libyuv { 20 namespace libyuv {
21 21
22 TEST_F(libyuvTest, TestCpuHas) { 22 TEST_F(LibYUVBaseTest, TestCpuHas) {
23 int cpu_flags = TestCpuFlag(-1); 23 int cpu_flags = TestCpuFlag(-1);
24 printf("Cpu Flags %x\n", cpu_flags); 24 printf("Cpu Flags %x\n", cpu_flags);
25 int has_arm = TestCpuFlag(kCpuHasARM); 25 int has_arm = TestCpuFlag(kCpuHasARM);
26 printf("Has ARM %x\n", has_arm); 26 printf("Has ARM %x\n", has_arm);
27 int has_neon = TestCpuFlag(kCpuHasNEON); 27 int has_neon = TestCpuFlag(kCpuHasNEON);
28 printf("Has NEON %x\n", has_neon); 28 printf("Has NEON %x\n", has_neon);
29 int has_x86 = TestCpuFlag(kCpuHasX86); 29 int has_x86 = TestCpuFlag(kCpuHasX86);
30 printf("Has X86 %x\n", has_x86); 30 printf("Has X86 %x\n", has_x86);
31 int has_sse2 = TestCpuFlag(kCpuHasSSE2); 31 int has_sse2 = TestCpuFlag(kCpuHasSSE2);
32 printf("Has SSE2 %x\n", has_sse2); 32 printf("Has SSE2 %x\n", has_sse2);
(...skipping 12 matching lines...) Expand all
45 int has_fma3 = TestCpuFlag(kCpuHasFMA3); 45 int has_fma3 = TestCpuFlag(kCpuHasFMA3);
46 printf("Has FMA3 %x\n", has_fma3); 46 printf("Has FMA3 %x\n", has_fma3);
47 int has_mips = TestCpuFlag(kCpuHasMIPS); 47 int has_mips = TestCpuFlag(kCpuHasMIPS);
48 printf("Has MIPS %x\n", has_mips); 48 printf("Has MIPS %x\n", has_mips);
49 int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP); 49 int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP);
50 printf("Has MIPS DSP %x\n", has_mips_dsp); 50 printf("Has MIPS DSP %x\n", has_mips_dsp);
51 int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2); 51 int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2);
52 printf("Has MIPS DSPR2 %x\n", has_mips_dspr2); 52 printf("Has MIPS DSPR2 %x\n", has_mips_dspr2);
53 } 53 }
54 54
55 TEST_F(libyuvTest, TestCompilerHasAVX2) { 55 TEST_F(LibYUVBaseTest, TestCompilerHasAVX2) {
56 #ifdef _MSC_VER 56 #ifdef _MSC_VER
57 printf("_MSC_VER %d\n", _MSC_VER); 57 printf("_MSC_VER %d\n", _MSC_VER);
58 #endif 58 #endif
59 #if !defined(LIBYUV_DISABLE_X86) && (defined(GCC_HAS_AVX2) || \ 59 #if !defined(LIBYUV_DISABLE_X86) && (defined(GCC_HAS_AVX2) || \
60 defined(CLANG_HAS_AVX2) || defined(VISUALC_HAS_AVX2)) 60 defined(CLANG_HAS_AVX2) || defined(VISUALC_HAS_AVX2))
61 printf("Has AVX2 1\n"); 61 printf("Has AVX2 1\n");
62 // If compiler supports AVX2, the following function is expected to exist: 62 // If compiler supports AVX2, the following function is expected to exist:
63 #if !defined(HAS_ARGBSHUFFLEROW_AVX2) 63 #if !defined(HAS_ARGBSHUFFLEROW_AVX2)
64 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was expected. 64 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was expected.
65 #endif 65 #endif
66 #else 66 #else
67 printf("Has AVX2 0\n"); 67 printf("Has AVX2 0\n");
68 // If compiler does not support AVX2, the following function not expected: 68 // If compiler does not support AVX2, the following function not expected:
69 #if defined(HAS_ARGBSHUFFLEROW_AVX2) 69 #if defined(HAS_ARGBSHUFFLEROW_AVX2)
70 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was not expected. 70 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was not expected.
71 #endif 71 #endif
72 #endif 72 #endif
73 } 73 }
74 74
75 #if defined(__i386__) || defined(__x86_64__) || \ 75 #if defined(__i386__) || defined(__x86_64__) || \
76 defined(_M_IX86) || defined(_M_X64) 76 defined(_M_IX86) || defined(_M_X64)
77 TEST_F(libyuvTest, TestCpuId) { 77 TEST_F(LibYUVBaseTest, TestCpuId) {
78 int has_x86 = TestCpuFlag(kCpuHasX86); 78 int has_x86 = TestCpuFlag(kCpuHasX86);
79 if (has_x86) { 79 if (has_x86) {
80 uint32 cpu_info[4]; 80 uint32 cpu_info[4];
81 // Vendor ID: 81 // Vendor ID:
82 // AuthenticAMD AMD processor 82 // AuthenticAMD AMD processor
83 // CentaurHauls Centaur processor 83 // CentaurHauls Centaur processor
84 // CyrixInstead Cyrix processor 84 // CyrixInstead Cyrix processor
85 // GenuineIntel Intel processor 85 // GenuineIntel Intel processor
86 // GenuineTMx86 Transmeta processor 86 // GenuineTMx86 Transmeta processor
87 // Geode by NSC National Semiconductor processor 87 // Geode by NSC National Semiconductor processor
(...skipping 27 matching lines...) Expand all
115 115
116 static int FileExists(const char* file_name) { 116 static int FileExists(const char* file_name) {
117 FILE* f = fopen(file_name, "r"); 117 FILE* f = fopen(file_name, "r");
118 if (!f) { 118 if (!f) {
119 return 0; 119 return 0;
120 } 120 }
121 fclose(f); 121 fclose(f);
122 return 1; 122 return 1;
123 } 123 }
124 124
125 TEST_F(libyuvTest, TestLinuxNeon) { 125 TEST_F(LibYUVBaseTest, TestLinuxNeon) {
126 if (FileExists("../../unit_test/testdata/arm_v7.txt")) { 126 if (FileExists("../../unit_test/testdata/arm_v7.txt")) {
127 EXPECT_EQ(0, ArmCpuCaps("../../unit_test/testdata/arm_v7.txt")); 127 EXPECT_EQ(0, ArmCpuCaps("../../unit_test/testdata/arm_v7.txt"));
128 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/tegra3.txt")); 128 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/tegra3.txt"));
129 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt")); 129 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt"));
130 } else { 130 } else {
131 printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n"); 131 printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n");
132 } 132 }
133 #if defined(__linux__) && defined(__ARM_NEON__) 133 #if defined(__linux__) && defined(__ARM_NEON__)
134 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo")); 134 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo"));
135 #endif 135 #endif
136 } 136 }
137 137
138 } // namespace libyuv 138 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/convert_test.cc ('k') | unit_test/math_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698