* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdbool.h>
#include <stdarg.h>
+#include <stdio.h>
#include <shared/macro.h>
/* File with correct stderr */
const char *err;
+ /*
+ * whether to treat the correct files as regex to the real
+ * output
+ */
+ bool regex;
+
/*
* Vector with pair of files
* key = correct file
} output;
/* comma-separated list of loaded modules at the end of the test */
const char *modules_loaded;
+ const char *modules_not_loaded;
testfunc func;
const char *config[_TC_LAST];
const char *path;
const struct keyval *env_vars;
bool need_spawn;
bool expected_fail;
+ /* allow to skip tests that don't meet compile-time dependencies */
+ bool skip;
+ bool print_outputs;
} __attribute__((aligned(8)));
#define assert_return(expr, r) \
do { \
if ((!(expr))) { \
- ERR("Failed assertion: " #expr "%s:%d %s", \
+ ERR("Failed assertion: " #expr " %s:%d %s\n", \
__FILE__, __LINE__, __PRETTY_FUNCTION__); \
return (r); \
} \
/* Test definitions */
-#define DEFINE_TEST(_name, ...) \
- static const struct test s##_name \
+#define DEFINE_TEST_WITH_FUNC(_name, _func, ...) \
+ static const struct test UNIQ(s##_name) \
__attribute__((used, section("kmod_tests"), aligned(8))) = { \
.name = #_name, \
- .func = _name, \
+ .func = _func, \
## __VA_ARGS__ \
};
-#define TESTSUITE_MAIN(_tests) \
+#define DEFINE_TEST(_name, ...) DEFINE_TEST_WITH_FUNC(_name, _name, __VA_ARGS__)
+
+#define TESTSUITE_MAIN() \
extern struct test __start_kmod_tests[] __attribute__((weak, visibility("hidden"))); \
extern struct test __stop_kmod_tests[] __attribute__((weak, visibility("hidden"))); \
int main(int argc, char *argv[]) \
arg = test_init(__start_kmod_tests, __stop_kmod_tests, argc, argv); \
if (arg == 0) \
return 0; \
+ if (arg < 0) \
+ return EXIT_FAILURE; \
\
if (arg < argc) { \
t = test_find(__start_kmod_tests, __stop_kmod_tests, argv[arg]); \