[kvm-unit-tests PATCH] x86: setjmp: check expected value of "i" to give better feedback

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

 



Use a list of expected values instead of printing out numbers, which
aren't very meaningful. This prints only if the expected and actual
values differ.

Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
---
 x86/setjmp.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/x86/setjmp.c b/x86/setjmp.c
index 976a632..c0b25ec 100644
--- a/x86/setjmp.c
+++ b/x86/setjmp.c
@@ -1,19 +1,30 @@
 #include "libcflat.h"
 #include "setjmp.h"
 
+int expected[] = {
+	0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+};
+
+#define NUM_EXPECTED (sizeof(expected) / sizeof(int))
+
 int main(void)
 {
-    volatile int i;
+    volatile int i = -1, index = 0;
+    volatile bool had_errors = false;
     jmp_buf j;
 
     if (setjmp(j) == 0) {
 	    i = 0;
     }
-    printf("%d\n", i);
-    if (++i < 10) {
+    if (expected[index++] != i) {
+	    printf("FAIL: actual %d / expected %d\n", i, expected[index]);
+            had_errors = true;
+    }
+    if (index < NUM_EXPECTED) {
+	    i++;
 	    longjmp(j, 1);
     }
 
-    printf("done\n");
+    printf("Test %s\n", had_errors ? "FAILED" : "PASSED");
     return 0;
 }
-- 
2.23.0.162.g0b9fbb3734-goog




[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