summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'unittest')
-rw-r--r--unittest/unittest.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/unittest/unittest.h b/unittest/unittest.h
index 0ed005f..2350f55 100644
--- a/unittest/unittest.h
+++ b/unittest/unittest.h
@@ -3,13 +3,18 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+
#include "stringify.h"
#define TEST_PASS 0
#define TEST_FAIL 1
+#define test_print(fmt, args...) \
+ fprintf(stderr, "%s:%d:" fmt, __FILE__, __LINE__, ##args)
+
#define assert_err(fmt, args...) \
- fprintf(stderr, "%s:%d: Assertion error: " fmt, __FILE__, __LINE__, ##args)
+ test_print("Assertion error: " fmt, ##args)
/* Assert the expression 'expr' */
#define test_assert(expr) ({if (!(expr)) { \
@@ -33,7 +38,34 @@
/* Assert that a != b */
#define test_assert_neq(a, b) ({ \
if ((a) == (b)) { \
- assert_err(__stringify(a) " != " __stringify(b) "\n"); \
+ assert_err(__stringify(a) " == " __stringify(b) "\n"); \
+ exit(TEST_FAIL); \
+ }})
+
+/* Assert that a is NULL */
+#define test_assert_null(a) ({ \
+ if ((a) != NULL) { \
+ assert_err(__stringify(a) " not NULL\n"); \
+ exit(TEST_FAIL); \
+ }})
+
+/* Assert that a is not NULL */
+#define test_assert_not_null(a) ({ \
+ if ((a) == NULL) { \
+ assert_err(__stringify(a) " is NULL\n"); \
+ exit(TEST_FAIL); \
+ }})
+
+static inline int __xstrmatch(const char *ctx, const char *arg)
+{
+ size_t len = strlen(ctx);
+ return (strlen(arg) == len && strncmp(arg, ctx, len) == 0);
+}
+
+/* Assert that string a matches string b */
+#define test_assert_str_eq(a, b) ({ \
+ if (!__xstrmatch((a), (b))) { \
+ assert_err(__stringify(a) " does not match " __stringify(b) "\n"); \
exit(TEST_FAIL); \
}})
d>1-6/+4 2014-07-01block SG_IO: add SG_FLAG_Q_AT_HEAD flagDouglas Gilbert1-1/+4 2014-07-01block: fix SG_[GS]ET_RESERVED_SIZE ioctl when max_sectors is hugeAkinobu Mita1-4/+11 2014-06-06block: add blk_rq_set_block_pc()Jens Axboe1-3/+3 2014-05-29block: remove dead code in scsi_ioctl:blk_verify_commandDave Jones1-4/+0 2014-01-21block: Fix memory leak in rw_copy_check_uvector() handlingChristian Engelmayer1-2/+4 2013-11-08block: Use rw_copy_check_uvector()Kent Overstreet1-29/+10 2013-05-07aio: don't include aio.h in sched.hKent Overstreet1-0/+1 2012-06-15scsi: Silence unnecessary warnings about ioctl to partitionJan Kara1-1/+4 2012-01-14block: fail SCSI passthrough ioctls on partition devicesPaolo Bonzini1-0/+45 2012-01-14block: add and use scsi_blk_cmd_ioctlPaolo Bonzini1-0/+7 2011-10-19block: drop unnecessary blk_get/put_queue() in scsi_cmd_ioctl() and blk_get_tg()Tejun Heo1-2/+1 2010-11-10block: take care not to overflow when calculating total iov lengthJens Axboe1-10/+24 net-next.git/commit/Documentation/media/kapi?id=d9d3d1761abecf72a8044762724fb04b5974a513'>[media] doc-rst: document v4l2-dev.hMauro Carvalho Chehab1-0/+5 2016-07-23[media] mc-core: Fix a cross-referenceMauro Carvalho Chehab1-1/+1 2016-07-23[media] v4l2-common.h: document the subdev functionsMauro Carvalho Chehab1-0/+6 2016-07-23[media] v4l2-subdev.rst: add cross references to new sectionsMauro Carvalho Chehab1-70/+82 2016-07-23[media] v4l2-subdev.rst: add two sections from v4l2-framework.rstMauro Carvalho Chehab2-165/+166 2016-07-23[media] doc-rst: merge v4l2-async.rst with v4l2-subdev.rstMauro Carvalho Chehab3-5/+5 2016-07-23[media] v4l2-subdev.rst: add cross-referencesMauro Carvalho Chehab1-77/+85 2016-07-23[media] v4l2-subdev.rst: add documentation from v4l2-framework.rstMauro Carvalho Chehab2-257/+256 2016-07-23[media] v4l2-device.rst: do cross references with kernel-docMauro Carvalho Chehab1-64/+66 2016-07-23[media] v4l2-device.rst: add contents from v4l2-frameworkMauro Carvalho Chehab2-140/+139 2016-07-23[media] doc-rst: Split v4l-core into one file per kAPIMauro Carvalho Chehab17-35/+85 2016-07-23[media] v4l2-device.h: document functionsMauro Carvalho Chehab1-0/+2 2016-07-23[media] doc-rst: better organize the media booksMauro Carvalho Chehab1-1/+1 2016-07-23Merge branch 'patchwork' into topic/docs-nextMauro Carvalho Chehab1-17/+0 2016-07-18[media] doc-rst: fix media kAPI documentationMauro Carvalho Chehab4-35/+1 2016-07-17[media] doc-rst: Convert videobuf documentation to ReSTMauro Carvalho Chehab1-2/+49 2016-07-17[media] doc-rst: move videobuf documentation to media/kapiMauro Carvalho Chehab2-47/+477 2016-07-17[media] doc-rst: do a poor man's conversion of v4l2-frameworkMauro Carvalho Chehab1-128/+230 2016-07-17[media] doc-rst: move framework docs to kAPI documentationMauro Carvalho Chehab2-0/+1911 2016-07-17[media] doc-rst: Fix conversion for dvb-core.rstMauro Carvalho Chehab1-13/+27 2016-07-17[media] doc-rst: Fix conversion for MC core functionsMauro Carvalho Chehab1-81/+105 2016-07-17[media] doc-rst: Fix conversion for v4l2 core functionsMauro Carvalho Chehab1-0/+21 2016-07-17[media] doc-rst: Fix issues with RC documentationMauro Carvalho Chehab1-0/+9 2016-07-17[media] doc-rst: split media_drivers.rst into one file per API typeMauro Carvalho Chehab4-0/+411