Patchwork [V2] xfstests: fix src/seek_sanity_test -t option

login
register
mail settings
Submitter Eric Sandeen
Date May 24, 2013, 5:14 a.m.
Message ID <519EF740.1000907@redhat.com>
Download mbox | patch
Permalink /patch/246056/
State Not Applicable
Headers show

Comments

Eric Sandeen - May 24, 2013, 5:14 a.m.
_require_seek_data_hole() does not work because
the -t (test) option of seek_sanity_test is broken,
because of an early check for (argc != 2):

# src/seek_sanity_test -t foo
Usage: src/seek_sanity_test base_file_path

So _require_seek_data_hole() doesn't see the
"Kernel does not support" string it's looking for,
and passes the check.

So rather than _notrun-ing the test, it proceeds to
fail with noisy errors.

Fix that, make a common usage() function, and check for
too many args as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: saner test for too many args




--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
jeff.liu - May 24, 2013, 6:54 a.m.
On 05/24/2013 01:14 PM, Eric Sandeen wrote:
> _require_seek_data_hole() does not work because
> the -t (test) option of seek_sanity_test is broken,
> because of an early check for (argc != 2):
> 
> # src/seek_sanity_test -t foo
> Usage: src/seek_sanity_test base_file_path
> 
> So _require_seek_data_hole() doesn't see the
> "Kernel does not support" string it's looking for,
> and passes the check.
> 
> So rather than _notrun-ing the test, it proceeds to
> fail with noisy errors.
> 
> Fix that, make a common usage() function, and check for
> too many args as well.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> V2: saner test for too many args
> 
> diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> index 4275a84..f957178 100644
> --- a/src/seek_sanity_test.c
> +++ b/src/seek_sanity_test.c
> @@ -656,6 +656,12 @@ out:
>  	return ret;
>  }
>  
> +void usage(char *cmd)
> +{
> +	fprintf(stdout, "Usage: %s [-t] base_file_path\n", cmd);
> +	exit(1);
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	int ret = -1;
> @@ -664,23 +670,20 @@ int main(int argc, char **argv)
>  	int check_support = 0;
>  	int numtests = sizeof(seek_tests) / sizeof(struct testrec);
>  
> -	if (argc != 2) {
> -		fprintf(stdout, "Usage: %s base_file_path\n", argv[0]);
> -		return ret;
> -	}
> -
>  	while ((opt = getopt(argc, argv, "t")) != -1) {
>  		switch (opt) {
>  		case 't':
>  			check_support++;
>  			break;
>  		default:
> -			fprintf(stderr, "Usage: %s [-t] base_file_path\n",
> -				argv[0]);
> -			return ret;
> +			usage(argv[0]);
>  		}
>  	}
>  
> +	/* should be exactly one arg left, the filename */
> +	if (optind != argc - 1)
> +		usage(argv[0]);
> +
>  	base_file_path = (char *)strdup(argv[optind]);
>  
>  	ret = test_basic_support();

This looks good to me.

Reviewed-by: Jie Liu <jeff.liu@oracle.com>

Thanks,
-Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zheng Liu - May 24, 2013, 8:02 a.m.
On Fri, May 24, 2013 at 12:14:40AM -0500, Eric Sandeen wrote:
> _require_seek_data_hole() does not work because
> the -t (test) option of seek_sanity_test is broken,
> because of an early check for (argc != 2):
> 
> # src/seek_sanity_test -t foo
> Usage: src/seek_sanity_test base_file_path
> 
> So _require_seek_data_hole() doesn't see the
> "Kernel does not support" string it's looking for,
> and passes the check.
> 
> So rather than _notrun-ing the test, it proceeds to
> fail with noisy errors.
> 
> Fix that, make a common usage() function, and check for
> too many args as well.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Sorry, my apologies.  I made a mistake when I rebased the patch.  Thanks
for fixing it.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>

                                                - Zheng

> ---
> 
> V2: saner test for too many args
> 
> diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> index 4275a84..f957178 100644
> --- a/src/seek_sanity_test.c
> +++ b/src/seek_sanity_test.c
> @@ -656,6 +656,12 @@ out:
>  	return ret;
>  }
>  
> +void usage(char *cmd)
> +{
> +	fprintf(stdout, "Usage: %s [-t] base_file_path\n", cmd);
> +	exit(1);
> +}
> +
>  int main(int argc, char **argv)
>  {
>  	int ret = -1;
> @@ -664,23 +670,20 @@ int main(int argc, char **argv)
>  	int check_support = 0;
>  	int numtests = sizeof(seek_tests) / sizeof(struct testrec);
>  
> -	if (argc != 2) {
> -		fprintf(stdout, "Usage: %s base_file_path\n", argv[0]);
> -		return ret;
> -	}
> -
>  	while ((opt = getopt(argc, argv, "t")) != -1) {
>  		switch (opt) {
>  		case 't':
>  			check_support++;
>  			break;
>  		default:
> -			fprintf(stderr, "Usage: %s [-t] base_file_path\n",
> -				argv[0]);
> -			return ret;
> +			usage(argv[0]);
>  		}
>  	}
>  
> +	/* should be exactly one arg left, the filename */
> +	if (optind != argc - 1)
> +		usage(argv[0]);
> +
>  	base_file_path = (char *)strdup(argv[optind]);
>  
>  	ret = test_basic_support();
> 
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 4275a84..f957178 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -656,6 +656,12 @@  out:
 	return ret;
 }
 
+void usage(char *cmd)
+{
+	fprintf(stdout, "Usage: %s [-t] base_file_path\n", cmd);
+	exit(1);
+}
+
 int main(int argc, char **argv)
 {
 	int ret = -1;
@@ -664,23 +670,20 @@  int main(int argc, char **argv)
 	int check_support = 0;
 	int numtests = sizeof(seek_tests) / sizeof(struct testrec);
 
-	if (argc != 2) {
-		fprintf(stdout, "Usage: %s base_file_path\n", argv[0]);
-		return ret;
-	}
-
 	while ((opt = getopt(argc, argv, "t")) != -1) {
 		switch (opt) {
 		case 't':
 			check_support++;
 			break;
 		default:
-			fprintf(stderr, "Usage: %s [-t] base_file_path\n",
-				argv[0]);
-			return ret;
+			usage(argv[0]);
 		}
 	}
 
+	/* should be exactly one arg left, the filename */
+	if (optind != argc - 1)
+		usage(argv[0]);
+
 	base_file_path = (char *)strdup(argv[optind]);
 
 	ret = test_basic_support();