cgptlib_test.h 746 B

12345678910111213141516171819202122232425262728293031
  1. /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. */
  5. #ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_
  6. #define VBOOT_REFERENCE_CGPTLIB_TEST_H_
  7. #include <stdio.h>
  8. #include "sysincludes.h"
  9. enum {
  10. TEST_FAIL = -1,
  11. TEST_OK = 0,
  12. };
  13. #define TEST_CASE(func) #func, func
  14. typedef int (*test_func)();
  15. #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
  16. #define EXPECT(expr) \
  17. do { \
  18. if (!(expr)) { \
  19. printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\
  20. #expr, __FUNCTION__, __LINE__); \
  21. return TEST_FAIL; \
  22. } \
  23. } while (0)
  24. #endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */