diff options
author | marcel <marcel@FreeBSD.org> | 2005-09-19 06:51:57 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2005-09-19 06:51:57 +0000 |
commit | d94a6a6215e73e7d38d961419dd075d70e9ed70d (patch) | |
tree | 49b8379eeccfc18dce34f7d08a3f0477058da962 /tools | |
parent | e4930c9f7b08966fb21684ecaa7030fce17409f3 (diff) | |
download | FreeBSD-src-d94a6a6215e73e7d38d961419dd075d70e9ed70d.zip FreeBSD-src-d94a6a6215e73e7d38d961419dd075d70e9ed70d.tar.gz |
o Extend the suite to run more than just the driver. We need to run
mdconfig(8), because we need a disk to work on.
o Extend the number of tests now that we have a disk.
o Simplify the driver. All parameters are ASCII strings now.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/geom_gpt/gctl.t | 95 | ||||
-rw-r--r-- | tools/regression/geom_gpt/test.c | 52 |
2 files changed, 75 insertions, 72 deletions
diff --git a/tools/regression/geom_gpt/gctl.t b/tools/regression/geom_gpt/gctl.t index 15335a0..c369026 100644 --- a/tools/regression/geom_gpt/gctl.t +++ b/tools/regression/geom_gpt/gctl.t @@ -29,35 +29,50 @@ my $srcdir = `dirname $0`; chomp $srcdir; -my $cmd = "/tmp/$$"; +my $cmd = "/tmp/gctl-$$"; my $out = "$cmd.out"; +my $disk = "/tmp/disk-$$"; +my $unit = ""; -my %tests = ( - "" => "FAIL Verb missing", - "-s verb=invalid" => "FAIL 22 verb 'invalid'", - # create - "-s verb=create" => "FAIL 87 provider", - "-s verb=create -s provider=invalid" => "FAIL 22 provider 'invalid'", +my %steps = ( + "1" => "gctl", + "2" => "gctl", + "3" => "gctl", + "4" => "gctl", + "5" => "mdcfg", + "6" => "gctl", + "7" => "gctl", + "8" => "gctl", + "9" => "mdcfg", ); -sub run ($$) { - local ($nr, $test) = @_; - local $st; +my %args = ( + "1" => "", + "2" => "verb=invalid", + "3" => "verb=create", + "4" => "verb=create provider=invalid", + "5" => "create", + "6" => "verb=create provider=md%unit% entries=-1", + "7" => "verb=create provider=md%unit%", + "8" => "verb=create provider=md%unit%", + "9" => "destroy", +); - if (exists $ENV{'TEST_VERBOSE'}) { - system("$cmd -v $test > $out 2>&1"); - system("cat $out"); - } - else { - system("$cmd $test > $out 2>&1"); - } - $st = `tail -1 $out`; - if ($st =~ "^$tests{$test}") { - print "ok $nr\n"; - } else { - print "not ok $nr # $st\n"; - } - unlink $out; +my %result = ( + "1" => "FAIL Verb missing", + "2" => "FAIL 22 verb 'invalid'", + "3" => "FAIL 87 provider", + "4" => "FAIL 22 provider 'invalid'", + # + "6" => "FAIL 22 entries -1", + "7" => "PASS", + "8" => "FAIL 17 geom 'md0'", + # +); + +my $verbose = ""; +if (exists $ENV{'TEST_VERBOSE'}) { + $verbose = "-v"; } # Compile the driver... @@ -74,12 +89,36 @@ if (`$cmd` =~ "^FAIL Permission denied") { exit 0; } -$count = keys (%tests); +$count = keys (%steps); print "1..$count\n"; -my $nr=0; -foreach $test (keys %tests) { - run ++$nr, $test; +foreach my $nr (sort keys %steps) { + my $action = $steps{$nr}; + my $arg = $args{$nr}; + + if ($action =~ "gctl") { + $arg =~ s/%unit%/$unit/g; + system("$cmd $verbose $arg | tee $out 2>&1"); + $st = `tail -1 $out`; + if ($st =~ "^$result{$nr}") { + print "ok $nr\n"; + } else { + print "not ok $nr \# $st\n"; + } + unlink $out; + } elsif ($action =~ "mdcfg") { + if ($arg =~ "create") { + system("dd if=/dev/zero of=$disk count=1024 2>&1"); + $unit = `mdconfig -a -t vnode -f $disk`; + chomp $unit; + $unit =~ s/md//g; + } elsif ($arg =~ "destroy") { + system("mdconfig -d -u $unit"); + unlink $disk; + $unit = ""; + } + print "ok $nr\n"; + } } unlink $cmd; diff --git a/tools/regression/geom_gpt/test.c b/tools/regression/geom_gpt/test.c index 4b092d5..0cb0b30 100644 --- a/tools/regression/geom_gpt/test.c +++ b/tools/regression/geom_gpt/test.c @@ -59,58 +59,18 @@ parse(char *arg, char **param, char **value) return (0); } -static int -add_int32(struct gctl_req *req, char *arg) -{ - char *param, *nptr, *endptr; - uint32_t value; - int error; - - error = parse(arg, ¶m, &nptr); - if (error) - return (error); - if (nptr == NULL) - return (EINVAL); - value = strtol(nptr, &endptr, 0); - if (*endptr) - return (EINVAL); - gctl_ro_param(req, param, sizeof(value), &value); - return (0); -} - -static int -add_string(struct gctl_req *req, char *arg) -{ - char *param, *value; - int error; - - error = parse(arg, ¶m, &value); - if (error) - return (error); - if (value == NULL) - return (EINVAL); - - gctl_ro_param(req, param, -1, value); - return (0); -} - int main(int argc, char *argv[]) { struct gctl_req *req; + char *param, *value; const char *s; int c; req = gctl_get_handle(); gctl_ro_param(req, "class", -1, "GPT"); - while ((c = getopt(argc, argv, "4:s:v")) != -1) { + while ((c = getopt(argc, argv, "v")) != -1) { switch (c) { - case '4': /* uint32_t */ - add_int32(req, optarg); - break; - case 's': /* string */ - add_string(req, optarg); - break; case 'v': verbose = 1; break; @@ -121,8 +81,12 @@ int main(int argc, char *argv[]) break; } } - if (argc != optind) - usage(); + + while (optind < argc) { + parse(argv[optind++], ¶m, &value); + if (value != NULL) + gctl_ro_param(req, param, -1, value); + } if (verbose) gctl_dump(req, stdout); |