udelay_test.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. # udelay() test script
  4. #
  5. # Test is executed by writing and reading to /sys/kernel/debug/udelay_test
  6. # and exercises a variety of delays to ensure that udelay() is delaying
  7. # at least as long as requested (as compared to ktime).
  8. #
  9. # Copyright (C) 2014 Google, Inc.
  10. #
  11. MODULE_NAME=udelay_test
  12. UDELAY_PATH=/sys/kernel/debug/udelay_test
  13. setup()
  14. {
  15. /sbin/modprobe -q $MODULE_NAME
  16. tmp_file=`mktemp`
  17. }
  18. test_one()
  19. {
  20. delay=$1
  21. echo $delay > $UDELAY_PATH
  22. tee -a $tmp_file < $UDELAY_PATH
  23. }
  24. cleanup()
  25. {
  26. if [ -f $tmp_file ]; then
  27. rm $tmp_file
  28. fi
  29. /sbin/modprobe -q -r $MODULE_NAME
  30. }
  31. trap cleanup EXIT
  32. setup
  33. # Delay for a variety of times.
  34. # 1..200, 200..500 (by 10), 500..2000 (by 100)
  35. for (( delay = 1; delay < 200; delay += 1 )); do
  36. test_one $delay
  37. done
  38. for (( delay = 200; delay < 500; delay += 10 )); do
  39. test_one $delay
  40. done
  41. for (( delay = 500; delay <= 2000; delay += 100 )); do
  42. test_one $delay
  43. done
  44. # Search for failures
  45. count=`grep -c FAIL $tmp_file`
  46. if [ $? -eq "0" ]; then
  47. echo "ERROR: $count delays failed to delay long enough"
  48. retcode=1
  49. fi
  50. exit $retcode