1 /*
2 * SPDX-FileCopyrightText: Copyright 2010-2022, 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #pragma once
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include <stdio.h>
23
validate(int8_t * act,const int8_t * ref,int size)24 static inline int validate(int8_t *act, const int8_t *ref, int size)
25 {
26 int test_passed = true;
27 int count = 0;
28 int total = 0;
29
30 for (int i = 0; i < size; ++i)
31 {
32 total++;
33 if (act[i] != ref[i])
34 {
35 count++;
36 printf("ERROR at pos %d: Act: %d Ref: %d\r\n", i, act[i], ref[i]);
37 test_passed = false;
38 }
39 }
40
41 if (!test_passed)
42 {
43 printf("%d of %d failed\r\n", count, total);
44 }
45
46 return test_passed;
47 }
48
validate_s16(int16_t * act,const int16_t * ref,int size)49 static inline int validate_s16(int16_t *act, const int16_t *ref, int size)
50 {
51 int test_passed = true;
52 int count = 0;
53 int total = 0;
54
55 for (int i = 0; i < size; ++i)
56 {
57 total++;
58 if (act[i] != ref[i])
59 {
60 count++;
61 printf("ERROR at pos %d: Act: %d Ref: %d\r\n", i, act[i], ref[i]);
62 test_passed = false;
63 }
64 }
65
66 if (!test_passed)
67 {
68 printf("%d of %d failed\r\n", count, total);
69 }
70
71 return test_passed;
72 }
73