From: Bill Wendling <morbo@google.com>
To: kvm@vger.kernel.org
Cc: jmattson@google.com, sean.j.christopherson@intel.com,
Bill Wendling <morbo@google.com>
Subject: [kvm-unit-tests PATCH] x86: setjmp: check expected value of "i" to give better feedback
Date: Tue, 10 Sep 2019 19:31:42 -0700 [thread overview]
Message-ID: <20190911023142.85970-1-morbo@google.com> (raw)
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@google.com>
---
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
next reply other threads:[~2019-09-11 2:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 2:31 Bill Wendling [this message]
2019-09-19 20:10 ` [kvm-unit-tests PATCH] x86: setjmp: check expected value of "i" to give better feedback Jim Mattson
2019-09-19 20:39 ` Sean Christopherson
2019-09-19 22:14 ` [kvm-unit-tests PATCH 1/1] " Bill Wendling
2019-09-19 22:16 ` Bill Wendling
2019-09-24 14:03 ` [kvm-unit-tests PATCH] " Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190911023142.85970-1-morbo@google.com \
--to=morbo@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=sean.j.christopherson@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.