mkdb-correctness.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. mkdir check.repo
  27. cp -r ../client/exp check.repo/
  28. cd check.repo
  29. mkdir reception
  30. if [[ -f source.random ]]
  31. then
  32. echo "Reusing the source.random file"
  33. else
  34. echo "Creating the source.random file"
  35. dd if=/dev/urandom of=source.random count=`python -c"print( int($ONE_GBIT / (1024000) ) );"` bs=128000
  36. fi
  37. echo "Creating the databases .."
  38. for DB in $ONE_MBIT $TEN_MBIT $HUNDRED_MBIT $ONE_GBIT
  39. do
  40. for L in $HUNDRED_KBIT $TEN_MBIT $ONE_GBIT $ONE_KBIT
  41. do
  42. N=`python -c"print( int($DB / $L) );"`
  43. # Only build directories with 1000 or less files
  44. if [[ ( $DB -gt $L ) && ( $N -le 1000 )]];
  45. then
  46. #First we need to obtain the appropriate parameters for N and L fixed
  47. L_KBIT=`python -c"print( int($L / 1024) );"`
  48. L_BYTE=`python -c"print( int($L / 8) );"`
  49. rm -fr db
  50. mkdir db
  51. dd if=source.random of=db/test1 count=$L_KBIT bs=128
  52. cd db
  53. for (( i = 2 ; i <= $N ; i++ ))
  54. do
  55. ln -s test1 test$i
  56. done
  57. cd ..
  58. mv db db-$L_BYTE-$N
  59. fi
  60. done
  61. # For tests with more than 1000 files use a single file with split_file option
  62. rm -fr db
  63. mkdir db
  64. dd if=source.random of=db/test1 count=`python -c"print( int($DB / 1024000) );"` bs=128000
  65. mv db db-`python -c"print( int($DB / 8) );"`
  66. done
  67. rm -f source.random
  68. cd ..