diff --git a/checkpatch.pl b/checkpatch.pl index 70a3bb4..4e38574 100755 --- a/checkpatch.pl +++ b/checkpatch.pl @@ -2140,6 +2140,8 @@ sub process { my %commit_log_tags = (); my $has_changelog = 0; + my $has_test_result_file = 0; + my $warned_about_result_file = 0; my $has_doc = 0; my $has_test = 0; my $is_test = 0; @@ -2731,6 +2733,9 @@ sub process { if ($realfile =~ /^(?:static-build\/)?test\/.*\//) { $has_test = 1; } + if ($realfile =~ /^test\/.*\.result$/) { + $has_test_result_file = 1; + } # check for repeated words separated by a single space # avoid false positive from list command eg, '-rw-r--r-- 1 root root' @@ -2823,6 +2828,14 @@ sub process { "please, use spaces instead of tabs\n" . $herevet); } + if (!$warned_about_result_file && + $has_test_result_file && + $line =~ /^\+/) { + $warned_about_result_file = 1; + ERROR("TEST_DIFF_FILE", + "Please avoid tests with .result files\n"); + } + # check we are in a valid C source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|cc)$/); diff --git a/doc/checkpatch.rst b/doc/checkpatch.rst index 546aa86..013505e 100644 --- a/doc/checkpatch.rst +++ b/doc/checkpatch.rst @@ -742,6 +742,10 @@ Others For DOS-formatted patches, there are extra ^M symbols at the end of the line. These should be removed. + **TEST_DIFF_FILE** + For regression tests, there are .result files. Tests with .result files + should be avoided. + **MEMSET** The memset use appears to be incorrect. This may be caused due to badly ordered parameters. Please recheck the usage.