Advertisement
CSenshi

OS - FUSE (test files)

Jul 12th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # to run please change mode
  4. # chmod +x check_dir.bash
  5.  
  6. if [ "$#" -ne 1 ]; then
  7.     echo "Illegal number of parameters"
  8.     echo 'Call : ./check_dir.sh mounted_dir'
  9.     exit 1
  10. fi
  11.  
  12. MOUNT_DIR=$1
  13. cd $MOUNT_DIR
  14.  
  15. CMD="#### Command : "
  16.  
  17. test1(){
  18.     echo "Test 1 : Creating $1 Files ..."
  19.     for i in $(seq 1 $1);
  20.     do
  21.         echo $CMD touch file_$i
  22.         touch file_$i
  23.     done
  24.    
  25.     echo $CMD 'ls :'
  26.     ls
  27.    
  28.     echo "Done!"
  29.     echo
  30. }
  31.  
  32. test2(){
  33.     echo "Test 2 : Read/Write from subdirectories..."
  34.    
  35.     TEST_FILE="TEST_FILE.txt"
  36.     TEST_CONTENT="PLEASE END MY SUFFERING!!!"
  37.    
  38.     echo "$CMD echo $TEST_CONTENT > $TEST_FILE"
  39.     echo $TEST_CONTENT > $TEST_FILE
  40.    
  41.     echo "$CMD cat $TEST_FILE"
  42.     cat $TEST_FILE
  43.    
  44.     echo "Done!"
  45.     echo
  46. }
  47.  
  48. test3(){
  49.     echo "Test 3 : Create files inside directories"
  50.    
  51.     dir1="dir1"
  52.     dir2="$dir1/dir2"
  53.     dir3="$dir2/dir3"
  54.    
  55.     echo "$CMD mkdir $dir1"
  56.     mkdir $dir1
  57.     echo "$CMD mkdir $dir2"
  58.     mkdir $dir2
  59.     echo "$CMD mkdir $dir3"
  60.     mkdir $dir3
  61.    
  62.     TEST_FILE="$dir3/DONT_OPEN.txt"
  63.     TEST_CONTENT="You Rebel!!!"
  64.    
  65.     echo "$CMD echo TEST_CONTENT > $TEST_FILE"
  66.     echo $TEST_CONTENT > $TEST_FILE
  67.    
  68.     echo "$CMD cat $TEST_FILE"
  69.     cat $TEST_FILE
  70.     echo
  71.    
  72.     echo "Done!"
  73.     echo
  74. }
  75.  
  76.  
  77. test4(){
  78.     echo "Test 4 : Write/Append Data"
  79.    
  80.     TEST_FILE="test_append.txt"
  81.    
  82.     TEST_CONTENT="KILL!!!"
  83.     echo "$CMD echo TEST_CONTENT >> $TEST_FILE"
  84.     echo $TEST_CONTENT >> $TEST_FILE
  85.    
  86.     TEST_CONTENT="ME!!!"
  87.     echo "$CMD echo TEST_CONTENT >> $TEST_FILE"
  88.     echo $TEST_CONTENT >> $TEST_FILE
  89.    
  90.     TEST_CONTENT="NOW!!!"
  91.     echo "$CMD echo TEST_CONTENT >> $TEST_FILE"
  92.     echo $TEST_CONTENT >> $TEST_FILE
  93.    
  94.     TEST_CONTENT="FAST!!!"
  95.     echo "$CMD echo TEST_CONTENT >> $TEST_FILE"
  96.     echo $TEST_CONTENT >> $TEST_FILE
  97.    
  98.     echo "$CMD cat $TEST_FILE"
  99.     cat $TEST_FILE
  100.     echo
  101.    
  102.     echo "Done!"
  103.     echo
  104. }
  105.  
  106. run_test(){
  107.     # Base Test Make 10 files
  108.     test1 10
  109.    
  110.     # Read and Write from file
  111.     test2
  112.    
  113.     # Write data inside directories
  114.     test3
  115.    
  116.     # Write and append data
  117.     test4
  118. }
  119.  
  120.  
  121. START=$(date +%s.%N)
  122. run_test
  123. END=$(date +%s.%N)
  124. DIFF=$(echo "$END - $START" | bc)
  125.  
  126. echo "Elapsed time : $DIFF seconds"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement