~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/damon/sysfs.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/damon/sysfs.sh (Architecture m68k) and /tools/testing/selftests/damon/sysfs.sh (Architecture sparc)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 # Kselftest frmework requirement - SKIP code i      4 # Kselftest frmework requirement - SKIP code is 4.
  5 ksft_skip=4                                         5 ksft_skip=4
  6                                                     6 
  7 ensure_write_succ()                                 7 ensure_write_succ()
  8 {                                                   8 {
  9         file=$1                                     9         file=$1
 10         content=$2                                 10         content=$2
 11         reason=$3                                  11         reason=$3
 12                                                    12 
 13         if ! echo "$content" > "$file"             13         if ! echo "$content" > "$file"
 14         then                                       14         then
 15                 echo "writing $content to $fil     15                 echo "writing $content to $file failed"
 16                 echo "expected success because     16                 echo "expected success because $reason"
 17                 exit 1                             17                 exit 1
 18         fi                                         18         fi
 19 }                                                  19 }
 20                                                    20 
 21 ensure_write_fail()                                21 ensure_write_fail()
 22 {                                                  22 {
 23         file=$1                                    23         file=$1
 24         content=$2                                 24         content=$2
 25         reason=$3                                  25         reason=$3
 26                                                    26 
 27         if (echo "$content" > "$file") 2> /dev     27         if (echo "$content" > "$file") 2> /dev/null
 28         then                                       28         then
 29                 echo "writing $content to $fil     29                 echo "writing $content to $file succeed ($fail_reason)"
 30                 echo "expected failure because     30                 echo "expected failure because $reason"
 31                 exit 1                             31                 exit 1
 32         fi                                         32         fi
 33 }                                                  33 }
 34                                                    34 
 35 ensure_dir()                                       35 ensure_dir()
 36 {                                                  36 {
 37         dir=$1                                     37         dir=$1
 38         to_ensure=$2                               38         to_ensure=$2
 39         if [ "$to_ensure" = "exist" ] && [ ! -     39         if [ "$to_ensure" = "exist" ] && [ ! -d "$dir" ]
 40         then                                       40         then
 41                 echo "$dir dir is expected but     41                 echo "$dir dir is expected but not found"
 42                 exit 1                             42                 exit 1
 43         elif [ "$to_ensure" = "not_exist" ] &&     43         elif [ "$to_ensure" = "not_exist" ] && [ -d "$dir" ]
 44         then                                       44         then
 45                 echo "$dir dir is not expected     45                 echo "$dir dir is not expected but found"
 46                 exit 1                             46                 exit 1
 47         fi                                         47         fi
 48 }                                                  48 }
 49                                                    49 
 50 ensure_file()                                      50 ensure_file()
 51 {                                                  51 {
 52         file=$1                                    52         file=$1
 53         to_ensure=$2                               53         to_ensure=$2
 54         permission=$3                              54         permission=$3
 55         if [ "$to_ensure" = "exist" ]              55         if [ "$to_ensure" = "exist" ]
 56         then                                       56         then
 57                 if [ ! -f "$file" ]                57                 if [ ! -f "$file" ]
 58                 then                               58                 then
 59                         echo "$file is expecte     59                         echo "$file is expected but not found"
 60                         exit 1                     60                         exit 1
 61                 fi                                 61                 fi
 62                 perm=$(stat -c "%a" "$file")       62                 perm=$(stat -c "%a" "$file")
 63                 if [ ! "$perm" = "$permission"     63                 if [ ! "$perm" = "$permission" ]
 64                 then                               64                 then
 65                         echo "$file permission     65                         echo "$file permission: expected $permission but $perm"
 66                         exit 1                     66                         exit 1
 67                 fi                                 67                 fi
 68         elif [ "$to_ensure" = "not_exist" ] &&     68         elif [ "$to_ensure" = "not_exist" ] && [ -f "$dir" ]
 69         then                                       69         then
 70                 echo "$file is not expected bu     70                 echo "$file is not expected but found"
 71                 exit 1                             71                 exit 1
 72         fi                                         72         fi
 73 }                                                  73 }
 74                                                    74 
 75 test_range()                                       75 test_range()
 76 {                                                  76 {
 77         range_dir=$1                               77         range_dir=$1
 78         ensure_dir "$range_dir" "exist"            78         ensure_dir "$range_dir" "exist"
 79         ensure_file "$range_dir/min" "exist" 6     79         ensure_file "$range_dir/min" "exist" 600
 80         ensure_file "$range_dir/max" "exist" 6     80         ensure_file "$range_dir/max" "exist" 600
 81 }                                                  81 }
 82                                                    82 
 83 test_tried_regions()                               83 test_tried_regions()
 84 {                                                  84 {
 85         tried_regions_dir=$1                       85         tried_regions_dir=$1
 86         ensure_dir "$tried_regions_dir" "exist     86         ensure_dir "$tried_regions_dir" "exist"
 87         ensure_file "$tried_regions_dir/total_     87         ensure_file "$tried_regions_dir/total_bytes" "exist" "400"
 88 }                                                  88 }
 89                                                    89 
 90 test_stats()                                       90 test_stats()
 91 {                                                  91 {
 92         stats_dir=$1                               92         stats_dir=$1
 93         ensure_dir "$stats_dir" "exist"            93         ensure_dir "$stats_dir" "exist"
 94         for f in nr_tried sz_tried nr_applied      94         for f in nr_tried sz_tried nr_applied sz_applied qt_exceeds
 95         do                                         95         do
 96                 ensure_file "$stats_dir/$f" "e     96                 ensure_file "$stats_dir/$f" "exist" "400"
 97         done                                       97         done
 98 }                                                  98 }
 99                                                    99 
100 test_filter()                                     100 test_filter()
101 {                                                 101 {
102         filter_dir=$1                             102         filter_dir=$1
103         ensure_file "$filter_dir/type" "exist"    103         ensure_file "$filter_dir/type" "exist" "600"
104         ensure_write_succ "$filter_dir/type" "    104         ensure_write_succ "$filter_dir/type" "anon" "valid input"
105         ensure_write_succ "$filter_dir/type" "    105         ensure_write_succ "$filter_dir/type" "memcg" "valid input"
106         ensure_write_succ "$filter_dir/type" "    106         ensure_write_succ "$filter_dir/type" "addr" "valid input"
107         ensure_write_succ "$filter_dir/type" "    107         ensure_write_succ "$filter_dir/type" "target" "valid input"
108         ensure_write_fail "$filter_dir/type" "    108         ensure_write_fail "$filter_dir/type" "foo" "invalid input"
109         ensure_file "$filter_dir/matching" "ex    109         ensure_file "$filter_dir/matching" "exist" "600"
110         ensure_file "$filter_dir/memcg_path" "    110         ensure_file "$filter_dir/memcg_path" "exist" "600"
111         ensure_file "$filter_dir/addr_start" "    111         ensure_file "$filter_dir/addr_start" "exist" "600"
112         ensure_file "$filter_dir/addr_end" "ex    112         ensure_file "$filter_dir/addr_end" "exist" "600"
113         ensure_file "$filter_dir/damon_target_    113         ensure_file "$filter_dir/damon_target_idx" "exist" "600"
114 }                                                 114 }
115                                                   115 
116 test_filters()                                    116 test_filters()
117 {                                                 117 {
118         filters_dir=$1                            118         filters_dir=$1
119         ensure_dir "$filters_dir" "exist"         119         ensure_dir "$filters_dir" "exist"
120         ensure_file "$filters_dir/nr_filters"     120         ensure_file "$filters_dir/nr_filters" "exist" "600"
121         ensure_write_succ  "$filters_dir/nr_fi    121         ensure_write_succ  "$filters_dir/nr_filters" "1" "valid input"
122         test_filter "$filters_dir/0"              122         test_filter "$filters_dir/0"
123                                                   123 
124         ensure_write_succ  "$filters_dir/nr_fi    124         ensure_write_succ  "$filters_dir/nr_filters" "2" "valid input"
125         test_filter "$filters_dir/0"              125         test_filter "$filters_dir/0"
126         test_filter "$filters_dir/1"              126         test_filter "$filters_dir/1"
127                                                   127 
128         ensure_write_succ "$filters_dir/nr_fil    128         ensure_write_succ "$filters_dir/nr_filters" "0" "valid input"
129         ensure_dir "$filters_dir/0" "not_exist    129         ensure_dir "$filters_dir/0" "not_exist"
130         ensure_dir "$filters_dir/1" "not_exist    130         ensure_dir "$filters_dir/1" "not_exist"
131 }                                                 131 }
132                                                   132 
133 test_watermarks()                                 133 test_watermarks()
134 {                                                 134 {
135         watermarks_dir=$1                         135         watermarks_dir=$1
136         ensure_dir "$watermarks_dir" "exist"      136         ensure_dir "$watermarks_dir" "exist"
137         ensure_file "$watermarks_dir/metric" "    137         ensure_file "$watermarks_dir/metric" "exist" "600"
138         ensure_file "$watermarks_dir/interval_    138         ensure_file "$watermarks_dir/interval_us" "exist" "600"
139         ensure_file "$watermarks_dir/high" "ex    139         ensure_file "$watermarks_dir/high" "exist" "600"
140         ensure_file "$watermarks_dir/mid" "exi    140         ensure_file "$watermarks_dir/mid" "exist" "600"
141         ensure_file "$watermarks_dir/low" "exi    141         ensure_file "$watermarks_dir/low" "exist" "600"
142 }                                                 142 }
143                                                   143 
144 test_weights()                                    144 test_weights()
145 {                                                 145 {
146         weights_dir=$1                            146         weights_dir=$1
147         ensure_dir "$weights_dir" "exist"         147         ensure_dir "$weights_dir" "exist"
148         ensure_file "$weights_dir/sz_permil" "    148         ensure_file "$weights_dir/sz_permil" "exist" "600"
149         ensure_file "$weights_dir/nr_accesses_    149         ensure_file "$weights_dir/nr_accesses_permil" "exist" "600"
150         ensure_file "$weights_dir/age_permil"     150         ensure_file "$weights_dir/age_permil" "exist" "600"
151 }                                                 151 }
152                                                   152 
153 test_goal()                                       153 test_goal()
154 {                                                 154 {
155         goal_dir=$1                               155         goal_dir=$1
156         ensure_dir "$goal_dir" "exist"            156         ensure_dir "$goal_dir" "exist"
157         ensure_file "$goal_dir/target_value" "    157         ensure_file "$goal_dir/target_value" "exist" "600"
158         ensure_file "$goal_dir/current_value"     158         ensure_file "$goal_dir/current_value" "exist" "600"
159 }                                                 159 }
160                                                   160 
161 test_goals()                                      161 test_goals()
162 {                                                 162 {
163         goals_dir=$1                              163         goals_dir=$1
164         ensure_dir "$goals_dir" "exist"           164         ensure_dir "$goals_dir" "exist"
165         ensure_file "$goals_dir/nr_goals" "exi    165         ensure_file "$goals_dir/nr_goals" "exist" "600"
166                                                   166 
167         ensure_write_succ  "$goals_dir/nr_goal    167         ensure_write_succ  "$goals_dir/nr_goals" "1" "valid input"
168         test_goal "$goals_dir/0"                  168         test_goal "$goals_dir/0"
169                                                   169 
170         ensure_write_succ  "$goals_dir/nr_goal    170         ensure_write_succ  "$goals_dir/nr_goals" "2" "valid input"
171         test_goal "$goals_dir/0"                  171         test_goal "$goals_dir/0"
172         test_goal "$goals_dir/1"                  172         test_goal "$goals_dir/1"
173                                                   173 
174         ensure_write_succ  "$goals_dir/nr_goal    174         ensure_write_succ  "$goals_dir/nr_goals" "0" "valid input"
175         ensure_dir "$goals_dir/0" "not_exist"     175         ensure_dir "$goals_dir/0" "not_exist"
176         ensure_dir "$goals_dir/1" "not_exist"     176         ensure_dir "$goals_dir/1" "not_exist"
177 }                                                 177 }
178                                                   178 
179 test_quotas()                                     179 test_quotas()
180 {                                                 180 {
181         quotas_dir=$1                             181         quotas_dir=$1
182         ensure_dir "$quotas_dir" "exist"          182         ensure_dir "$quotas_dir" "exist"
183         ensure_file "$quotas_dir/ms" "exist" 6    183         ensure_file "$quotas_dir/ms" "exist" 600
184         ensure_file "$quotas_dir/bytes" "exist    184         ensure_file "$quotas_dir/bytes" "exist" 600
185         ensure_file "$quotas_dir/reset_interva    185         ensure_file "$quotas_dir/reset_interval_ms" "exist" 600
186         test_weights "$quotas_dir/weights"        186         test_weights "$quotas_dir/weights"
187         test_goals "$quotas_dir/goals"            187         test_goals "$quotas_dir/goals"
188 }                                                 188 }
189                                                   189 
190 test_access_pattern()                             190 test_access_pattern()
191 {                                                 191 {
192         access_pattern_dir=$1                     192         access_pattern_dir=$1
193         ensure_dir "$access_pattern_dir" "exis    193         ensure_dir "$access_pattern_dir" "exist"
194         test_range "$access_pattern_dir/age"      194         test_range "$access_pattern_dir/age"
195         test_range "$access_pattern_dir/nr_acc    195         test_range "$access_pattern_dir/nr_accesses"
196         test_range "$access_pattern_dir/sz"       196         test_range "$access_pattern_dir/sz"
197 }                                                 197 }
198                                                   198 
199 test_scheme()                                     199 test_scheme()
200 {                                                 200 {
201         scheme_dir=$1                             201         scheme_dir=$1
202         ensure_dir "$scheme_dir" "exist"          202         ensure_dir "$scheme_dir" "exist"
203         ensure_file "$scheme_dir/action" "exis    203         ensure_file "$scheme_dir/action" "exist" "600"
204         test_access_pattern "$scheme_dir/acces    204         test_access_pattern "$scheme_dir/access_pattern"
205         ensure_file "$scheme_dir/apply_interva    205         ensure_file "$scheme_dir/apply_interval_us" "exist" "600"
206         test_quotas "$scheme_dir/quotas"          206         test_quotas "$scheme_dir/quotas"
207         test_watermarks "$scheme_dir/watermark    207         test_watermarks "$scheme_dir/watermarks"
208         test_filters "$scheme_dir/filters"        208         test_filters "$scheme_dir/filters"
209         test_stats "$scheme_dir/stats"            209         test_stats "$scheme_dir/stats"
210         test_tried_regions "$scheme_dir/tried_    210         test_tried_regions "$scheme_dir/tried_regions"
211 }                                                 211 }
212                                                   212 
213 test_schemes()                                    213 test_schemes()
214 {                                                 214 {
215         schemes_dir=$1                            215         schemes_dir=$1
216         ensure_dir "$schemes_dir" "exist"         216         ensure_dir "$schemes_dir" "exist"
217         ensure_file "$schemes_dir/nr_schemes"     217         ensure_file "$schemes_dir/nr_schemes" "exist" 600
218                                                   218 
219         ensure_write_succ  "$schemes_dir/nr_sc    219         ensure_write_succ  "$schemes_dir/nr_schemes" "1" "valid input"
220         test_scheme "$schemes_dir/0"              220         test_scheme "$schemes_dir/0"
221                                                   221 
222         ensure_write_succ  "$schemes_dir/nr_sc    222         ensure_write_succ  "$schemes_dir/nr_schemes" "2" "valid input"
223         test_scheme "$schemes_dir/0"              223         test_scheme "$schemes_dir/0"
224         test_scheme "$schemes_dir/1"              224         test_scheme "$schemes_dir/1"
225                                                   225 
226         ensure_write_succ "$schemes_dir/nr_sch    226         ensure_write_succ "$schemes_dir/nr_schemes" "0" "valid input"
227         ensure_dir "$schemes_dir/0" "not_exist    227         ensure_dir "$schemes_dir/0" "not_exist"
228         ensure_dir "$schemes_dir/1" "not_exist    228         ensure_dir "$schemes_dir/1" "not_exist"
229 }                                                 229 }
230                                                   230 
231 test_region()                                     231 test_region()
232 {                                                 232 {
233         region_dir=$1                             233         region_dir=$1
234         ensure_dir "$region_dir" "exist"          234         ensure_dir "$region_dir" "exist"
235         ensure_file "$region_dir/start" "exist    235         ensure_file "$region_dir/start" "exist" 600
236         ensure_file "$region_dir/end" "exist"     236         ensure_file "$region_dir/end" "exist" 600
237 }                                                 237 }
238                                                   238 
239 test_regions()                                    239 test_regions()
240 {                                                 240 {
241         regions_dir=$1                            241         regions_dir=$1
242         ensure_dir "$regions_dir" "exist"         242         ensure_dir "$regions_dir" "exist"
243         ensure_file "$regions_dir/nr_regions"     243         ensure_file "$regions_dir/nr_regions" "exist" 600
244                                                   244 
245         ensure_write_succ  "$regions_dir/nr_re    245         ensure_write_succ  "$regions_dir/nr_regions" "1" "valid input"
246         test_region "$regions_dir/0"              246         test_region "$regions_dir/0"
247                                                   247 
248         ensure_write_succ  "$regions_dir/nr_re    248         ensure_write_succ  "$regions_dir/nr_regions" "2" "valid input"
249         test_region "$regions_dir/0"              249         test_region "$regions_dir/0"
250         test_region "$regions_dir/1"              250         test_region "$regions_dir/1"
251                                                   251 
252         ensure_write_succ "$regions_dir/nr_reg    252         ensure_write_succ "$regions_dir/nr_regions" "0" "valid input"
253         ensure_dir "$regions_dir/0" "not_exist    253         ensure_dir "$regions_dir/0" "not_exist"
254         ensure_dir "$regions_dir/1" "not_exist    254         ensure_dir "$regions_dir/1" "not_exist"
255 }                                                 255 }
256                                                   256 
257 test_target()                                     257 test_target()
258 {                                                 258 {
259         target_dir=$1                             259         target_dir=$1
260         ensure_dir "$target_dir" "exist"          260         ensure_dir "$target_dir" "exist"
261         ensure_file "$target_dir/pid_target" "    261         ensure_file "$target_dir/pid_target" "exist" "600"
262         test_regions "$target_dir/regions"        262         test_regions "$target_dir/regions"
263 }                                                 263 }
264                                                   264 
265 test_targets()                                    265 test_targets()
266 {                                                 266 {
267         targets_dir=$1                            267         targets_dir=$1
268         ensure_dir "$targets_dir" "exist"         268         ensure_dir "$targets_dir" "exist"
269         ensure_file "$targets_dir/nr_targets"     269         ensure_file "$targets_dir/nr_targets" "exist" 600
270                                                   270 
271         ensure_write_succ  "$targets_dir/nr_ta    271         ensure_write_succ  "$targets_dir/nr_targets" "1" "valid input"
272         test_target "$targets_dir/0"              272         test_target "$targets_dir/0"
273                                                   273 
274         ensure_write_succ  "$targets_dir/nr_ta    274         ensure_write_succ  "$targets_dir/nr_targets" "2" "valid input"
275         test_target "$targets_dir/0"              275         test_target "$targets_dir/0"
276         test_target "$targets_dir/1"              276         test_target "$targets_dir/1"
277                                                   277 
278         ensure_write_succ "$targets_dir/nr_tar    278         ensure_write_succ "$targets_dir/nr_targets" "0" "valid input"
279         ensure_dir "$targets_dir/0" "not_exist    279         ensure_dir "$targets_dir/0" "not_exist"
280         ensure_dir "$targets_dir/1" "not_exist    280         ensure_dir "$targets_dir/1" "not_exist"
281 }                                                 281 }
282                                                   282 
283 test_intervals()                                  283 test_intervals()
284 {                                                 284 {
285         intervals_dir=$1                          285         intervals_dir=$1
286         ensure_dir "$intervals_dir" "exist"       286         ensure_dir "$intervals_dir" "exist"
287         ensure_file "$intervals_dir/aggr_us" "    287         ensure_file "$intervals_dir/aggr_us" "exist" "600"
288         ensure_file "$intervals_dir/sample_us"    288         ensure_file "$intervals_dir/sample_us" "exist" "600"
289         ensure_file "$intervals_dir/update_us"    289         ensure_file "$intervals_dir/update_us" "exist" "600"
290 }                                                 290 }
291                                                   291 
292 test_monitoring_attrs()                           292 test_monitoring_attrs()
293 {                                                 293 {
294         monitoring_attrs_dir=$1                   294         monitoring_attrs_dir=$1
295         ensure_dir "$monitoring_attrs_dir" "ex    295         ensure_dir "$monitoring_attrs_dir" "exist"
296         test_intervals "$monitoring_attrs_dir/    296         test_intervals "$monitoring_attrs_dir/intervals"
297         test_range "$monitoring_attrs_dir/nr_r    297         test_range "$monitoring_attrs_dir/nr_regions"
298 }                                                 298 }
299                                                   299 
300 test_context()                                    300 test_context()
301 {                                                 301 {
302         context_dir=$1                            302         context_dir=$1
303         ensure_dir "$context_dir" "exist"         303         ensure_dir "$context_dir" "exist"
304         ensure_file "$context_dir/avail_operat    304         ensure_file "$context_dir/avail_operations" "exit" 400
305         ensure_file "$context_dir/operations"     305         ensure_file "$context_dir/operations" "exist" 600
306         test_monitoring_attrs "$context_dir/mo    306         test_monitoring_attrs "$context_dir/monitoring_attrs"
307         test_targets "$context_dir/targets"       307         test_targets "$context_dir/targets"
308         test_schemes "$context_dir/schemes"       308         test_schemes "$context_dir/schemes"
309 }                                                 309 }
310                                                   310 
311 test_contexts()                                   311 test_contexts()
312 {                                                 312 {
313         contexts_dir=$1                           313         contexts_dir=$1
314         ensure_dir "$contexts_dir" "exist"        314         ensure_dir "$contexts_dir" "exist"
315         ensure_file "$contexts_dir/nr_contexts    315         ensure_file "$contexts_dir/nr_contexts" "exist" 600
316                                                   316 
317         ensure_write_succ  "$contexts_dir/nr_c    317         ensure_write_succ  "$contexts_dir/nr_contexts" "1" "valid input"
318         test_context "$contexts_dir/0"            318         test_context "$contexts_dir/0"
319                                                   319 
320         ensure_write_fail "$contexts_dir/nr_co    320         ensure_write_fail "$contexts_dir/nr_contexts" "2" "only 0/1 are supported"
321         test_context "$contexts_dir/0"            321         test_context "$contexts_dir/0"
322                                                   322 
323         ensure_write_succ "$contexts_dir/nr_co    323         ensure_write_succ "$contexts_dir/nr_contexts" "0" "valid input"
324         ensure_dir "$contexts_dir/0" "not_exis    324         ensure_dir "$contexts_dir/0" "not_exist"
325 }                                                 325 }
326                                                   326 
327 test_kdamond()                                    327 test_kdamond()
328 {                                                 328 {
329         kdamond_dir=$1                            329         kdamond_dir=$1
330         ensure_dir "$kdamond_dir" "exist"         330         ensure_dir "$kdamond_dir" "exist"
331         ensure_file "$kdamond_dir/state" "exis    331         ensure_file "$kdamond_dir/state" "exist" "600"
332         ensure_file "$kdamond_dir/pid" "exist"    332         ensure_file "$kdamond_dir/pid" "exist" 400
333         test_contexts "$kdamond_dir/contexts"     333         test_contexts "$kdamond_dir/contexts"
334 }                                                 334 }
335                                                   335 
336 test_kdamonds()                                   336 test_kdamonds()
337 {                                                 337 {
338         kdamonds_dir=$1                           338         kdamonds_dir=$1
339         ensure_dir "$kdamonds_dir" "exist"        339         ensure_dir "$kdamonds_dir" "exist"
340                                                   340 
341         ensure_file "$kdamonds_dir/nr_kdamonds    341         ensure_file "$kdamonds_dir/nr_kdamonds" "exist" "600"
342                                                   342 
343         ensure_write_succ  "$kdamonds_dir/nr_k    343         ensure_write_succ  "$kdamonds_dir/nr_kdamonds" "1" "valid input"
344         test_kdamond "$kdamonds_dir/0"            344         test_kdamond "$kdamonds_dir/0"
345                                                   345 
346         ensure_write_succ  "$kdamonds_dir/nr_k    346         ensure_write_succ  "$kdamonds_dir/nr_kdamonds" "2" "valid input"
347         test_kdamond "$kdamonds_dir/0"            347         test_kdamond "$kdamonds_dir/0"
348         test_kdamond "$kdamonds_dir/1"            348         test_kdamond "$kdamonds_dir/1"
349                                                   349 
350         ensure_write_succ "$kdamonds_dir/nr_kd    350         ensure_write_succ "$kdamonds_dir/nr_kdamonds" "0" "valid input"
351         ensure_dir "$kdamonds_dir/0" "not_exis    351         ensure_dir "$kdamonds_dir/0" "not_exist"
352         ensure_dir "$kdamonds_dir/1" "not_exis    352         ensure_dir "$kdamonds_dir/1" "not_exist"
353 }                                                 353 }
354                                                   354 
355 test_damon_sysfs()                                355 test_damon_sysfs()
356 {                                                 356 {
357         damon_sysfs=$1                            357         damon_sysfs=$1
358         if [ ! -d "$damon_sysfs" ]                358         if [ ! -d "$damon_sysfs" ]
359         then                                      359         then
360                 echo "$damon_sysfs not found"     360                 echo "$damon_sysfs not found"
361                 exit $ksft_skip                   361                 exit $ksft_skip
362         fi                                        362         fi
363                                                   363 
364         test_kdamonds "$damon_sysfs/kdamonds"     364         test_kdamonds "$damon_sysfs/kdamonds"
365 }                                                 365 }
366                                                   366 
367 check_dependencies()                              367 check_dependencies()
368 {                                                 368 {
369         if [ $EUID -ne 0 ]                        369         if [ $EUID -ne 0 ]
370         then                                      370         then
371                 echo "Run as root"                371                 echo "Run as root"
372                 exit $ksft_skip                   372                 exit $ksft_skip
373         fi                                        373         fi
374 }                                                 374 }
375                                                   375 
376 check_dependencies                                376 check_dependencies
377 test_damon_sysfs "/sys/kernel/mm/damon/admin"     377 test_damon_sysfs "/sys/kernel/mm/damon/admin"
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php