fs_racer.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. ################################################################################
  3. ## ##
  4. ## Copyright (c) Dan Carpenter., 2004 ##
  5. ## ##
  6. ## This program is free software; you can redistribute it and#or modify ##
  7. ## it under the terms of the GNU General Public License as published by ##
  8. ## the Free Software Foundation; either version 2 of the License, or ##
  9. ## (at your option) any later version. ##
  10. ## ##
  11. ## This program is distributed in the hope that it will be useful, but ##
  12. ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
  13. ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
  14. ## for more details. ##
  15. ## ##
  16. ## You should have received a copy of the GNU General Public License ##
  17. ## along with this program; if not, write to the Free Software ##
  18. ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  19. ## ##
  20. ################################################################################
  21. ## DESCRIPTION:
  22. ## This test creates 20 files (0 thru 19) and then shuffles them around,
  23. ## deletes, and recreates them as fast as possible. This is all done in
  24. ## an effort to test for race conditions in the filesystem code. This test
  25. ## runs until killed or Ctrl-C'd. It is suggested that it run overnight
  26. ## with preempt turned on to make the system more sensitive to race
  27. ## conditions.
  28. MAX_FILES=20
  29. CLEAR_SECS=30
  30. DIR="$TMPDIR/race"
  31. execute_test()
  32. {
  33. [ -e $DIR ] || mkdir $DIR
  34. ./fs_racer_file_create.sh $DIR $MAX_FILES &
  35. ./fs_racer_file_create.sh $DIR $MAX_FILES &
  36. ./fs_racer_file_create.sh $DIR $MAX_FILES &
  37. ./fs_racer_dir_create.sh $DIR $MAX_FILES &
  38. ./fs_racer_dir_create.sh $DIR $MAX_FILES &
  39. ./fs_racer_dir_create.sh $DIR $MAX_FILES &
  40. ./fs_racer_file_rename.sh $DIR $MAX_FILES &
  41. ./fs_racer_file_rename.sh $DIR $MAX_FILES &
  42. ./fs_racer_file_rename.sh $DIR $MAX_FILES &
  43. ./fs_racer_file_link.sh $DIR $MAX_FILES &
  44. ./fs_racer_file_link.sh $DIR $MAX_FILES &
  45. ./fs_racer_file_link.sh $DIR $MAX_FILES &
  46. ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
  47. ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
  48. ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
  49. ./fs_racer_file_concat.sh $DIR $MAX_FILES &
  50. ./fs_racer_file_concat.sh $DIR $MAX_FILES &
  51. ./fs_racer_file_concat.sh $DIR $MAX_FILES &
  52. ./fs_racer_file_list.sh $DIR &
  53. ./fs_racer_file_list.sh $DIR &
  54. ./fs_racer_file_list.sh $DIR &
  55. ./fs_racer_file_rm.sh $DIR $MAX_FILES &
  56. ./fs_racer_file_rm.sh $DIR $MAX_FILES &
  57. ./fs_racer_file_rm.sh $DIR $MAX_FILES &
  58. }
  59. usage()
  60. {
  61. echo usage: fs_racer.sh -t DURATION [Execute the testsuite for given DURATION seconds]
  62. exit 0;
  63. }
  64. call_exit()
  65. {
  66. echo \"Cleaning up\"
  67. killall fs_racer_file_create.sh
  68. killall fs_racer_dir_create.sh
  69. killall fs_racer_file_rm.sh
  70. killall fs_racer_file_rename.sh
  71. killall fs_racer_file_link.sh
  72. killall fs_racer_file_symlink.sh
  73. killall fs_racer_file_list.sh
  74. killall fs_racer_file_concat.sh
  75. rm -rf $DIR
  76. exit 0
  77. }
  78. while getopts :t: arg
  79. do case $arg in
  80. t) execute_test
  81. sleep $OPTARG
  82. call_exit;;
  83. \?) usage;;
  84. esac
  85. done
  86. exit 0