aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Gong <gong.chen@linux.intel.com>2010-05-24 17:20:32 +0800
committerAndi Kleen <ak@linux.intel.com>2010-05-25 15:32:52 +0200
commite0ca7f239bbf7dd4afdb25309762a86b63a3aa31 (patch)
tree9ed2ba242d477249e3cfd706280c81ea4c42f3b8
parent3c6118fc45992dc33e8f46a181918aa53eb3a1e3 (diff)
downloadmce-test-e0ca7f239bbf7dd4afdb25309762a86b63a3aa31.tar.gz
tsimpleinj: enhance automatic test for hwpoison test
add failure statistic and exit value check, so that it is easy to run automatic test. Signed-off-by: Chen Gong <gong.chen@linux.intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r--tsrc/tsimpleinj.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tsrc/tsimpleinj.c b/tsrc/tsimpleinj.c
index 758a270..a7029cb 100644
--- a/tsrc/tsimpleinj.c
+++ b/tsrc/tsimpleinj.c
@@ -21,6 +21,8 @@
#define err(x) perror(x),exit(1)
int count = 20;
+int failure = 0;
+int total_cases = 0;
sigjmp_buf recover;
int PS;
@@ -37,9 +39,12 @@ void sighandler(int sig, siginfo_t *si, void *arg)
void testmem(char *msg, char *page, int write)
{
printf("%s page %p\n", msg, page);
+ total_cases++;
if (sigsetjmp(recover,1) == 0) {
- if (madvise(page, PS, MADV_POISON) != 0)
+ if (madvise(page, PS, MADV_POISON) != 0) {
+ failure++;
perror("madvise");
+ }
if (write)
*page = 2;
else
@@ -98,7 +103,7 @@ int main(void)
fd = tempfd();
if (fd < 0) err("open testfile");
char *tmp = malloc(PS);
- if (!tmp) exit(ENOMEM);
+ if (!tmp) err("no enough memory");
memset(tmp, 0xff, PS);
write(fd, tmp, PS);
free(tmp);
@@ -148,6 +153,12 @@ int main(void)
close(fd);
#endif
+ if (failure > 0) {
+ printf("FAILURE -- %d of %d cases broken!\n", failure, total_cases);
+ return 1;
+ }
+ printf("SUCCESS\n");
+
return 0;
}