validate.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * SPDX-FileCopyrightText: Copyright 2010-2022 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. #pragma once
  19. #include <stdbool.h>
  20. #include <stdint.h>
  21. #include <stdio.h>
  22. static inline int validate(int8_t *act, const int8_t *ref, int size)
  23. {
  24. int test_passed = true;
  25. int count = 0;
  26. int total = 0;
  27. for (int i = 0; i < size; ++i)
  28. {
  29. total++;
  30. if (act[i] != ref[i])
  31. {
  32. count++;
  33. printf("ERROR at pos %d: Act: %d Ref: %d\r\n", i, act[i], ref[i]);
  34. test_passed = false;
  35. }
  36. }
  37. if (!test_passed)
  38. {
  39. printf("%d of %d failed\r\n", count, total);
  40. }
  41. return test_passed;
  42. }
  43. static inline int validate_s16(int16_t *act, const int16_t *ref, int size)
  44. {
  45. int test_passed = true;
  46. int count = 0;
  47. int total = 0;
  48. for (int i = 0; i < size; ++i)
  49. {
  50. total++;
  51. if (act[i] != ref[i])
  52. {
  53. count++;
  54. printf("ERROR at pos %d: Act: %d Ref: %d\r\n", i, act[i], ref[i]);
  55. test_passed = false;
  56. }
  57. else
  58. {
  59. // printf("PASS at pos %d: %d\r\n", i, act[i]);
  60. }
  61. }
  62. if (!test_passed)
  63. {
  64. printf("%d of %d failed\r\n", count, total);
  65. }
  66. return test_passed;
  67. }