]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
unittest: new rok() is ok or display the label and "return 1;"
authorAlain Spineux <alain@baculasystems.com>
Wed, 26 Feb 2020 17:53:47 +0000 (18:53 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:57 +0000 (09:02 +0100)
avoid the display of the OK message when it succeed
rok() is useful to skip tests that follow and depend of the success
of the test
I like to use it for test that should never fail

bacula/src/lib/unittests.h

index 7c1ff479705e482989b0ec25f75dfce7b3ce4521..d29c4d177357345cddf10846aa7b65f9ebb81d72 100644 (file)
@@ -31,6 +31,8 @@
 #define is(x, y, label) _is(__FILE__, __LINE__, #x, (x), (y), label)
 #define isnt(x, y, label) _isnt(__FILE__, __LINE__, #x, (x), (y), label)
 
+#define rok(x, label) { bool v=(x); if (!v) { _ok(__FILE__, __LINE__, #x, v, label); return 1; } }
+
 /* TODO: log() ported from BEE it should be updated. */
 #ifdef RTEST_LOG_THREADID
 #define log(format, ...)  do { \