validate.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2010-2020 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 <stdint.h>
  20. #include <stdio.h>
  21. #include <stdbool.h>
  22. 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. }