Skip to content

Commit

Permalink
selftests/powerpc: Fix subpage_prot test to return !0 on failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Aneesh Kumar K.V <[email protected]>
  • Loading branch information
mpe committed May 11, 2016
1 parent 438517e commit 2f67798
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tools/testing/selftests/powerpc/mm/subpage_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
}

0 comments on commit 2f67798

Please sign in to comment.