mkdb-correctness.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. #/* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  3. # * This file is part of XPIR.
  4. # *
  5. # * XPIR is free software: you can redistribute it and/or modify
  6. # * it under the terms of the GNU General Public License as published by
  7. # * the Free Software Foundation, either version 3 of the License, or
  8. # * (at your option) any later version.
  9. # *
  10. # * XPIR is distributed in the hope that it will be useful,
  11. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # * GNU General Public License for more details.
  14. # *
  15. # * You should have received a copy of the GNU General Public License
  16. # * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  17. #*/
  18. ONE_KBIT=1024
  19. HUNDRED_KBIT=102400
  20. ONE_MBIT=1024000
  21. TEN_MBIT=10240000
  22. HUNDRED_MBIT=102400000
  23. ONE_GBIT=1024000000
  24. #files: 1kbits, 100kbits, 10mbits 1gbit
  25. #bases: 1Mbits, 10M, 100M, 1G, 10G
  26. if [[ -e check.repo ]]
  27. then
  28. echo "Check repo exists, not rebuilding it"
  29. echo "Remove it manually if you want it rebuilt"
  30. exit
  31. fi
  32. mkdir check.repo
  33. cp -r ../client/exp check.repo/
  34. cd check.repo
  35. mkdir reception
  36. if [[ -f source.random ]]
  37. then
  38. echo "Reusing the source.random file"
  39. else
  40. echo "Creating the source.random file"
  41. dd if=/dev/urandom of=source.random count=`python -c"print( int($ONE_GBIT / (1024000) ) );"` bs=128000
  42. fi
  43. echo "Creating the databases .."
  44. for DB in $ONE_MBIT $TEN_MBIT $HUNDRED_MBIT $ONE_GBIT
  45. do
  46. for L in $HUNDRED_KBIT $TEN_MBIT $ONE_GBIT $ONE_KBIT
  47. do
  48. N=`python -c"print( int($DB / $L) );"`
  49. # Only build directories with 1000 or less files
  50. if [[ ( $DB -gt $L ) && ( $N -le 1000 )]];
  51. then
  52. #First we need to obtain the appropriate parameters for N and L fixed
  53. L_KBIT=`python -c"print( int($L / 1024) );"`
  54. L_BYTE=`python -c"print( int($L / 8) );"`
  55. rm -fr db
  56. mkdir db
  57. dd if=source.random of=db/test1 count=$L_KBIT bs=128
  58. cd db
  59. for (( i = 2 ; i <= $N ; i++ ))
  60. do
  61. ln -s test1 test$i
  62. done
  63. cd ..
  64. mv db db-$L_BYTE-$N
  65. fi
  66. done
  67. # For tests with more than 1000 files use a single file with split_file option
  68. rm -fr db
  69. mkdir db
  70. dd if=source.random of=db/test1 count=`python -c"print( int($DB / 1024000) );"` bs=128000
  71. mv db db-`python -c"print( int($DB / 8) );"`
  72. done
  73. rm -f source.random
  74. cd ..