test_common.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #
  2. # Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. #
  9. # Initial Contributors:
  10. # Nokia Corporation - initial contribution.
  11. #
  12. # Contributors:
  13. #
  14. # Description:
  15. #
  16. # Test environment setup script for caseless fuse filesystem.
  17. # This script should be sourced rather than executed (hence
  18. # no #! at the top).
  19. # The functions cleanup and init are used to set up and tear
  20. # down the test directories and mounts.
  21. # the doit function is used to wrap tests
  22. CFBIN=./caseless-fuse
  23. MOUNTSOURCE=$PWD/test_source
  24. MOUNTPOINT=$PWD/test_mount
  25. FUSEOPTS="-o big_writes,direct_io,max_write=$[ 1024*1024*1024 ]"
  26. export CFBIN MOUNTSOURCE MOUNTPOINT FUSEOPTS
  27. doit() {
  28. FSTESTNAME="$1"
  29. echo "$1 : {"
  30. CMDS=""
  31. read C
  32. while [ $? -eq 0 ]; do
  33. CMDS="$CMDS $C"
  34. read C
  35. done
  36. set -x
  37. eval "$CMDS"
  38. rv=$?
  39. set +x
  40. echo "}"
  41. return $rv
  42. }
  43. init() {
  44. doit "init" <<EOT1
  45. mkdir "$MOUNTPOINT" &&
  46. mkdir "$MOUNTSOURCE" && set -x &&
  47. "$CFBIN" $FUSEOPTS "$MOUNTPOINT" "$MOUNTSOURCE" ; echo "init state: $?"
  48. EOT1
  49. }
  50. cleanup() {
  51. doit "cleanup" <<EOT2
  52. fusermount -u "$MOUNTPOINT";
  53. rm -rf "$MOUNTPOINT"
  54. rm -rf "$MOUNTSOURCE"
  55. EOT2
  56. }