]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afscp: Add -s option
authorAndrew Deason <adeason@sinenomine.net>
Wed, 10 Nov 2010 21:35:17 +0000 (15:35 -0600)
committerStephan Wiesand <stephan.wiesand@desy.de>
Tue, 20 Aug 2013 22:26:01 +0000 (15:26 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 00023f168e0e097c6a7e9da4450a009e4818a1a5)

Change-Id: Ifefce12d7372f9f8fe7149b91af0d0a7f128cb96
Reviewed-on: http://gerrit.openafs.org/9416
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/tests/afscp.c

index fc5194b07c99bd294b6bbabe90fed6ce1c2b4726..08b4d65732072074d7c16eb7520bcb34c62c3baf 100644 (file)
@@ -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) {