1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef TEST_UTILS_128_H
23#define TEST_UTILS_128_H
24
25#include <stdio.h>
26#include <stdint.h>
27#include <inttypes.h>
28#include <string.h>
29
30#define PRINT_RESULTS 0
31#define PRINT_FAILURES 0
32
33
34static inline int32_t check_results_128(const char *isa_ase_name,
35 const char *group_name,
36 const char *instruction_name,
37 const uint32_t test_count,
38 const double elapsed_time,
39 const uint64_t *b128_result,
40 const uint64_t *b128_expect)
41{
42#if PRINT_RESULTS
43 uint32_t ii;
44 printf("\n");
45 for (ii = 0; ii < test_count; ii++) {
46 uint64_t a, b;
47 memcpy(&a, (b128_result + 2 * ii), 8);
48 memcpy(&b, (b128_result + 2 * ii + 1), 8);
49 if (ii % 8 != 0) {
50 printf(" { 0x%016llxULL, 0x%016llxULL, },\n", a, b);
51 } else {
52 printf(" { 0x%016llxULL, 0x%016llxULL, }, /* %3d */\n",
53 a, b, ii);
54 }
55 }
56 printf("\n");
57#endif
58 uint32_t i;
59 uint32_t pass_count = 0;
60 uint32_t fail_count = 0;
61
62 printf("| %-10s \t| %-20s\t| %-16s \t|",
63 isa_ase_name, group_name, instruction_name);
64 for (i = 0; i < test_count; i++) {
65 if ((b128_result[2 * i] == b128_expect[2 * i]) &&
66 (b128_result[2 * i + 1] == b128_expect[2 * i + 1])) {
67 pass_count++;
68 } else {
69#if PRINT_FAILURES
70 uint32_t ii;
71 uint64_t a, b;
72
73 printf("\n");
74
75 printf("FAILURE for test case %d!\n", i);
76
77 memcpy(&a, (b128_expect + 2 * i), 8);
78 memcpy(&b, (b128_expect + 2 * i + 1), 8);
79 printf("Expected result : { 0x%016llxULL, 0x%016llxULL, },\n",
80 a, b);
81
82 memcpy(&a, (b128_result + 2 * i), 8);
83 memcpy(&b, (b128_result + 2 * i + 1), 8);
84 printf("Actual result : { 0x%016llxULL, 0x%016llxULL, },\n",
85 a, b);
86
87 printf("\n");
88#endif
89 fail_count++;
90 }
91 }
92
93 printf(" PASS: %3d \t| FAIL: %3d \t| elapsed time: %5.2f ms \t|\n",
94 pass_count, fail_count, elapsed_time);
95
96 if (fail_count > 0) {
97 return -1;
98 } else {
99 return 0;
100 }
101}
102
103#endif
104