root/tools/testing/selftests/kvm/include/test_util.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * tools/testing/selftests/kvm/include/test_util.h
   4  *
   5  * Copyright (C) 2018, Google LLC.
   6  */
   7 
   8 #ifndef SELFTEST_KVM_TEST_UTIL_H
   9 #define SELFTEST_KVM_TEST_UTIL_H
  10 
  11 #include <stdlib.h>
  12 #include <stdarg.h>
  13 #include <stdbool.h>
  14 #include <stdio.h>
  15 #include <string.h>
  16 #include <inttypes.h>
  17 #include <errno.h>
  18 #include <unistd.h>
  19 #include <fcntl.h>
  20 #include "kselftest.h"
  21 
  22 ssize_t test_write(int fd, const void *buf, size_t count);
  23 ssize_t test_read(int fd, void *buf, size_t count);
  24 int test_seq_read(const char *path, char **bufp, size_t *sizep);
  25 
  26 void test_assert(bool exp, const char *exp_str,
  27                  const char *file, unsigned int line, const char *fmt, ...);
  28 
  29 #define TEST_ASSERT(e, fmt, ...) \
  30         test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
  31 
  32 #define ASSERT_EQ(a, b) do { \
  33         typeof(a) __a = (a); \
  34         typeof(b) __b = (b); \
  35         TEST_ASSERT(__a == __b, \
  36                     "ASSERT_EQ(%s, %s) failed.\n" \
  37                     "\t%s is %#lx\n" \
  38                     "\t%s is %#lx", \
  39                     #a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \
  40 } while (0)
  41 
  42 #endif /* SELFTEST_KVM_TEST_UTIL_H */

/* [<][>][^][v][top][bottom][index][help] */