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

selftests/txtimestamp: Add more configurable parameters

Add a way to configure if poll() should wait forever for an event, the
number of packets that should be sent for each and if there should be
any delay between packets.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vinicius Costa Gomes and committed by
David S. Miller
5dce8379 5eb297a9

+18 -3
+18 -3
tools/testing/selftests/networking/timestamping/txtimestamp.c
··· 68 68 static int do_ipv4 = 1; 69 69 static int do_ipv6 = 1; 70 70 static int cfg_payload_len = 10; 71 + static int cfg_poll_timeout = 100; 71 72 static bool cfg_show_payload; 72 73 static bool cfg_do_pktinfo; 73 74 static bool cfg_loop_nodata; 75 + static bool cfg_no_delay; 74 76 static uint16_t dest_port = 9000; 75 77 76 78 static struct sockaddr_in daddr; ··· 173 171 174 172 memset(&pollfd, 0, sizeof(pollfd)); 175 173 pollfd.fd = fd; 176 - ret = poll(&pollfd, 1, 100); 174 + ret = poll(&pollfd, 1, cfg_poll_timeout); 177 175 if (ret != 1) 178 176 error(1, errno, "poll"); 179 177 } ··· 373 371 error(1, errno, "send"); 374 372 375 373 /* wait for all errors to be queued, else ACKs arrive OOO */ 376 - usleep(50 * 1000); 374 + if (!cfg_no_delay) 375 + usleep(50 * 1000); 377 376 378 377 __poll(fd); 379 378 ··· 395 392 " -4: only IPv4\n" 396 393 " -6: only IPv6\n" 397 394 " -h: show this message\n" 395 + " -c N: number of packets for each test\n" 396 + " -D: no delay between packets\n" 397 + " -F: poll() waits forever for an event\n" 398 398 " -I: request PKTINFO\n" 399 399 " -l N: send N bytes at a time\n" 400 400 " -n: set no-payload option\n" ··· 415 409 int proto_count = 0; 416 410 char c; 417 411 418 - while ((c = getopt(argc, argv, "46hIl:np:rRux")) != -1) { 412 + while ((c = getopt(argc, argv, "46c:DFhIl:np:rRux")) != -1) { 419 413 switch (c) { 420 414 case '4': 421 415 do_ipv6 = 0; 422 416 break; 423 417 case '6': 424 418 do_ipv4 = 0; 419 + break; 420 + case 'c': 421 + cfg_num_pkts = strtoul(optarg, NULL, 10); 422 + break; 423 + case 'D': 424 + cfg_no_delay = true; 425 + break; 426 + case 'F': 427 + cfg_poll_timeout = -1; 425 428 break; 426 429 case 'I': 427 430 cfg_do_pktinfo = true;