diff --git a/gpAux/extensions/gps3ext/bin/gpcheckcloud/gpcheckcloud.cpp b/gpAux/extensions/gps3ext/bin/gpcheckcloud/gpcheckcloud.cpp index 5a7f27d07285dc0db702b7ddcc85fb88b5aa2e88..2f69ff84bf10c707569e5f04c60cb57937b81bb4 100644 --- a/gpAux/extensions/gps3ext/bin/gpcheckcloud/gpcheckcloud.cpp +++ b/gpAux/extensions/gps3ext/bin/gpcheckcloud/gpcheckcloud.cpp @@ -16,8 +16,8 @@ void printUsage(FILE *stream) { "config=path_to_config_file\", to check the configuration.\n" " gpcheckcloud -d \"s3://endpoint/bucket/prefix " "config=path_to_config_file\", to download and output to stdout.\n" - " gpcheckcloud -u \"s3://endpoint/bucket/prefix " - "config=path_to_config_file\" -f \"/path/to/file\", to upload a file to S3.\n" + " gpcheckcloud -u \"/path/to/file\" \"s3://endpoint/bucket/prefix " + "config=path_to_config_file\", to upload a file to S3.\n" " gpcheckcloud -t, to show the config template.\n" " gpcheckcloud -h, to show this help.\n"); } @@ -27,18 +27,16 @@ map parseCommandLineArgs(int argc, char *argv[]) { int opt = 0; map optionPairs; - while ((opt = getopt(argc, argv, "c:d:u:f:ht")) != -1) { + while ((opt = getopt(argc, argv, "c:d:u:ht")) != -1) { switch (opt) { case 'c': case 'd': - case 'u': - case 'f': case 'h': case 't': if (optarg == NULL) { optionPairs[opt] = ""; } else if (optarg[0] == '-') { - fprintf(stderr, "Failed. Invalid argument for -%c: '%s'\n\n", opt, optarg); + fprintf(stderr, "Failed. Invalid argument for -%c: '%s'.\n\n", opt, optarg); printUsage(stderr); exit(EXIT_FAILURE); } else { @@ -46,6 +44,19 @@ map parseCommandLineArgs(int argc, char *argv[]) { } break; + case 'u': + if (optarg == NULL) { + optionPairs[opt] = ""; + } else if (optind + 1 == argc) { + optionPairs['f'] = optarg; + optionPairs['u'] = argv[optind]; + } else { + fprintf(stderr, "Failed. Invalid arguments for -u, please check.\n\n"); + printUsage(stderr); + exit(EXIT_FAILURE); + } + break; + default: // '?' printUsage(stderr); exit(EXIT_FAILURE); @@ -62,7 +73,7 @@ void validateCommandLineArgs(map &optionPairs) { if ((count == 2) && (optionPairs.size() == 2)) { return; } else if (count == 1) { - fprintf(stderr, "Failed. Option \'-u\' must work with \'-f\'\n\n"); + fprintf(stderr, "Failed. Option \'-u\' must work with \'-f\'.\n\n"); printUsage(stderr); exit(EXIT_FAILURE); } diff --git a/gpAux/extensions/gps3ext/regress/gpcheckcloud_regress.sh b/gpAux/extensions/gps3ext/regress/gpcheckcloud_regress.sh index 72bd7de62cc55a68fc66859d8109878d0990e24d..bf18c4954cc9d2ae73af2ab0a5b1a8d5695e3047 100755 --- a/gpAux/extensions/gps3ext/regress/gpcheckcloud_regress.sh +++ b/gpAux/extensions/gps3ext/regress/gpcheckcloud_regress.sh @@ -12,8 +12,8 @@ MD5SUM_SMALL=`cat /tmp/gpcheckcloud.small |openssl md5 |cut -d ' ' -f 2` MD5SUM_LARGE=`cat /tmp/gpcheckcloud.large |openssl md5 |cut -d ' ' -f 2` echo "Uploading data..." -$GPCHECKCLOUD -u "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/small/ config=/home/gpadmin/s3.conf" -f /tmp/gpcheckcloud.small -$GPCHECKCLOUD -u "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/large/ config=/home/gpadmin/s3.conf" -f /tmp/gpcheckcloud.large +$GPCHECKCLOUD -u /tmp/gpcheckcloud.small "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/small/ config=/home/gpadmin/s3.conf" +$GPCHECKCLOUD -u /tmp/gpcheckcloud.large "s3://s3-us-west-2.amazonaws.com/s3test.pivotal.io/regress/s3write/$RANDOM_PREFIX/large/ config=/home/gpadmin/s3.conf" echo "Downloading and checking hashsum..." CHECK_CASES=(