_debugfs_common.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. test_write_result() {
  4. file=$1
  5. content=$2
  6. orig_content=$3
  7. expect_reason=$4
  8. expected=$5
  9. echo "$content" > "$file"
  10. if [ $? -ne "$expected" ]
  11. then
  12. echo "writing $content to $file doesn't return $expected"
  13. echo "expected because: $expect_reason"
  14. echo "$orig_content" > "$file"
  15. exit 1
  16. fi
  17. }
  18. test_write_succ() {
  19. test_write_result "$1" "$2" "$3" "$4" 0
  20. }
  21. test_write_fail() {
  22. test_write_result "$1" "$2" "$3" "$4" 1
  23. }
  24. test_content() {
  25. file=$1
  26. orig_content=$2
  27. expected=$3
  28. expect_reason=$4
  29. content=$(cat "$file")
  30. if [ "$content" != "$expected" ]
  31. then
  32. echo "reading $file expected $expected but $content"
  33. echo "expected because: $expect_reason"
  34. echo "$orig_content" > "$file"
  35. exit 1
  36. fi
  37. }
  38. source ./_chk_dependency.sh
  39. damon_onoff="$DBGFS/monitor_on"
  40. if [ -f "$DBGFS/monitor_on_DEPRECATED" ]
  41. then
  42. damon_onoff="$DBGFS/monitor_on_DEPRECATED"
  43. else
  44. damon_onoff="$DBGFS/monitor_on"
  45. fi
  46. if [ $(cat "$damon_onoff") = "on" ]
  47. then
  48. echo "monitoring is on"
  49. exit $ksft_skip
  50. fi