You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autotest.sh 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 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. cat > ./tests/autoconfig-oci.php <<DELIM
  53. <?php
  54. \$AUTOCONFIG = array (
  55. 'installed' => false,
  56. 'dbtype' => 'oci',
  57. 'dbtableprefix' => 'oc_',
  58. 'adminlogin' => 'admin',
  59. 'adminpass' => 'admin',
  60. 'directory' => '$BASEDIR/$DATADIR',
  61. 'dbuser' => 'oc_autotest',
  62. 'dbname' => 'XE',
  63. 'dbhost' => 'localhost',
  64. 'dbpass' => 'owncloud',
  65. );
  66. DELIM
  67. function execute_tests {
  68. echo "Setup environment for $1 testing ..."
  69. # back to root folder
  70. cd $BASEDIR
  71. # revert changes to tests/data
  72. git checkout tests/data/*
  73. # reset data directory
  74. rm -rf $DATADIR
  75. mkdir $DATADIR
  76. # remove the old config file
  77. #rm -rf config/config.php
  78. cp tests/preseed-config.php config/config.php
  79. # drop database
  80. if [ "$1" == "mysql" ] ; then
  81. mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
  82. fi
  83. if [ "$1" == "pgsql" ] ; then
  84. dropdb -U oc_autotest oc_autotest
  85. fi
  86. if [ "$1" == "oci" ] ; then
  87. echo "drop the database"
  88. sqlplus -s -l / as sysdba <<EOF
  89. drop user oc_autotest cascade;
  90. EOF
  91. echo "create the database"
  92. sqlplus -s -l / as sysdba <<EOF
  93. create user oc_autotest identified by owncloud;
  94. alter user oc_autotest default tablespace users
  95. temporary tablespace temp
  96. quota unlimited on users;
  97. grant create session
  98. , create table
  99. , create procedure
  100. , create sequence
  101. , create trigger
  102. , create view
  103. , create synonym
  104. , alter session
  105. to oc_autotest;
  106. exit;
  107. EOF
  108. fi
  109. # copy autoconfig
  110. cp $BASEDIR/tests/autoconfig-$1.php $BASEDIR/config/autoconfig.php
  111. # trigger installation
  112. php -f index.php
  113. #test execution
  114. echo "Testing with $1 ..."
  115. cd tests
  116. rm -rf coverage-html-$1
  117. mkdir coverage-html-$1
  118. php -f enable_all.php
  119. if [ "$1" == "sqlite" ] ; then
  120. # coverage only with sqlite - causes segfault on ci.tmit.eu - reason unknown
  121. phpunit --configuration phpunit-autotest.xml --log-junit autotest-results-$1.xml --coverage-clover autotest-clover-$1.xml --coverage-html coverage-html-$1
  122. else
  123. phpunit --configuration phpunit-autotest.xml --log-junit autotest-results-$1.xml
  124. fi
  125. }
  126. #
  127. # start test execution
  128. #
  129. if [ -z "$1" ]
  130. then
  131. execute_tests "sqlite"
  132. execute_tests 'mysql'
  133. execute_tests 'pgsql'
  134. # we will add oci as soon as it's stable
  135. #execute_tests 'oci'
  136. else
  137. execute_tests $1
  138. fi
  139. #
  140. # NOTES on mysql:
  141. # - CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'owncloud';
  142. # - grant access permissions: grant all on oc_autotest.* to 'oc_autotest'@'localhost';
  143. #
  144. # NOTES on pgsql:
  145. # - su - postgres
  146. # - createuser -P (enter username and password and enable superuser)
  147. # - 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):
  148. # local all all trust
  149. #
  150. # NOTES on oci:
  151. # - it's a pure nightmare to install Oracle on a Linux-System
  152. # - DON'T TRY THIS AT HOME!
  153. # - if you really need it: we feel sorry for you
  154. #