xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | <testcase> |
| 2 | <info> |
| 3 | <keywords> |
| 4 | checksrc |
| 5 | </keywords> |
| 6 | </info> |
| 7 | |
| 8 | # |
| 9 | # Client-side |
| 10 | <client> |
| 11 | <server> |
| 12 | none |
| 13 | </server> |
| 14 | <name> |
| 15 | checksrc |
| 16 | </name> |
| 17 | |
| 18 | <command type="perl"> |
| 19 | %SRCDIR/../scripts/checksrc.pl log/code%TESTNUMBER.c |
| 20 | </command> |
| 21 | <file name="log/code%TESTNUMBER.c"> |
| 22 | /* test source code |
| 23 | * Violate each rule at least once. |
| 24 | **/ |
| 25 | int hello; /*------------------------------------------------------------------*/ |
| 26 | int tab; |
| 27 | int trailing_space; |
| 28 | int a = func (); |
| 29 | int b = func( b); |
| 30 | int b = func(b ); |
| 31 | func(a, b , c); |
| 32 | |
| 33 | int hello() |
| 34 | { |
| 35 | return(2); |
| 36 | } |
| 37 | func(a, b,c); |
| 38 | |
| 39 | if(a == 2) { |
| 40 | ; |
| 41 | } else { |
| 42 | moo = 2; |
| 43 | } |
| 44 | |
| 45 | if(a == 2){ /* followed by comment */ |
| 46 | ; |
| 47 | } |
| 48 | |
| 49 | func() ; |
| 50 | |
| 51 | a = sprintf(buffer, "%s", moo); |
| 52 | |
| 53 | FILE *f = fopen("filename", "r"); |
| 54 | |
| 55 | void startfunc(int a, int b) { |
| 56 | func(); |
| 57 | } |
| 58 | |
| 59 | for(;;) { |
| 60 | func(1); |
| 61 | } while(1); |
| 62 | |
| 63 | char * name = "hello"; |
| 64 | char* name = "hello"; |
| 65 | |
| 66 | int foo=bar; |
| 67 | int foo= bar; |
| 68 | int foo = bar; |
| 69 | int foo = bar;foo++; |
| 70 | for(;;) { |
| 71 | } |
| 72 | |
| 73 | int a = sizeof int; |
| 74 | int a = snprintf(buffer, sizeof(buffer), "%d", 99); |
| 75 | |
| 76 | if(a) b++; |
| 77 | |
| 78 | // CPP comment? |
| 79 | |
| 80 | /* comment doesn't end |
| 81 | |
| 82 | </file> |
| 83 | </client> |
| 84 | |
| 85 | # |
| 86 | # Verify data after the test has been "shot" |
| 87 | <verify> |
| 88 | <stdout> |
| 89 | ./log/code1185.c:4:82: warning: Longer than 79 columns (LONGLINE) |
| 90 | int hello; /*------------------------------------------------------------------*/ |
| 91 | ./log/code1185.c:5:4: error: Contains TAB character (TABS) |
| 92 | int tab; |
| 93 | ^ |
| 94 | ./log/code1185.c:7:13: warning: func with space (SPACEBEFOREPAREN) |
| 95 | int a = func (); |
| 96 | ^ |
| 97 | ./log/code1185.c:8:14: warning: space after open parenthesis (SPACEAFTERPAREN) |
| 98 | int b = func( b); |
| 99 | ^ |
| 100 | ./log/code1185.c:9:16: warning: space before close parenthesis (SPACEBEFORECLOSE) |
| 101 | int b = func(b ); |
| 102 | ^ |
| 103 | ./log/code1185.c:10:11: warning: space before comma (SPACEBEFORECOMMA) |
| 104 | func(a, b , c); |
| 105 | ^ |
| 106 | ./log/code1185.c:14:9: warning: return without space before paren (RETURNNOSPACE) |
| 107 | return(2); |
| 108 | ^ |
| 109 | ./log/code1185.c:16:11: warning: comma without following space (COMMANOSPACE) |
| 110 | func(a, b,c); |
| 111 | ^ |
| 112 | ./log/code1185.c:18:12: warning: wrongly placed open brace (BRACEPOS) |
| 113 | if(a == 2) { |
| 114 | ^ |
| 115 | ./log/code1185.c:20:1: warning: else after closing brace on same line (BRACEELSE) |
| 116 | } else { |
| 117 | ^ |
| 118 | ./log/code1185.c:24:11: warning: missing space after close paren (PARENBRACE) |
| 119 | if(a == 2){ |
| 120 | ^ |
| 121 | ./log/code1185.c:28:7: warning: no space before semicolon (SPACESEMICOLON) |
| 122 | func() ; |
| 123 | ^ |
| 124 | ./log/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC) |
| 125 | a = sprintf(buffer, "%s", moo); |
| 126 | ^ |
| 127 | ./log/code1185.c:32:11: warning: use of non-binary fopen without FOPEN_* macro: r (FOPENMODE) |
| 128 | FILE *f = fopen("filename", "r"); |
| 129 | ^ |
| 130 | ./log/code1185.c:34:30: warning: wrongly placed open brace (BRACEPOS) |
| 131 | void startfunc(int a, int b) { |
| 132 | ^ |
| 133 | ./log/code1185.c:39:6: warning: not indented 2 steps (uses 4) (INDENTATION) |
| 134 | func(1); |
| 135 | ^ |
| 136 | ./log/code1185.c:42:8: warning: space after declarative asterisk (ASTERISKSPACE) |
| 137 | char * name = "hello"; |
| 138 | ^ |
| 139 | ./log/code1185.c:43:7: warning: space after declarative asterisk (ASTERISKSPACE) |
| 140 | char* name = "hello"; |
| 141 | ^ |
| 142 | ./log/code1185.c:43:6: warning: no space before asterisk (ASTERISKNOSPACE) |
| 143 | char* name = "hello"; |
| 144 | ^ |
| 145 | ./log/code1185.c:45:10: warning: no space after equals sign (EQUALSNOSPACE) |
| 146 | int foo=bar; |
| 147 | ^ |
| 148 | ./log/code1185.c:46:9: warning: no space before equals sign (NOSPACEEQUALS) |
| 149 | int foo= bar; |
| 150 | ^ |
| 151 | ./log/code1185.c:48:16: warning: no space after semicolon (SEMINOSPACE) |
| 152 | int foo = bar;foo++; |
| 153 | ^ |
| 154 | ./log/code1185.c:49:10: warning: multiple spaces (MULTISPACE) |
| 155 | for(;;) { |
| 156 | ^ |
| 157 | ./log/code1185.c:50:2: warning: not indented 2 steps (uses 0) (INDENTATION) |
| 158 | } |
| 159 | ^ |
| 160 | ./log/code1185.c:52:16: warning: sizeof without parenthesis (SIZEOFNOPAREN) |
| 161 | int a = sizeof int; |
| 162 | ^ |
| 163 | ./log/code1185.c:53:10: warning: use of snprintf is banned (SNPRINTF) |
| 164 | int a = snprintf(buffer, sizeof(buffer), "%d", 99); |
| 165 | ^ |
| 166 | ./log/code1185.c:55:7: warning: conditional block on the same line (ONELINECONDITION) |
| 167 | if(a) b++; |
| 168 | ^ |
| 169 | ./log/code1185.c:57:2: warning: // comment (CPPCOMMENTS) |
| 170 | // CPP comment? |
| 171 | ^ |
| 172 | ./log/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT) |
| 173 | |
| 174 | ^ |
| 175 | ./log/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT) |
| 176 | |
| 177 | ^ |
| 178 | checksrc: 0 errors and 30 warnings |
| 179 | </stdout> |
| 180 | <errorcode> |
| 181 | 5 |
| 182 | </errorcode> |
| 183 | </verify> |
| 184 | </testcase> |