Skip to content

Commit 0276fe9

Browse files
wedsonafSven Van Asbroeck
authored andcommitted
binder: test: Allow number of iterations to be specified.
1 parent c53984e commit 0276fe9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/testing/selftests/binder/ping_client.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <stdio.h>
2+
#include <stdlib.h>
23
#include <stdint.h>
34
#include <string.h>
45
#include <stdalign.h>
@@ -52,14 +53,18 @@ static size_t handle_read(int fd, struct binder_write_read *b)
5253
int main(int argc, char **argv)
5354
{
5455
int ret;
55-
size_t i;
5656
struct timespec begin, end;
57+
uint64_t iters = 1000000;
5758

58-
if (argc != 2) {
59-
fprintf(stderr, "Usage: %s <binder-file-name>\n", argv[0]);
59+
if (argc != 2 && argc != 3) {
60+
fprintf(stderr, "Usage: %s <binder-file-name> [iters]\n",
61+
argv[0]);
6062
return 1;
6163
}
6264

65+
if (argc >= 3)
66+
iters = strtoull(argv[2], NULL, 10);
67+
6368
int fd = open(argv[1], O_RDWR);
6469
if (fd == -1) {
6570
perror("open");
@@ -100,7 +105,7 @@ int main(int argc, char **argv)
100105
to_write.addr = handle_read(fd, &b);
101106

102107
clock_gettime(CLOCK_MONOTONIC, &begin);
103-
for (i = 0; i < 1000000; i++) {
108+
while (iters--) {
104109
b.read_consumed = 0;
105110
b.write_consumed = 0;
106111
ret = ioctl(fd, BINDER_WRITE_READ, &b);

0 commit comments

Comments
 (0)