diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-11-02 15:13:54 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-18 11:23:09 -0500 |
| commit | a57419b366a20009c9363c3cdad2449dc2fa8b9c (patch) | |
| tree | f91037997c9d7ca0ca3a2b2ec7a0804eab8eb754 /tools/testing | |
| parent | 576f627c817dff0b7081374287a77247325b9cc0 (diff) | |
ktest: New TEST_START instead of using [], and use real SHA1s
Change the config to use TEST_START where the options after a
TEST_START automatically get the [] as it is read and they do
not need to exist in the config file;
TEST_START
MIN_CONFIG = myconfig
is the same as
MIN_CONFIG[1] = myconfig
The benefit is that you no longer need to keep track of test numbers
with tests.
Also process the commit ids that are passed to the options
to get the actually SHA1 so it is no longer relative to the branch.
Ie, saying HEAD will get the current SHA1 and then that will
be used, and will work even if another branch is checked out.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/ktest/ktest.pl | 206 | ||||
| -rw-r--r-- | tools/testing/ktest/sample.conf | 345 |
2 files changed, 433 insertions, 118 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index ef978171ecb7..a7e86e391172 100644 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -11,21 +11,23 @@ use File::Path qw(mkpath); | |||
| 11 | use File::Copy qw(cp); | 11 | use File::Copy qw(cp); |
| 12 | use FileHandle; | 12 | use FileHandle; |
| 13 | 13 | ||
| 14 | $#ARGV >= 0 || die "usage: autotest.pl config-file\n"; | 14 | $#ARGV >= 0 || die "usage: ktest.pl config-file\n"; |
| 15 | 15 | ||
| 16 | $| = 1; | 16 | $| = 1; |
| 17 | 17 | ||
| 18 | my %opt; | 18 | my %opt; |
| 19 | my %repeat_tests; | ||
| 20 | my %repeats; | ||
| 19 | my %default; | 21 | my %default; |
| 20 | 22 | ||
| 21 | #default opts | 23 | #default opts |
| 22 | $default{"NUM_TESTS"} = 5; | 24 | $default{"NUM_TESTS"} = 1; |
| 23 | $default{"REBOOT_TYPE"} = "grub"; | 25 | $default{"REBOOT_TYPE"} = "grub"; |
| 24 | $default{"TEST_TYPE"} = "test"; | 26 | $default{"TEST_TYPE"} = "test"; |
| 25 | $default{"BUILD_TYPE"} = "randconfig"; | 27 | $default{"BUILD_TYPE"} = "randconfig"; |
| 26 | $default{"MAKE_CMD"} = "make"; | 28 | $default{"MAKE_CMD"} = "make"; |
| 27 | $default{"TIMEOUT"} = 120; | 29 | $default{"TIMEOUT"} = 120; |
| 28 | $default{"TMP_DIR"} = "/tmp/autotest"; | 30 | $default{"TMP_DIR"} = "/tmp/ktest"; |
| 29 | $default{"SLEEP_TIME"} = 60; # sleep time between tests | 31 | $default{"SLEEP_TIME"} = 60; # sleep time between tests |
| 30 | $default{"BUILD_NOCLEAN"} = 0; | 32 | $default{"BUILD_NOCLEAN"} = 0; |
| 31 | $default{"REBOOT_ON_ERROR"} = 0; | 33 | $default{"REBOOT_ON_ERROR"} = 0; |
| @@ -87,29 +89,138 @@ my $target_image; | |||
| 87 | my $localversion; | 89 | my $localversion; |
| 88 | my $iteration = 0; | 90 | my $iteration = 0; |
| 89 | 91 | ||
| 92 | sub set_value { | ||
| 93 | my ($lvalue, $rvalue) = @_; | ||
| 94 | |||
| 95 | if (defined($opt{$lvalue})) { | ||
| 96 | die "Error: Option $lvalue defined more than once!\n"; | ||
| 97 | } | ||
| 98 | $opt{$lvalue} = $rvalue; | ||
| 99 | } | ||
| 100 | |||
| 90 | sub read_config { | 101 | sub read_config { |
| 91 | my ($config) = @_; | 102 | my ($config) = @_; |
| 92 | 103 | ||
| 93 | open(IN, $config) || die "can't read file $config"; | 104 | open(IN, $config) || die "can't read file $config"; |
| 94 | 105 | ||
| 106 | my $name = $config; | ||
| 107 | $name =~ s,.*/(.*),$1,; | ||
| 108 | |||
| 109 | my $test_num = 0; | ||
| 110 | my $default = 1; | ||
| 111 | my $repeat = 1; | ||
| 112 | my $num_tests_set = 0; | ||
| 113 | my $skip = 0; | ||
| 114 | my $rest; | ||
| 115 | |||
| 95 | while (<IN>) { | 116 | while (<IN>) { |
| 96 | 117 | ||
| 97 | # ignore blank lines and comments | 118 | # ignore blank lines and comments |
| 98 | next if (/^\s*$/ || /\s*\#/); | 119 | next if (/^\s*$/ || /\s*\#/); |
| 99 | 120 | ||
| 100 | if (/^\s*(\S+)\s*=\s*(.*?)\s*$/) { | 121 | if (/^\s*TEST_START(.*)/) { |
| 122 | |||
| 123 | $rest = $1; | ||
| 124 | |||
| 125 | if ($num_tests_set) { | ||
| 126 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; | ||
| 127 | } | ||
| 128 | |||
| 129 | my $old_test_num = $test_num; | ||
| 130 | |||
| 131 | $test_num += $repeat; | ||
| 132 | $default = 0; | ||
| 133 | $repeat = 1; | ||
| 134 | |||
| 135 | if ($rest =~ /\s+SKIP(.*)/) { | ||
| 136 | $rest = $1; | ||
| 137 | $skip = 1; | ||
| 138 | } else { | ||
| 139 | $skip = 0; | ||
| 140 | } | ||
| 141 | |||
| 142 | if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) { | ||
| 143 | $repeat = $1; | ||
| 144 | $rest = $2; | ||
| 145 | $repeat_tests{"$test_num"} = $repeat; | ||
| 146 | } | ||
| 147 | |||
| 148 | if ($rest =~ /\s+SKIP(.*)/) { | ||
| 149 | $rest = $1; | ||
| 150 | $skip = 1; | ||
| 151 | } | ||
| 152 | |||
| 153 | if ($rest !~ /^\s*$/) { | ||
| 154 | die "$name: $.: Gargbage found after TEST_START\n$_"; | ||
| 155 | } | ||
| 156 | |||
| 157 | if ($skip) { | ||
| 158 | $test_num = $old_test_num; | ||
| 159 | $repeat = 1; | ||
| 160 | } | ||
| 161 | |||
| 162 | } elsif (/^\s*DEFAULTS(.*)$/) { | ||
| 163 | $default = 1; | ||
| 164 | |||
| 165 | $rest = $1; | ||
| 166 | |||
| 167 | if ($rest =~ /\s+SKIP(.*)/) { | ||
| 168 | $rest = $1; | ||
| 169 | $skip = 1; | ||
| 170 | } else { | ||
| 171 | $skip = 0; | ||
| 172 | } | ||
| 173 | |||
| 174 | if ($rest !~ /^\s*$/) { | ||
| 175 | die "$name: $.: Gargbage found after DEFAULTS\n$_"; | ||
| 176 | } | ||
| 177 | |||
| 178 | } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) { | ||
| 179 | |||
| 180 | next if ($skip); | ||
| 181 | |||
| 101 | my $lvalue = $1; | 182 | my $lvalue = $1; |
| 102 | my $rvalue = $2; | 183 | my $rvalue = $2; |
| 103 | 184 | ||
| 104 | if (defined($opt{$lvalue})) { | 185 | if (!$default && |
| 105 | die "Error: Option $lvalue defined more than once!\n"; | 186 | ($lvalue eq "NUM_TESTS" || |
| 187 | $lvalue eq "LOG_FILE" || | ||
| 188 | $lvalue eq "CLEAR_LOG")) { | ||
| 189 | die "$name: $.: $lvalue must be set in DEFAULTS section\n"; | ||
| 190 | } | ||
| 191 | |||
| 192 | if ($lvalue eq "NUM_TESTS") { | ||
| 193 | if ($test_num) { | ||
| 194 | die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n"; | ||
| 195 | } | ||
| 196 | if (!$default) { | ||
| 197 | die "$name: $.: NUM_TESTS must be set in default section\n"; | ||
| 198 | } | ||
| 199 | $num_tests_set = 1; | ||
| 200 | } | ||
| 201 | |||
| 202 | if ($default || $lvalue =~ /\[\d+\]$/) { | ||
| 203 | set_value($lvalue, $rvalue); | ||
| 204 | } else { | ||
| 205 | my $val = "$lvalue\[$test_num\]"; | ||
| 206 | set_value($val, $rvalue); | ||
| 207 | |||
| 208 | if ($repeat > 1) { | ||
| 209 | $repeats{$val} = $repeat; | ||
| 210 | } | ||
| 106 | } | 211 | } |
| 107 | $opt{$lvalue} = $rvalue; | 212 | } else { |
| 213 | die "$name: $.: Garbage found in config\n$_"; | ||
| 108 | } | 214 | } |
| 109 | } | 215 | } |
| 110 | 216 | ||
| 111 | close(IN); | 217 | close(IN); |
| 112 | 218 | ||
| 219 | if ($test_num) { | ||
| 220 | $test_num += $repeat - 1; | ||
| 221 | $opt{"NUM_TESTS"} = $test_num; | ||
| 222 | } | ||
| 223 | |||
| 113 | # set any defaults | 224 | # set any defaults |
| 114 | 225 | ||
| 115 | foreach my $default (keys %default) { | 226 | foreach my $default (keys %default) { |
| @@ -398,6 +509,27 @@ sub reboot_to { | |||
| 398 | run_command "$reboot_script"; | 509 | run_command "$reboot_script"; |
| 399 | } | 510 | } |
| 400 | |||
