validate.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved.
  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. else
  37. {
  38. // printf("PASS at pos %d: %d\r\n", i, act[i]);
  39. }
  40. }
  41. if (!test_passed)
  42. {
  43. printf("%d of %d failed\r\n", count, total);
  44. }
  45. return test_passed;
  46. }
  47. static inline int validate_s16(int16_t *act, const int16_t *ref, int size)
  48. {
  49. int test_passed = true;
  50. int count = 0;
  51. int total = 0;
  52. for (int i = 0; i < size; ++i)
  53. {
  54. total++;
  55. if (act[i] != ref[i])
  56. {
  57. count++;
  58. printf("ERROR at pos %d: Act: %d Ref: %d\r\n", i, act[i], ref[i]);
  59. test_passed = false;
  60. }
  61. else
  62. {
  63. // printf("PASS at pos %d: %d\r\n", i, act[i]);
  64. }
  65. }
  66. if (!test_passed)
  67. {
  68. printf("%d of %d failed\r\n", count, total);
  69. }
  70. return test_passed;
  71. }