Home | History | Annotate | Download | only in racer
      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 
     22 ## DESCRIPTION:
     23 ## This test creates 20 files (0 thru 19) and then shuffles them around,
     24 ## deletes, and recreates them as fast as possible.  This is all done in
     25 ## an effort to test for race conditions in the filesystem code. This test
     26 ## runs until killed or Ctrl-C'd.  It is suggested that it run overnight
     27 ## with preempt turned on to make the system more sensitive to race
     28 ## conditions.
     29 
     30 MAX_FILES=20
     31 CLEAR_SECS=30
     32 DIR="$TMPDIR/race"
     33 
     34 execute_test()
     35 {
     36 [ -e $DIR ] || mkdir $DIR
     37 ./fs_racer_file_create.sh $DIR $MAX_FILES &
     38 ./fs_racer_file_create.sh $DIR $MAX_FILES &
     39 ./fs_racer_file_create.sh $DIR $MAX_FILES &
     40 
     41 ./fs_racer_dir_create.sh $DIR $MAX_FILES &
     42 ./fs_racer_dir_create.sh $DIR $MAX_FILES &
     43 ./fs_racer_dir_create.sh $DIR $MAX_FILES &
     44 
     45 ./fs_racer_file_rename.sh $DIR $MAX_FILES &
     46 ./fs_racer_file_rename.sh $DIR $MAX_FILES &
     47 ./fs_racer_file_rename.sh $DIR $MAX_FILES &
     48 
     49 ./fs_racer_file_link.sh $DIR $MAX_FILES &
     50 ./fs_racer_file_link.sh $DIR $MAX_FILES &
     51 ./fs_racer_file_link.sh $DIR $MAX_FILES &
     52 
     53 ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
     54 ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
     55 ./fs_racer_file_symlink.sh $DIR $MAX_FILES &
     56 
     57 ./fs_racer_file_concat.sh $DIR $MAX_FILES &
     58 ./fs_racer_file_concat.sh $DIR $MAX_FILES &
     59 ./fs_racer_file_concat.sh $DIR $MAX_FILES &
     60 
     61 ./fs_racer_file_list.sh $DIR &
     62 ./fs_racer_file_list.sh $DIR &
     63 ./fs_racer_file_list.sh $DIR &
     64 
     65 ./fs_racer_file_rm.sh $DIR $MAX_FILES &
     66 ./fs_racer_file_rm.sh $DIR $MAX_FILES &
     67 ./fs_racer_file_rm.sh $DIR $MAX_FILES &
     68 }
     69 
     70 
     71 usage()
     72 {
     73     echo usage: fs_racer.sh -t DURATION [Execute the testsuite for given DURATION seconds]
     74     exit 0;
     75 }
     76 
     77 
     78 call_exit()
     79 {
     80     echo \"Cleaning up\"
     81     killall fs_racer_file_create.sh
     82     killall fs_racer_dir_create.sh
     83     killall fs_racer_file_rm.sh
     84     killall fs_racer_file_rename.sh
     85     killall fs_racer_file_link.sh
     86     killall fs_racer_file_symlink.sh
     87     killall fs_racer_file_list.sh
     88     killall fs_racer_file_concat.sh
     89     rm -rf $DIR
     90     exit 0
     91 }
     92 
     93 while getopts :t: arg
     94 do  case $arg in
     95     t)  execute_test
     96         sleep $OPTARG
     97         call_exit;;
     98     \?) usage;;
     99     esac
    100 done
    101 
    102 exit 0
    103 
    104