diff options
| author | Shuah Khan <shuahkh@osg.samsung.com> | 2014-10-03 11:08:14 -0400 |
|---|---|---|
| committer | Shuah Khan <shuahkh@osg.samsung.com> | 2014-11-17 12:39:24 -0500 |
| commit | e061bcd88573863daef2c67888ced5333b2ba536 (patch) | |
| tree | c7f6bd9303186f630806e3ddec1f82d37d5309cf /tools/testing/selftests/kcmp | |
| parent | 56661564e1fea94c42289edd59361a1f87932410 (diff) | |
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>
Diffstat (limited to 'tools/testing/selftests/kcmp')
| -rw-r--r-- | tools/testing/selftests/kcmp/kcmp_test.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c index dbba4084869c..a5a4da856dfe 100644 --- a/tools/testing/selftests/kcmp/kcmp_test.c +++ b/tools/testing/selftests/kcmp/kcmp_test.c | |||
| @@ -17,6 +17,8 @@ | |||
| 17 | #include <sys/stat.h> | 17 | #include <sys/stat.h> |
| 18 | #include <sys/wait.h> | 18 | #include <sys/wait.h> |
| 19 | 19 | ||
| 20 | #include "../kselftest.h" | ||
| 21 | |||
| 20 | static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) | 22 | static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) |
| 21 | { | 23 | { |
| 22 | return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); | 24 | return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); |
| @@ -34,13 +36,13 @@ int main(int argc, char **argv) | |||
| 34 | 36 | ||
| 35 | if (fd1 < 0) { | 37 | if (fd1 < 0) { |
| 36 | perror("Can't create file"); | 38 | perror("Can't create file"); |
| 37 | exit(1); | 39 | ksft_exit_fail(); |
| 38 | } | 40 | } |
| 39 | 41 | ||
| 40 | pid2 = fork(); | 42 | pid2 = fork(); |
| 41 | if (pid2 < 0) { | 43 | if (pid2 < 0) { |
| 42 | perror("fork failed"); | 44 | perror("fork failed"); |
| 43 | exit(1); | 45 | ksft_exit_fail(); |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | if (!pid2) { | 48 | if (!pid2) { |
| @@ -50,7 +52,7 @@ int main(int argc, char **argv) | |||
| 50 | fd2 = open(kpath, O_RDWR, 0644); | 52 | fd2 = open(kpath, O_RDWR, 0644); |
| 51 | if (fd2 < 0) { | 53 | if (fd2 < 0) { |
| 52 | perror("Can't open file"); | 54 | perror("Can't open file"); |
| 53 | exit(1); | 55 | ksft_exit_fail(); |
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | /* An example of output and arguments */ | 58 | /* An example of output and arguments */ |
| @@ -74,23 +76,34 @@ int main(int argc, char **argv) | |||
| 74 | if (ret) { | 76 | if (ret) { |
| 75 | printf("FAIL: 0 expected but %d returned (%s)\n", | 77 | printf("FAIL: 0 expected but %d returned (%s)\n", |
| 76 | ret, strerror(errno)); | 78 | ret, strerror(errno)); |
| 79 | ksft_inc_fail_cnt(); | ||
| 77 | ret = -1; | 80 | ret = -1; |
| 78 | } else | 81 | } else { |
| 79 | printf("PASS: 0 returned as expected\n"); | 82 | printf("PASS: 0 returned as expected\n"); |
| 83 | ksft_inc_pass_cnt(); | ||
| 84 | } | ||
| 80 | 85 | ||
| 81 | /* Compare with self */ | 86 | /* Compare with self */ |
| 82 | ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); | 87 | ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0); |
| 83 | if (ret) { | 88 | if (ret) { |
| 84 | printf("FAIL: 0 expected but %d returned (%s)\n", | 89 | printf("FAIL: 0 expected but %d returned (%s)\n", |
| 85 | ret, strerror(errno)); | 90 | ret, strerror(errno)); |
| 91 | ksft_inc_fail_cnt(); | ||
| 86 | ret = -1; | 92 | ret = -1; |
| 87 | } else | 93 | } else { |
| 88 | printf("PASS: 0 returned as expected\n"); | 94 | printf("PASS: 0 returned as expected\n"); |
| 95 | ksft_inc_pass_cnt(); | ||
| 96 | } | ||
| 97 | |||
| 98 | ksft_print_cnts(); | ||
| 89 | 99 | ||
| 90 | exit(ret); | 100 | if (ret) |
| 101 | ksft_exit_fail(); | ||
| 102 | else | ||
| 103 | ksft_exit_pass(); | ||
| 91 | } | 104 | } |
| 92 | 105 | ||
| 93 | waitpid(pid2, &status, P_ALL); | 106 | waitpid(pid2, &status, P_ALL); |
| 94 | 107 | ||
| 95 | return 0; | 108 | return ksft_exit_pass(); |
| 96 | } | 109 | } |
