Skip to contentSkip to conversation

xfstests: fix src/seek_sanity_test -t option

PATCH Superseded Eric Sandeen 4 participants 5 messages May 24, 2013 – May 28, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: fix src/seek_sanity_test -t option

_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.

---

src/seek_sanity_test.c +6 -4
index 4275a84..f957178 100644
@@ -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;
-	}
#1 lore raw

PATCH v2 1/1 xfstests: fix src/seek_sanity_test -t option

_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.

---

V2: saner test for too many args

src/seek_sanity_test.c +6 -4
index 4275a84..f957178 100644
@@ -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;
-	}
Reviewed-by on v2 1/1
#2 lore raw
Quoted 58 lines · Eric Sandeen

_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.

---

V2: saner test for too many args

src/seek_sanity_test.c +7 -8
index 4275a84..f957178 100644
@@ -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]);

src/seek_sanity_test.c int main(int argc, char **argv) · line 689

Quoted 10 lines
src/seek_sanity_test.c +4 -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.

Thanks,
-Jeff

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v2 1/1
#3 lore raw
In reply to Eric Sandeen
Quoted 11 lines · Eric Sandeen

_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.

Quoted 7 lines

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.

Sorry, my apologies. I made a mistake when I rebased the patch. Thanks for fixing it.

- Zheng

Quoted 53 lines

---

V2: saner test for too many args

src/seek_sanity_test.c +11 -8
index 4275a84..f957178 100644
@@ -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();
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
In reply to Eric Sandeen
Quoted 11 lines · Eric Sandeen

_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.

Quoted 7 lines

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.

Thanks, this has been committed:

commit bd13bf9e2a87a40d3aab2644967029b854ed2d11

Author: Eric Sandeen <[email protected]>
Date:   Tue May 28 10:37:39 2013 -0500

xfstests: fix src/seek_sanity_test -t option

--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs