OLD | NEW |
1 /* crosstest.py --test=mem_intrin.cpp --driver=mem_intrin_main.cpp \ | 1 /* crosstest.py --test=mem_intrin.cpp --driver=mem_intrin_main.cpp \ |
2 --prefix=Subzero_ --output=mem_intrin */ | 2 --prefix=Subzero_ --output=mem_intrin */ |
3 | 3 |
4 #include <stdint.h> /* cstdint requires -std=c++0x or higher */ | 4 #include <stdint.h> /* cstdint requires -std=c++0x or higher */ |
5 #include <cstdio> | 5 #include <cstdio> |
6 | 6 |
7 #include "mem_intrin.h" | 7 #include "mem_intrin.h" |
8 namespace Subzero_ { | 8 namespace Subzero_ { |
9 #include "mem_intrin.h" | 9 #include "mem_intrin.h" |
10 } | 10 } |
(...skipping 22 matching lines...) Expand all Loading... |
33 #undef do_test_fixed | 33 #undef do_test_fixed |
34 } | 34 } |
35 | 35 |
36 void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 36 void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
37 uint8_t buf[256]; | 37 uint8_t buf[256]; |
38 uint8_t buf2[256]; | 38 uint8_t buf2[256]; |
39 #define do_test_variable(test_func) \ | 39 #define do_test_variable(test_func) \ |
40 for (size_t len = 4; len < 128; ++len) { \ | 40 for (size_t len = 4; len < 128; ++len) { \ |
41 for (uint8_t init_val = 0; init_val < 100; ++init_val) { \ | 41 for (uint8_t init_val = 0; init_val < 100; ++init_val) { \ |
42 ++TotalTests; \ | 42 ++TotalTests; \ |
43 int llc_result = test_func(buf, (void *)buf2, init_val, len); \ | 43 int llc_result = test_func(buf, buf2, init_val, len); \ |
44 int sz_result = Subzero_::test_func(buf, (void *)buf2, init_val, len); \ | 44 int sz_result = Subzero_::test_func(buf, buf2, init_val, len); \ |
45 if (llc_result == sz_result) { \ | 45 if (llc_result == sz_result) { \ |
46 ++Passes; \ | 46 ++Passes; \ |
47 } else { \ | 47 } else { \ |
48 ++Failures; \ | 48 ++Failures; \ |
49 printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \ | 49 printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \ |
50 STR(test_func), init_val, len, llc_result, sz_result); \ | 50 STR(test_func), init_val, len, llc_result, sz_result); \ |
51 } \ | 51 } \ |
52 } \ | 52 } \ |
53 } | 53 } |
54 | 54 |
55 do_test_variable(memcpy_test) | 55 do_test_variable(memcpy_test) |
56 do_test_variable(memmove_test) | 56 do_test_variable(memmove_test) |
57 do_test_variable(memset_test) | 57 do_test_variable(memset_test) |
58 #undef do_test_variable | 58 #undef do_test_variable |
59 } | 59 } |
60 | 60 |
61 int main(int argc, char **argv) { | 61 int main(int argc, char **argv) { |
62 unsigned TotalTests = 0; | 62 unsigned TotalTests = 0; |
63 unsigned Passes = 0; | 63 unsigned Passes = 0; |
64 unsigned Failures = 0; | 64 unsigned Failures = 0; |
65 testFixedLen(TotalTests, Passes, Failures); | 65 testFixedLen(TotalTests, Passes, Failures); |
66 testVariableLen(TotalTests, Passes, Failures); | 66 testVariableLen(TotalTests, Passes, Failures); |
67 printf("TotalTests=%u Passes=%u Failures=%u\n", TotalTests, Passes, Failures); | 67 printf("TotalTests=%u Passes=%u Failures=%u\n", TotalTests, Passes, Failures); |
68 return Failures; | 68 return Failures; |
69 } | 69 } |
OLD | NEW |