File: script.sh

package info (click to toggle)
mariadb-10.0 10.0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 416,512 kB
  • sloc: cpp: 1,351,103; ansic: 803,086; perl: 59,621; pascal: 32,136; sh: 25,156; yacc: 14,897; xml: 5,194; sql: 4,651; cs: 4,647; makefile: 4,113; python: 2,526; ruby: 2,496; lex: 1,427; asm: 295; awk: 54; php: 22; sed: 16
file content (120 lines) | stat: -rwxr-xr-x 3,120 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# Copyright(C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# set -x
set -e

base_dir="$(cd $(dirname $0); pwd)"
top_dir="${base_dir}/../.."

bundled_mroonga_dir="${top_dir}/storage/mroonga"
if [ -f "${bundled_mroonga_dir}/config.sh" ]; then
    mroonga_dir="${bundled_mroonga_dir}"
    . "${bundled_mroonga_dir}/config.sh"
else
    mroonga_dir="${top_dir}"
    . "${top_dir}/config.sh"
fi

n_processors="$(grep '^processor' /proc/cpuinfo | wc -l)"
max_n_processors=8
if (( $n_processors > $max_n_processors )); then
    n_processors=$max_n_processors
fi

build()
{
    if [ "${MROONGA_BUNDLED}" = "yes" ]; then
	make > /dev/null
    else
	make -j${n_processors} > /dev/null
    fi
}

run_unit_test()
{
    if [ "${MROONGA_BUNDLED}" != "yes" ]; then
	NO_MAKE=yes ${mroonga_dir}/test/run-unit-test.sh
    fi
}

prepare_mysql_test_dir()
{
    mysql_test_dir=/usr/mysql-test
    if [ -d /usr/lib/mysql-testsuite/ ]; then
	sudo cp -a /usr/lib/mysql-testsuite/ ${mysql_test_dir}/
    elif [ -d /usr/share/mysql/mysql-test/ ]; then
	sudo cp -a /usr/share/mysql/mysql-test/ ${mysql_test_dir}/
    elif [ -d /opt/mysql/ ]; then
	mysql_test_dir=$(echo /opt/mysql/server-*/mysql-test)
    else
	sudo cp -a ${MYSQL_SOURCE_DIR}/mysql-test/ ${mysql_test_dir}/
    fi
    sudo chown -R $(id -u):$(id -g) ${mysql_test_dir}/

    cp -a ${mroonga_dir}/mysql-test/mroonga/ ${mysql_test_dir}/suite/
}

collect_test_suite_names()
{
    cd ${mysql_test_dir}/suite/
    test_suite_names=""
    for test_suite_name in $(find mroonga -type d '!' -name '[tr]'); do
	if [ -n "${test_suite_names}" ]; then
	    test_suite_names="${test_suite_names},"
	fi
	test_suite_names="${test_suite_names}${test_suite_name}"
    done
    cd -
}

prepare_sql_test()
{
    sudo make install > /dev/null
    prepare_mysql_test_dir
    collect_test_suite_names
}

run_sql_test()
{
    test_args=()
    if [ "${MROONGA_TEST_EMBEDDED}" = "yes" ]; then
	test_args=("${test_args[@]}" "--embedded-server")
    fi

    if [ "${MROONGA_BUNDLED}" = "yes" ]; then
	${mroonga_dir}/test/run-sql-test.sh \
	  "${test_args[@]}" \
	  --parallel="${n_processors}"
    else
	prepare_sql_test

	cd ${mysql_test_dir}/
	./mysql-test-run.pl \
	    "${test_args[@]}" \
	    --no-check-testcases \
	    --parallel="${n_processors}" \
	    --retry=1 \
	    --suite="${test_suite_names}" \
	    --force
    fi
}

build
# run_unit_test
run_sql_test