selftests/powerpc: Fix subpage_prot test to return !0 on failure

It's helpful for automated testing if the test returns error codes back
to the calling program.

While we're here fix all the usages of %p to remove the double 0x, ie.
%p already includes 0x.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
Michael Ellerman 2016-05-02 14:54:29 +10:00
parent 438517ec78
commit 2f67798c1f
1 changed files with 10 additions and 8 deletions

View File

@ -73,7 +73,7 @@ static inline void check_faulted(void *addr, long page, long subpage, int write)
want_fault |= (subpage == ((page + 1) % 16));
if (faulted != want_fault) {
printf("Failed at 0x%p (p=%ld,sp=%ld,w=%d), want=%s, got=%s !\n",
printf("Failed at %p (p=%ld,sp=%ld,w=%d), want=%s, got=%s !\n",
addr, page, subpage, write,
want_fault ? "fault" : "pass",
faulted ? "fault" : "pass");
@ -82,7 +82,7 @@ static inline void check_faulted(void *addr, long page, long subpage, int write)
if (faulted) {
if (dar != addr) {
printf("Fault expected at 0x%p and happened at 0x%p !\n",
printf("Fault expected at %p and happened at %p !\n",
addr, dar);
}
faulted = 0;
@ -162,7 +162,7 @@ int test_anon(void)
mallocblock = (void *)align;
printf("allocated malloc block of 0x%lx bytes at 0x%p\n",
printf("allocated malloc block of 0x%lx bytes at %p\n",
mallocsize, mallocblock);
printf("testing malloc block...\n");
@ -197,7 +197,7 @@ int test_file(void)
perror("failed to map file");
return 1;
}
printf("allocated %s for 0x%lx bytes at 0x%p\n",
printf("allocated %s for 0x%lx bytes at %p\n",
file_name, filesize, fileblock);
printf("testing file map...\n");
@ -207,14 +207,16 @@ int test_file(void)
int main(int argc, char *argv[])
{
test_harness(test_anon, "subpage_prot_anon");
int rc;
rc = test_harness(test_anon, "subpage_prot_anon");
if (rc)
return rc;
if (argc > 1)
file_name = argv[1];
else
file_name = "tempfile";
test_harness(test_file, "subpage_prot_file");
return 0;
return test_harness(test_file, "subpage_prot_file");
}