diff options
author | Shuah Khan <shuahkh@osg.samsung.com> | 2016-06-17 20:05:05 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2016-06-27 15:21:26 -0400 |
commit | e9c0d44f5328ba844f7e037791b9cc72ee3ef964 (patch) | |
tree | e095d64468cdc4a3babe606f69abe8a3a2a4b940 | |
parent | bff124682eaa784596672bdd344b9b0f646035a2 (diff) |
selftests: media_device_test change it to randomize loop count
Change it to randomize the loop count instead of hardcoded number of times
ioctl is called.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
-rw-r--r-- | tools/testing/selftests/media_tests/media_device_test.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/testing/selftests/media_tests/media_device_test.c b/tools/testing/selftests/media_tests/media_device_test.c index cbf53a032ab5..5d49943e77d0 100644 --- a/tools/testing/selftests/media_tests/media_device_test.c +++ b/tools/testing/selftests/media_tests/media_device_test.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * media_devkref_test.c - Media Controller Device Kref API Test | 2 | * media_device_test.c - Media Controller Device ioctl loop Test |
3 | * | 3 | * |
4 | * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com> | 4 | * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com> |
5 | * Copyright (c) 2016 Samsung Electronics Co., Ltd. | 5 | * Copyright (c) 2016 Samsung Electronics Co., Ltd. |
@@ -35,13 +35,14 @@ | |||
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <sys/ioctl.h> | 36 | #include <sys/ioctl.h> |
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | #include <time.h> | ||
38 | #include <linux/media.h> | 39 | #include <linux/media.h> |
39 | 40 | ||
40 | int main(int argc, char **argv) | 41 | int main(int argc, char **argv) |
41 | { | 42 | { |
42 | int opt; | 43 | int opt; |
43 | char media_device[256]; | 44 | char media_device[256]; |
44 | int count = 0; | 45 | int count; |
45 | struct media_device_info mdi; | 46 | struct media_device_info mdi; |
46 | int ret; | 47 | int ret; |
47 | int fd; | 48 | int fd; |
@@ -69,6 +70,10 @@ int main(int argc, char **argv) | |||
69 | exit(-1); | 70 | exit(-1); |
70 | } | 71 | } |
71 | 72 | ||
73 | /* Generate random number of interations */ | ||
74 | srand((unsigned int) time(NULL)); | ||
75 | count = rand(); | ||
76 | |||
72 | /* Open Media device and keep it open */ | 77 | /* Open Media device and keep it open */ |
73 | fd = open(media_device, O_RDWR); | 78 | fd = open(media_device, O_RDWR); |
74 | if (fd == -1) { | 79 | if (fd == -1) { |
@@ -82,14 +87,16 @@ int main(int argc, char **argv) | |||
82 | "other Oops in the dmesg. Enable KaSan kernel\n" | 87 | "other Oops in the dmesg. Enable KaSan kernel\n" |
83 | "config option for use-after-free error detection.\n\n"); | 88 | "config option for use-after-free error detection.\n\n"); |
84 | 89 | ||
85 | while (count < 100) { | 90 | printf("Running test for %d iternations\n", count); |
91 | |||
92 | while (count > 0) { | ||
86 | ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi); | 93 | ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi); |
87 | if (ret < 0) | 94 | if (ret < 0) |
88 | printf("Media Device Info errno %s\n", strerror(errno)); | 95 | printf("Media Device Info errno %s\n", strerror(errno)); |
89 | else | 96 | else |
90 | printf("Media device model %s driver %s\n", | 97 | printf("Media device model %s driver %s - count %d\n", |
91 | mdi.model, mdi.driver); | 98 | mdi.model, mdi.driver, count); |
92 | sleep(10); | 99 | sleep(10); |
93 | count++; | 100 | count--; |
94 | } | 101 | } |
95 | } | 102 | } |