drm/bridge: adv7511: Switch to atomic operations
[drm/drm-misc.git] / tools / testing / selftests / damon / _debugfs_common.sh
blob54d45791b0d9cb8875956bb0aa89471244e40686
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 test_write_result() {
5 file=$1
6 content=$2
7 orig_content=$3
8 expect_reason=$4
9 expected=$5
11 if [ "$expected" = "0" ]
12 then
13 echo "$content" > "$file"
14 else
15 echo "$content" > "$file" 2> /dev/null
17 if [ $? -ne "$expected" ]
18 then
19 echo "writing $content to $file doesn't return $expected"
20 echo "expected because: $expect_reason"
21 echo "$orig_content" > "$file"
22 exit 1
26 test_write_succ() {
27 test_write_result "$1" "$2" "$3" "$4" 0
30 test_write_fail() {
31 test_write_result "$1" "$2" "$3" "$4" 1
34 test_content() {
35 file=$1
36 orig_content=$2
37 expected=$3
38 expect_reason=$4
40 content=$(cat "$file")
41 if [ "$content" != "$expected" ]
42 then
43 echo "reading $file expected $expected but $content"
44 echo "expected because: $expect_reason"
45 echo "$orig_content" > "$file"
46 exit 1
50 source ./_chk_dependency.sh
52 damon_onoff="$DBGFS/monitor_on"
53 if [ -f "$DBGFS/monitor_on_DEPRECATED" ]
54 then
55 damon_onoff="$DBGFS/monitor_on_DEPRECATED"
56 else
57 damon_onoff="$DBGFS/monitor_on"
60 if [ $(cat "$damon_onoff") = "on" ]
61 then
62 echo "monitoring is on"
63 exit $ksft_skip