diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/ktest/examples/include/patchcheck.conf | 37 | ||||
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 110 | ||||
-rw-r--r-- | tools/testing/ktest/sample.conf | 44 |
3 files changed, 185 insertions, 6 deletions
diff --git a/tools/testing/ktest/examples/include/patchcheck.conf b/tools/testing/ktest/examples/include/patchcheck.conf index 339d3e1700ff..0eb0a5ac77da 100644 --- a/tools/testing/ktest/examples/include/patchcheck.conf +++ b/tools/testing/ktest/examples/include/patchcheck.conf | |||
@@ -14,6 +14,16 @@ | |||
14 | PATCH_START := HEAD~3 | 14 | PATCH_START := HEAD~3 |
15 | PATCH_END := HEAD | 15 | PATCH_END := HEAD |
16 | 16 | ||
17 | # Use the oldconfig if build_type wasn't defined | ||
18 | DEFAULTS IF NOT DEFINED BUILD_TYPE | ||
19 | DO_BUILD_TYPE := oldconfig | ||
20 | |||
21 | DEFAULTS ELSE | ||
22 | DO_BUILD_TYPE := ${BUILD_TYPE} | ||
23 | |||
24 | DEFAULTS | ||
25 | |||
26 | |||
17 | # Change PATCH_CHECKOUT to be the branch you want to test. The test will | 27 | # Change PATCH_CHECKOUT to be the branch you want to test. The test will |
18 | # do a git checkout of this branch before starting. Obviously both | 28 | # do a git checkout of this branch before starting. Obviously both |
19 | # PATCH_START and PATCH_END must be in this branch (and PATCH_START must | 29 | # PATCH_START and PATCH_END must be in this branch (and PATCH_START must |
@@ -43,6 +53,31 @@ PATCH_TEST_TYPE := boot | |||
43 | # (space delimited) | 53 | # (space delimited) |
44 | #IGNORE_WARNINGS = 39eaf7ef884dcc44f7ff1bac803ca2a1dcf43544 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce | 54 | #IGNORE_WARNINGS = 39eaf7ef884dcc44f7ff1bac803ca2a1dcf43544 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce |
45 | 55 | ||
56 | # Instead of just checking for warnings to files that are changed | ||
57 | # it can be advantageous to check for any new warnings. If a | ||
58 | # header file is changed, it could cause a warning in a file not | ||
59 | # touched by the commit. To detect these kinds of warnings, you | ||
60 | # can use the WARNINGS_FILE option. | ||
61 | # | ||
62 | # If the variable CREATE_WARNINGS_FILE is set, this config will | ||
63 | # enable the WARNINGS_FILE during the patchcheck test. Also, | ||
64 | # before running the patchcheck test, it will create the | ||
65 | # warnings file. | ||
66 | # | ||
67 | DEFAULTS IF DEFINED CREATE_WARNINGS_FILE | ||
68 | WARNINGS_FILE = ${OUTPUT_DIR}/warnings_file | ||
69 | |||
70 | TEST_START IF DEFINED CREATE_WARNINGS_FILE | ||
71 | # WARNINGS_FILE is already set by the DEFAULTS above | ||
72 | TEST_TYPE = make_warnings_file | ||
73 | # Checkout the commit before the patches to test, | ||
74 | # and record all the warnings that exist before the patches | ||
75 | # to test are added | ||
76 | CHECKOUT = ${PATCHCHECK_START}~1 | ||
77 | # Force a full build | ||
78 | BUILD_NOCLEAN = 0 | ||
79 | BUILD_TYPE = ${DO_BUILD_TYPE} | ||
80 | |||
46 | # If you are running a multi test, and the test failed on the first | 81 | # If you are running a multi test, and the test failed on the first |
47 | # test but on, say the 5th patch. If you want to restart on the | 82 | # test but on, say the 5th patch. If you want to restart on the |
48 | # fifth patch, set PATCH_START1. This will make the first test start | 83 | # fifth patch, set PATCH_START1. This will make the first test start |
@@ -61,6 +96,7 @@ PATCHCHECK_TYPE = ${PATCH_TEST_TYPE} | |||
61 | PATCHCHECK_START = ${PATCH_START1} | 96 | PATCHCHECK_START = ${PATCH_START1} |
62 | PATCHCHECK_END = ${PATCH_END} | 97 | PATCHCHECK_END = ${PATCH_END} |
63 | CHECKOUT = ${PATCH_CHECKOUT} | 98 | CHECKOUT = ${PATCH_CHECKOUT} |
99 | BUILD_TYPE = ${DO_BUILD_TYPE} | ||
64 | 100 | ||
65 | TEST_START IF ${TEST} == patchcheck && ${MULTI} | 101 | TEST_START IF ${TEST} == patchcheck && ${MULTI} |
66 | TEST_TYPE = patchcheck | 102 | TEST_TYPE = patchcheck |
@@ -72,3 +108,4 @@ PATCHCHECK_END = ${PATCH_END} | |||
72 | CHECKOUT = ${PATCH_CHECKOUT} | 108 | CHECKOUT = ${PATCH_CHECKOUT} |
73 | # Use multi to test different compilers? | 109 | # Use multi to test different compilers? |
74 | MAKE_CMD = CC=gcc-4.5.1 make | 110 | MAKE_CMD = CC=gcc-4.5.1 make |
111 | BUILD_TYPE = ${DO_BUILD_TYPE} | ||
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 3d19ee445249..3fd768e65998 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -126,6 +126,7 @@ my $start_minconfig_defined; | |||
126 | my $output_minconfig; | 126 | my $output_minconfig; |
127 | my $minconfig_type; | 127 | my $minconfig_type; |
128 | my $use_output_minconfig; | 128 | my $use_output_minconfig; |
129 | my $warnings_file; | ||
129 | my $ignore_config; | 130 | my $ignore_config; |
130 | my $ignore_errors; | 131 | my $ignore_errors; |
131 | my $addconfig; | 132 | my $addconfig; |
@@ -193,6 +194,9 @@ my $patchcheck_end; | |||
193 | # which would require more options. | 194 | # which would require more options. |
194 | my $buildonly = 1; | 195 | my $buildonly = 1; |
195 | 196 | ||
197 | # tell build not to worry about warnings, even when WARNINGS_FILE is set | ||
198 | my $warnings_ok = 0; | ||
199 | |||
196 | # set when creating a new config | 200 | # set when creating a new config |
197 | my $newconfig = 0; | 201 | my $newconfig = 0; |
198 | 202 | ||
@@ -235,6 +239,7 @@ my %option_map = ( | |||
235 | "START_MIN_CONFIG" => \$start_minconfig, | 239 | "START_MIN_CONFIG" => \$start_minconfig, |
236 | "MIN_CONFIG_TYPE" => \$minconfig_type, | 240 | "MIN_CONFIG_TYPE" => \$minconfig_type, |
237 | "USE_OUTPUT_MIN_CONFIG" => \$use_output_minconfig, | 241 | "USE_OUTPUT_MIN_CONFIG" => \$use_output_minconfig, |
242 | "WARNINGS_FILE" => \$warnings_file, | ||
238 | "IGNORE_CONFIG" => \$ignore_config, | 243 | "IGNORE_CONFIG" => \$ignore_config, |
239 | "TEST" => \$run_test, | 244 | "TEST" => \$run_test, |
240 | "ADD_CONFIG" => \$addconfig, | 245 | "ADD_CONFIG" => \$addconfig, |
@@ -1924,7 +1929,60 @@ sub start_monitor_and_boot { | |||
1924 | return monitor; | 1929 | return monitor; |
1925 | } | 1930 | } |
1926 | 1931 | ||
1932 | my $check_build_re = ".*:.*(warning|error|Error):.*"; | ||
1933 | my $utf8_quote = "\\x{e2}\\x{80}(\\x{98}|\\x{99})"; | ||
1934 | |||
1935 | # Read buildlog and check against warnings file for any | ||
1936 | # new warnings. | ||
1937 | # | ||
1938 | # Returns 1 if OK | ||
1939 | # 0 otherwise | ||
1927 | sub check_buildlog { | 1940 | sub check_buildlog { |
1941 | return 1 if (!defined $warnings_file); | ||
1942 | |||
1943 | my %warnings_list; | ||
1944 | |||
1945 | # Failed builds should not reboot the target | ||
1946 | my $save_no_reboot = $no_reboot; | ||
1947 | $no_reboot = 1; | ||
1948 | |||
1949 | if (-f $warnings_file) { | ||
1950 | open(IN, $warnings_file) or | ||
1951 | dodie "Error opening $warnings_file"; | ||
1952 | |||
1953 | while (<IN>) { | ||
1954 | if (/$check_build_re/) { | ||
1955 | chomp; | ||
1956 | $warnings_list{$_} = 1; | ||
1957 | } | ||
1958 | } | ||
1959 | close(IN); | ||
1960 | } | ||
1961 | |||
1962 | # If warnings file didn't exist, and WARNINGS_FILE exist, | ||
1963 | # then we fail on any warning! | ||
1964 | |||
1965 | open(IN, $buildlog) or dodie "Can't open $buildlog"; | ||
1966 | while (<IN>) { | ||
1967 | if (/$check_build_re/) { | ||
1968 | |||
1969 | # Some compilers use UTF-8 extended for quotes | ||
1970 | # for distcc heterogeneous systems, this causes issues | ||
1971 | s/$utf8_quote/'/g; | ||
1972 | |||
1973 | chomp; | ||
1974 | if (!defined $warnings_list{$_}) { | ||
1975 | fail "New warning found (not in $warnings_file)\n$_\n"; | ||
1976 | $no_reboot = $save_no_reboot; | ||
1977 | return 0; | ||
1978 | } | ||
1979 | } | ||
1980 | } | ||
1981 | $no_reboot = $save_no_reboot; | ||
1982 | close(IN); | ||
1983 | } | ||
1984 | |||
1985 | sub check_patch_buildlog { | ||
1928 | my ($patch) = @_; | 1986 | my ($patch) = @_; |
1929 | 1987 | ||
1930 | my @files = `git show $patch | diffstat -l`; | 1988 | my @files = `git show $patch | diffstat -l`; |
@@ -3080,11 +3138,13 @@ sub patchcheck { | |||
3080 | build "oldconfig" or return 0; | 3138 | build "oldconfig" or return 0; |
3081 | } | 3139 | } |
3082 | 3140 | ||
3083 | 3141 | # No need to do per patch checking if warnings file exists | |
3084 | if (!defined($ignored_warnings{$sha1})) { | 3142 | if (!defined($warnings_file) && !defined($ignored_warnings{$sha1})) { |
3085 | check_buildlog $sha1 or return 0; | 3143 | check_patch_buildlog $sha1 or return 0; |
3086 | } | 3144 | } |
3087 | 3145 | ||
3146 | check_buildlog or return 0; | ||
3147 | |||
3088 | next if ($type eq "build"); | 3148 | next if ($type eq "build"); |
3089 | 3149 | ||
3090 | my $failed = 0; | 3150 | my $failed = 0; |
@@ -3642,6 +3702,39 @@ sub make_min_config { | |||
3642 | return 1; | 3702 | return 1; |
3643 | } | 3703 | } |
3644 | 3704 | ||
3705 | sub make_warnings_file { | ||
3706 | my ($i) = @_; | ||
3707 | |||
3708 | if (!defined($warnings_file)) { | ||
3709 | dodie "Must define WARNINGS_FILE for make_warnings_file test"; | ||
3710 | } | ||
3711 | |||
3712 | if ($build_type eq "nobuild") { | ||
3713 | dodie "BUILD_TYPE can not be 'nobuild' for make_warnings_file test"; | ||
3714 | } | ||
3715 | |||
3716 | build $build_type or dodie "Failed to build"; | ||
3717 | |||
3718 | open(OUT, ">$warnings_file") or dodie "Can't create $warnings_file"; | ||
3719 | |||
3720 | open(IN, $buildlog) or dodie "Can't open $buildlog"; | ||
3721 | while (<IN>) { | ||
3722 | |||
3723 | # Some compilers use UTF-8 extended for quotes | ||
3724 | # for distcc heterogeneous systems, this causes issues | ||
3725 | s/$utf8_quote/'/g; | ||
3726 | |||
3727 | if (/$check_build_re/) { | ||
3728 | print OUT; | ||
3729 | } | ||
3730 | } | ||
3731 | close(IN); | ||
3732 | |||
3733 | close(OUT); | ||
3734 | |||
3735 | success $i; | ||
3736 | } | ||
3737 | |||
3645 | $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n"; | 3738 | $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl config-file\n"; |
3646 | 3739 | ||
3647 | if ($#ARGV == 0) { | 3740 | if ($#ARGV == 0) { |
@@ -3843,9 +3936,9 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3843 | $run_type = $bisect_type; | 3936 | $run_type = $bisect_type; |
3844 | } elsif ($test_type eq "config_bisect") { | 3937 | } elsif ($test_type eq "config_bisect") { |
3845 | $run_type = $config_bisect_type; | 3938 | $run_type = $config_bisect_type; |
3846 | } | 3939 | } elsif ($test_type eq "make_min_config") { |
3847 | 3940 | $run_type = ""; | |
3848 | if ($test_type eq "make_min_config") { | 3941 | } elsif ($test_type eq "make_warnings_file") { |
3849 | $run_type = ""; | 3942 | $run_type = ""; |
3850 | } | 3943 | } |
3851 | 3944 | ||
@@ -3902,10 +3995,15 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { | |||
3902 | } elsif ($test_type eq "make_min_config") { | 3995 | } elsif ($test_type eq "make_min_config") { |
3903 | make_min_config $i; | 3996 | make_min_config $i; |
3904 | next; | 3997 | next; |
3998 | } elsif ($test_type eq "make_warnings_file") { | ||
3999 | $no_reboot = 1; | ||
4000 | make_warnings_file $i; | ||
4001 | next; | ||
3905 | } | 4002 | } |
3906 | 4003 | ||
3907 | if ($build_type ne "nobuild") { | 4004 | if ($build_type ne "nobuild") { |
3908 | build $build_type or next; | 4005 | build $build_type or next; |
4006 | check_buildlog or next; | ||
3909 | } | 4007 | } |
3910 | 4008 | ||
3911 | if ($test_type eq "install") { | 4009 | if ($test_type eq "install") { |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index 4012e9330344..0a290fb4cd5e 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
@@ -793,6 +793,20 @@ | |||
793 | # Example for a virtual guest call "Guest". | 793 | # Example for a virtual guest call "Guest". |
794 | #POWER_OFF = virsh destroy Guest | 794 | #POWER_OFF = virsh destroy Guest |
795 | 795 | ||
796 | # To have the build fail on "new" warnings, create a file that | ||
797 | # contains a list of all known warnings (they must match exactly | ||
798 | # to the line with 'warning:', 'error:' or 'Error:'. If the option | ||
799 | # WARNINGS_FILE is set, then that file will be read, and if the | ||
800 | # build detects a warning, it will examine this file and if the | ||
801 | # warning does not exist in it, it will fail the build. | ||
802 | # | ||
803 | # Note, if this option is defined to a file that does not exist | ||
804 | # then any warning will fail the build. | ||
805 | # (see make_warnings_file below) | ||
806 | # | ||
807 | # (optional, default undefined) | ||
808 | #WARNINGS_FILE = ${OUTPUT_DIR}/warnings_file | ||
809 | |||
796 | # The way to execute a command on the target | 810 | # The way to execute a command on the target |
797 | # (default ssh $SSH_USER@$MACHINE $SSH_COMMAND";) | 811 | # (default ssh $SSH_USER@$MACHINE $SSH_COMMAND";) |
798 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined | 812 | # The variables SSH_USER, MACHINE and SSH_COMMAND are defined |
@@ -1222,3 +1236,33 @@ | |||
1222 | # MIN_CONFIG_TYPE = test | 1236 | # MIN_CONFIG_TYPE = test |
1223 | # TEST = ssh ${USER}@${MACHINE} echo hi | 1237 | # TEST = ssh ${USER}@${MACHINE} echo hi |
1224 | # | 1238 | # |
1239 | # | ||
1240 | # | ||
1241 | # | ||
1242 | # For TEST_TYPE = make_warnings_file | ||
1243 | # | ||
1244 | # If you want the build to fail when a new warning is discovered | ||
1245 | # you set the WARNINGS_FILE to point to a file of known warnings. | ||
1246 | # | ||
1247 | # The test "make_warnings_file" will let you create a new warnings | ||
1248 | # file before you run other tests, like patchcheck. | ||
1249 | # | ||
1250 | # What this test does is to run just a build, you still need to | ||
1251 | # specify BUILD_TYPE to tell the test what type of config to use. | ||
1252 | # A BUILD_TYPE of nobuild will fail this test. | ||
1253 | # | ||
1254 | # The test will do the build and scan for all warnings. Any warning | ||
1255 | # it discovers will be saved in the WARNINGS_FILE (required) option. | ||
1256 | # | ||
1257 | # It is recommended (but not necessary) to make sure BUILD_NOCLEAN is | ||
1258 | # off, so that a full build is done (make mrproper is performed). | ||
1259 | # That way, all warnings will be captured. | ||
1260 | # | ||
1261 | # Example: | ||
1262 | # | ||
1263 | # TEST_TYPE = make_warnings_file | ||
1264 | # WARNINGS_FILE = ${OUTPUT_DIR} | ||
1265 | # BUILD_TYPE = useconfig:oldconfig | ||
1266 | # CHECKOUT = v3.8 | ||
1267 | # BUILD_NOCLEAN = 0 | ||
1268 | # | ||