[PATCH v4 09/19] libcflat: add abort() and assert()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The test framework may have external dependencies. assert() provides
the ability to abort when those dependencies aren't met. However,
assert() should only be used for unlikely conditions. We can provide
more informative messages with printf() for the more likely problems.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/libcflat.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 99d1cd533dd03..c7c31be1cc8e5 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -67,4 +67,13 @@ extern long atol(const char *ptr);
 
 void report(const char *msg_fmt, bool pass, ...);
 int report_summary(void);
+
+#define abort() exit(64)		/* 129 exit status from qemu */
+#define assert(cond)							\
+do {									\
+	if (!(cond))							\
+		printf("%s:%d: assert failed\n", __FILE__, __LINE__),	\
+		abort();						\
+} while (0)
+
 #endif
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux