summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/vfio/lib/include/libvfio/assert.h')
-rw-r--r--tools/testing/selftests/vfio/lib/include/libvfio/assert.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/assert.h b/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
index f4ebd122d9b6..77b68c7129a6 100644
--- a/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
+++ b/tools/testing/selftests/vfio/lib/include/libvfio/assert.h
@@ -51,4 +51,9 @@
VFIO_ASSERT_EQ(__ret, 0, "ioctl(%s, %s, %s) returned %d\n", #_fd, #_op, #_arg, __ret); \
} while (0)
+#define snprintf_assert(_s, _size, _fmt, ...) do { \
+ int __ret = snprintf(_s, _size, _fmt, ##__VA_ARGS__); \
+ VFIO_ASSERT_LT(__ret, _size); \
+} while (0)
+
#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_ASSERT_H */