udelay_test.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # udelay() test script
  3. #
  4. # Test is executed by writing and reading to /sys/kernel/debug/udelay_test
  5. # and exercises a variety of delays to ensure that udelay() is delaying
  6. # at least as long as requested (as compared to ktime).
  7. #
  8. # Copyright (C) 2014 Google, Inc.
  9. #
  10. # This software is licensed under the terms of the GNU General Public
  11. # License version 2, as published by the Free Software Foundation, and
  12. # may be copied, distributed, and modified under those terms.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. MODULE_NAME=udelay_test
  19. UDELAY_PATH=/sys/kernel/debug/udelay_test
  20. setup()
  21. {
  22. /sbin/modprobe -q $MODULE_NAME
  23. tmp_file=`mktemp`
  24. }
  25. test_one()
  26. {
  27. delay=$1
  28. echo $delay > $UDELAY_PATH
  29. tee -a $tmp_file < $UDELAY_PATH
  30. }
  31. cleanup()
  32. {
  33. if [ -f $tmp_file ]; then
  34. rm $tmp_file
  35. fi
  36. /sbin/modprobe -q -r $MODULE_NAME
  37. }
  38. trap cleanup EXIT
  39. setup
  40. # Delay for a variety of times.
  41. # 1..200, 200..500 (by 10), 500..2000 (by 100)
  42. for (( delay = 1; delay < 200; delay += 1 )); do
  43. test_one $delay
  44. done
  45. for (( delay = 200; delay < 500; delay += 10 )); do
  46. test_one $delay
  47. done
  48. for (( delay = 500; delay <= 2000; delay += 100 )); do
  49. test_one $delay
  50. done
  51. # Search for failures
  52. count=`grep -c FAIL $tmp_file`
  53. if [ $? -eq "0" ]; then
  54. echo "ERROR: $count delays failed to delay long enough"
  55. retcode=1
  56. fi
  57. exit $retcode