autotest.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # @author Thomas Müller
  6. # @copyright 2012 Thomas Müller thomas.mueller@tmit.eu
  7. #
  8. DATADIR=data-autotest
  9. BASEDIR=$PWD
  10. # create autoconfig for sqlite, mysql and (soon) postgresql
  11. cat > ./tests/autoconfig-sqlite.php <<DELIM
  12. <?php
  13. \$AUTOCONFIG = array (
  14. 'installed' => false,
  15. 'dbtype' => 'sqlite',
  16. 'dbtableprefix' => 'oc_',
  17. 'adminlogin' => 'admin',
  18. 'adminpass' => 'admin',
  19. 'directory' => '$BASEDIR/$DATADIR',
  20. );
  21. DELIM
  22. cat > ./tests/autoconfig-mysql.php <<DELIM
  23. <?php
  24. \$AUTOCONFIG = array (
  25. 'installed' => false,
  26. 'dbtype' => 'mysql',
  27. 'dbtableprefix' => 'oc_',
  28. 'adminlogin' => 'admin',
  29. 'adminpass' => 'admin',
  30. 'directory' => '$BASEDIR/$DATADIR',
  31. 'dbuser' => 'oc_autotest',
  32. 'dbname' => 'oc_autotest',
  33. 'dbhost' => 'localhost',
  34. 'dbpass' => 'owncloud',
  35. );
  36. DELIM
  37. cat > ./tests/autoconfig-pgsql.php <<DELIM
  38. <?php
  39. \$AUTOCONFIG = array (
  40. 'installed' => false,
  41. 'dbtype' => 'pgsql',
  42. 'dbtableprefix' => 'oc_',
  43. 'adminlogin' => 'admin',
  44. 'adminpass' => 'admin',
  45. 'directory' => '$BASEDIR/$DATADIR',
  46. 'dbuser' => 'oc_autotest',
  47. 'dbname' => 'oc_autotest',
  48. 'dbhost' => 'localhost',
  49. 'dbpass' => 'owncloud',
  50. );
  51. DELIM
  52. function execute_tests {
  53. echo "Setup environment for $1 testing ..."
  54. # back to root folder
  55. cd $BASEDIR
  56. # revert changes to tests/data
  57. git checkout tests/data/*
  58. # reset data directory
  59. rm -rf $DATADIR
  60. mkdir $DATADIR
  61. # remove the old config file
  62. rm -rf config/config.php
  63. # drop database
  64. if [ "$1" == "mysql" ] ; then
  65. mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
  66. fi
  67. if [ "$1" == "pgsql" ] ; then
  68. dropdb -U oc_autotest oc_autotest
  69. fi
  70. # copy autoconfig
  71. cp $BASEDIR/tests/autoconfig-$1.php $BASEDIR/config/autoconfig.php
  72. # trigger installation
  73. php -f index.php
  74. #test execution
  75. echo "Testing with $1 ..."
  76. cd tests
  77. php -f index.php -- xml $1 > autotest-results-$1.xml
  78. }
  79. #
  80. # start test execution
  81. #
  82. execute_tests "sqlite"
  83. execute_tests 'mysql'
  84. execute_tests 'pgsql'
  85. #
  86. # NOTES on mysql:
  87. # - CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud';
  88. # - grant access permissions: grant all on oc_autotest.* to 'oc_autotest'@'localhost';
  89. #
  90. # NOTES on pgsql:
  91. # - su - postgres
  92. # - createuser -P (enter username and password and enable superuser)
  93. # - to enable dropdb I decided to add following line to pg_hba.conf (this is not the safest way but I don't care for the testing machine):
  94. # local all all trust
  95. #