/*
- * Copyright (C) 2012 ProFUSION embedded systems
+ * Copyright (C) 2012-2013 ProFUSION embedded systems
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <stdbool.h>
#include <stdarg.h>
+#include "macro.h"
+
struct test;
typedef int (*testfunc)(const struct test *t);
const char *name;
const char *description;
struct {
- const char *stdout;
- const char *stderr;
+ /* File with correct stdout */
+ const char *out;
+ /* File with correct stderr */
+ const char *err;
+
+ /*
+ * Vector with pair of files
+ * key = correct file
+ * val = file to check
+ */
+ const struct keyval *files;
} output;
+ /* comma-separated list of loaded modules at the end of the test */
+ const char *modules_loaded;
testfunc func;
const char *config[_TC_LAST];
const char *path;
#define WARN(fmt, ...) _LOG("WARN: ", fmt, ## __VA_ARGS__)
#define ERR(fmt, ...) _LOG("ERR: ", fmt, ## __VA_ARGS__)
+#define assert_return(expr, r) \
+ do { \
+ if ((!(expr))) { \
+ ERR("Failed assertion: " #expr, \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+ return (r); \
+ } \
+ } while (false)
+
+
/* Test definitions */
#define DEFINE_TEST(_name, ...) \
const struct test s##_name = { \
exit(EXIT_SUCCESS); \
} \
-#define __noreturn __attribute__((noreturn))
+#ifdef noreturn
+# define __noreturn noreturn
+#elif __STDC_VERSION__ >= 201112L
+# define __noreturn _Noreturn
+#else
+# define __noreturn __attribute__((noreturn))
+#endif