File: test.patch

package info (click to toggle)
kworkflow 1%3A0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,212 kB
  • sloc: sh: 31,869; perl: 2,172; sql: 268; ansic: 114; xml: 84; python: 76; makefile: 27
file content (112 lines) | stat: -rw-r--r-- 3,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 9cfd2e8fb9f420ea900ca4cf54ce84139970429e Mon Sep 17 00:00:00 2001
From: Lala Xpto <lalaXpto@lulu.com>
Date: Sun, 24 Feb 2019 12:16:25 -0300
Subject: [PATCH 41/54] Fix the extra '=*' in the codestyle command

Currently, if we use 'kw c' in a source file without any warning, it
displays something like this:

$ kw c drivers/gpu/drm/vkms/
Running checkpatch.pl on: drivers/gpu/drm/vkms/

=========================================================
PATH:70: ANY OUTPUT
total: 0 errors, 0 warnings, 1 checks, 144 lines checked

=========================================================

=========================================================

=========================================================

=========================================================

This patch, fix this problem by removing the extra "=*". Additionally,
this commit updates the test to better fit this new output and add a new
check for the case that does not have any issue in the code.

---
 src/checkpatch_wrapper.sh        |  8 ++++++--
 tests/unit/checkpatch_wrapper_test.sh | 14 +++++++++-----
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/checkpatch_wrapper.sh b/src/checkpatch_wrapper.sh
index 63949fc..cb38f78 100755
--- a/src/checkpatch_wrapper.sh
+++ b/src/checkpatch_wrapper.sh
@@ -22,11 +22,11 @@ function execute_checkpatch()
   FLIST=`find $FILE_OR_DIR_CHECK -type f ! -name '*\.mod\.c' | grep "\.[ch]$" `
 
   say "Running checkpatch.pl on: $FILE_OR_DIR_CHECK"
+  say $SEPARATOR
 
   for current_file in $FLIST
   do
     file=$current_file
-    echo
 
     if [ ! -e "$file" ]
     then
@@ -34,7 +34,11 @@ function execute_checkpatch()
       continue
     fi
 
-    say $SEPARATOR
     $checkpatch $file
+
+    if [ $? != 0 ]; then
+      say $SEPARATOR
+    fi
+
   done
 }
diff --git a/tests/unit/checkpatch_wrapper_test.sh b/tests/unit/checkpatch_wrapper_test.sh
index c079b32..cc60012 100755
--- a/tests/unit/checkpatch_wrapper_test.sh
+++ b/tests/unit/checkpatch_wrapper_test.sh
@@ -8,18 +8,17 @@ function suite
   suite_addTest "testWarning"
   suite_addTest "testError"
   suite_addTest "testChecks"
+  suite_addTest "testNothing"
 }
 
 # Those variables hold the last line execute_checkpatch prints in a code that is correct, has
 # 1 warning, has 1 erros and has 1 check, respectively. The sample codes used in this test are
 # in tests/unit/samples/
-CORRECT_MSG="========================================================="
 WARNING_MSG="total: 0 errors, 1 warnings, 0 checks, 25 lines checked"
 ERROR_MSG="total: 1 errors, 0 warnings, 0 checks, 25 lines checked"
 CHECK_MSG="total: 0 errors, 0 warnings, 1 checks, 26 lines checked"
 
 declare -A MSG=( \
-    ["correct"]=CORRECT_MSG \
     ["warning"]=WARNING_MSG \
     ["error"]=ERROR_MSG \
     ["check"]=CHECK_MSG \
@@ -27,9 +26,8 @@ declare -A MSG=( \
 
 function checkpatch
 {
-  res=$(execute_checkpatch "tests/unit/samples/codestyle_$1.c" 2>&1 | tail -n 1 )
-  [[ "$res" != "${!MSG[$1]}" ]] && fail "Checkpatch should output:\n${!MSG[$1]}"
-  true # Reset return value
+  res=$(execute_checkpatch "tests/unit/samples/codestyle_$1.c" 2>&1)
+  assertTrue "Checkpatch should output:\n${!MSG[$1]}" '[[ $res =~ ${!MSG[$1]} ]]'
 }
 
 function testWarning
@@ -52,4 +50,10 @@ function testCorrect
   checkpatch "correct"
 }
 
+function testNothing
+{
+  res=$(execute_checkpatch "tests/unit/samples/codestyle_nothing.c" 2>&1)
+  assertFail "Checkpatch should not show anything" '[[ $res =~ total ]]'
+}
+
 invoke_shunit
-- 
2.21.0