Skip to content

Commit

Permalink
binder: test: Allow number of iterations to be specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
wedsonaf authored and Sven Van Asbroeck committed Jun 10, 2021
1 parent c53984e commit 0276fe9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/testing/selftests/binder/ping_client.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdalign.h>
Expand Down Expand Up @@ -52,14 +53,18 @@ static size_t handle_read(int fd, struct binder_write_read *b)
int main(int argc, char **argv)
{
int ret;
size_t i;
struct timespec begin, end;
uint64_t iters = 1000000;

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

if (argc >= 3)
iters = strtoull(argv[2], NULL, 10);

int fd = open(argv[1], O_RDWR);
if (fd == -1) {
perror("open");
Expand Down Expand Up @@ -100,7 +105,7 @@ int main(int argc, char **argv)
to_write.addr = handle_read(fd, &b);

clock_gettime(CLOCK_MONOTONIC, &begin);
for (i = 0; i < 1000000; i++) {
while (iters--) {
b.read_consumed = 0;
b.write_consumed = 0;
ret = ioctl(fd, BINDER_WRITE_READ, &b);
Expand Down

0 comments on commit 0276fe9

Please sign in to comment.