From 23048745c9b8611a4e2e24c2b7ba01e103d8cf53 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 10 Nov 2010 15:35:17 -0600 Subject: [PATCH] afscp: Add -s option Add an -s option to afscp, to specify an amount of time to sleep in the middle of a read or write operation. This can be helpful in simulating a slow client. Reviewed-on: http://gerrit.openafs.org/3291 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 00023f168e0e097c6a7e9da4450a009e4818a1a5) Change-Id: Ifefce12d7372f9f8fe7149b91af0d0a7f128cb96 Reviewed-on: http://gerrit.openafs.org/9416 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/tests/afscp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/tests/afscp.c b/src/tests/afscp.c index fc5194b07..08b4d6573 100644 --- a/src/tests/afscp.c +++ b/src/tests/afscp.c @@ -218,6 +218,7 @@ main(int argc, char **argv) int code = 0, fetchcode, storecode, printcallerrs = 0; int slcl = 0, dlcl = 0, unlock = 0; int sfd = 0, dfd = 0, unauth = 0; + int sleeptime = 0; struct AFSCBFids theFids; struct AFSCBs theCBs; @@ -225,7 +226,7 @@ main(int argc, char **argv) blksize = 8 * 1024; - while ((ch = getopt(argc, argv, "iouUb:")) != -1) { + while ((ch = getopt(argc, argv, "iouUb:s:")) != -1) { switch (ch) { case 'b': blksize = atoi(optarg); @@ -236,6 +237,9 @@ main(int argc, char **argv) case 'o': dlcl = 1; break; + case 's': + sleeptime = atoi(optarg); + break; case 'u': unauth = 1; break; @@ -251,10 +255,11 @@ main(int argc, char **argv) if (argc - optind + unlock < 2) { fprintf(stderr, - "Usage: afscp [-i|-o]] [-b xfersz] [-u] [-U] source [dest]\n"); + "Usage: afscp [-i|-o]] [-b xfersz] [-s time] [-u] [-U] source [dest]\n"); fprintf(stderr, " -b Set block size\n"); fprintf(stderr, " -i Source is local (copy into AFS)\n"); fprintf(stderr, " -o Dest is local (copy out of AFS)\n"); + fprintf(stderr, " -s Set the seconds to sleep before reading/writing data\n"); fprintf(stderr, " -u Run unauthenticated\n"); fprintf(stderr, " -U Send an unlock request for source. (dest path not required)\n"); fprintf(stderr, "source and dest can be paths or specified as:\n"); @@ -479,6 +484,14 @@ main(int argc, char **argv) bytesremaining = ntohl(bytesremaining); } + if (sleeptime > 0) { +#ifdef AFS_PTHREAD_ENV + sleep(sleeptime); +#else + IOMGR_Sleep(sleeptime); +#endif + } + while (bytesremaining > 0) { /*printf("%d bytes remaining\n",bytesremaining); */ if (slcl) { -- 2.39.5