Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/kcmp: change test to use ksft framework

Change kcmp test to use kselftest framework to report
test results and test statistics.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>

+20 -7
+20 -7
tools/testing/selftests/kcmp/kcmp_test.c
··· 17 17 #include <sys/stat.h> 18 18 #include <sys/wait.h> 19 19 20 + #include "../kselftest.h" 21 + 20 22 static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) 21 23 { 22 24 return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); ··· 36 34 37 35 if (fd1 < 0) { 38 36 perror("Can't create file"); 39 - exit(1); 37 + ksft_exit_fail(); 40 38 } 41 39 42 40 pid2 = fork(); 43 41 if (pid2 < 0) { 44 42 perror("fork failed"); 45 - exit(1); 43 + ksft_exit_fail(); 46 44 } 47 45 48 46 if (!pid2) { ··· 52 50 fd2 = open(kpath, O_RDWR, 0644); 53 51 if (fd2 < 0) { 54 52 perror("Can't open file"); 55 - exit(1); 53 + ksft_exit_fail(); 56 54 } 57 55 58 56 /* An example of output and arguments */ ··· 76 74 if (ret) { 77 75 printf("FAIL: 0 expected but %d returned (%s)\n", 78 76 ret, strerror(errno)); 77 + ksft_inc_fail_cnt(); 79 78 ret = -1; 80 - } else 79 + } else { 81 80 printf("PASS: 0 returned as expected\n"); 81 + ksft_inc_pass_cnt(); 82 + } 82 83 83 84 /* Compare with self */ 84 85 ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); 85 86 if (ret) { 86 87 printf("FAIL: 0 expected but %d returned (%s)\n", 87 88 ret, strerror(errno)); 89 + ksft_inc_fail_cnt(); 88 90 ret = -1; 89 - } else 91 + } else { 90 92 printf("PASS: 0 returned as expected\n"); 93 + ksft_inc_pass_cnt(); 94 + } 91 95 92 - exit(ret); 96 + ksft_print_cnts(); 97 + 98 + if (ret) 99 + ksft_exit_fail(); 100 + else 101 + ksft_exit_pass(); 93 102 } 94 103 95 104 waitpid(pid2, &status, P_ALL); 96 105 97 - return 0; 106 + return ksft_exit_pass(); 98 107 }