From 91dbe3c6c2560bc144a4b06308f5e46839562bef Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 27 Sep 2018 09:31:13 +0200 Subject: [PATCH] test: allow unit tests to be skipped --- test/unit/test.c | 7 +++++++ test/unit/test.h | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/test/unit/test.c b/test/unit/test.c index 23bb835..fbfeb4b 100644 --- a/test/unit/test.c +++ b/test/unit/test.c @@ -33,6 +33,13 @@ TST_Fail(int line) exit(1); } +void +TST_Skip(int line) +{ + printf("SKIP (on line %d)\n", line); + exit(0); +} + int main(int argc, char **argv) { diff --git a/test/unit/test.h b/test/unit/test.h index f409252..2d3637b 100644 --- a/test/unit/test.h +++ b/test/unit/test.h @@ -33,7 +33,16 @@ extern void test_unit(void); } \ } while (0) +#define TEST_REQUIRE(expr) \ + do { \ + if (!(expr)) { \ + TST_Skip(__LINE__); \ + exit(0); \ + } \ + } while (0) + extern void TST_Fail(int line); +extern void TST_Skip(int line); extern void TST_SuspendLogging(void); extern void TST_ResumeLogging(void);