3 TEXT_ERROR='\033[0;31mError: \033[0m'
4 TEXT_INFO='\033[0;32mInfo: \033[0m'
8 echo "usage: $0 [-h] [-b [BUILT_TYPE]] [-i [PACKAGE]] [-t]\n"
9 echo "Tool for easy building, installing and running tests of Universal Switch."
10 echo "Requires getopt, gbs and sdb.\n"
12 echo "-h,--help print this message"
13 echo "-bBUILT_TYPE,--build=BUILT_TYPE build repository using GBS, available types are: 'initial', 'fast', 'no-tests', default value is 'fast'"
14 echo "-iPACKAGE,--install=PACKAGE install package on connected target, available packages are: 'base', 'tests', 'all', default value is 'all'"
15 echo "-t,--run-tests run tests on connected target"
16 echo "-j,--clean-journal vacuum systemd journal on target"
22 if [ "$?" -ne 0 ]; then
23 echo $TEXT_ERROR"Command sdb cannot be found, check if it is installed and its directory is added to PATH"
28 check_if_target_connected()
32 sdb devices | grep "device " 1>/dev/null
33 if [ "$?" -ne 0 ]; then
34 echo $TEXT_ERROR"Target not connected"
43 check_if_target_connected
45 sdb -d shell mount -o remount,rw /
47 cp "$@" "$TMP" 2>/dev/null
49 sdb push "$TMP" "$TMP"
50 sdb -d shell rpm -Uvh --force "$TMP"/*
62 DEFAULT_BUILT_TYPE="fast"
63 DEFAULT_INSTALL_TYPE="all"
64 VERSION=`awk '/Version/ {print $2}' packaging/org.tizen.universal-switch.spec`
65 RELEASE=`awk '/Release/ {print $2}' packaging/org.tizen.universal-switch.spec`
67 ARGUMENTS=`getopt -o hb::i::tj -l help,build::,install::,run-tests,clean-journal -n "$0" -- "$@"`
73 eval set -- "$ARGUMENTS"
75 while [ $# -gt 0 ]; do
92 BUILD_DIR="$HOME/GBS-ROOT/local/BUILD-ROOTS/scratch.armv7l.0/home/abuild/rpmbuild/BUILD/org.tizen.universal-switch-$VERSION"
93 if [ -d "$BUILD_DIR" ]; then
110 INSTALL_PACKAGE="$DEFAULT_INSTALL_TYPE"
121 sdb -d shell mount -o remount,rw /
122 sdb push "tests/dbustests.conf" "/etc/dbus-1/system.d/"
123 sdb -d shell killall -HUP dbus-daemon
128 '-j'|'--clean-journal')
134 echo "Invalid option, use '--help' for available options"
140 if [ "$BUILD_TYPE" != "" ]; then
142 echo $TEXT_INFO"Build type: "$BUILD_TYPE" chosen"
144 case "$BUILD_TYPE" in
146 gbs build -A armv7l --include-all --ccache --define "jobs 4"
151 gbs build -A armv7l --include-all --noinit --ccache --keep-packs --define "jobs 4"
156 gbs build -A armv7l --include-all --noinit --ccache --keep-packs --define "_without_tests 1" --define "jobs 4"
161 echo $TEXT_ERROR"Cannot build, valid options for building are: initial, fast, no-tests"
167 if [ "$INSTALL_PACKAGE" != "" ]; then
168 GBS_PATH="$HOME/GBS-ROOT/local/repos/public_mobile/armv7l/RPMS"
169 BASE_PACKAGE_NAME="$GBS_PATH/org.tizen.universal-switch-$VERSION-$RELEASE.armv7l.rpm"
170 TEST_PACKAGE_NAME="$GBS_PATH/org.tizen.universal-switch-tests-$VERSION-$RELEASE.armv7l.rpm"
171 TEST_LIB_PACKAGE_NAME="$HOME/GBS-ROOT/local/cache/*/gtest-[0-9]*"
173 case "$INSTALL_PACKAGE" in
175 if [ -f "$BASE_PACKAGE_NAME" ]; then
176 BASE_FILE="$BASE_PACKAGE_NAME"
178 echo $TEXT_ERROR"Base package not found, check if it was built."
184 if [ -f "$TEST_PACKAGE_NAME" ]; then
185 TEST_FILE="$TEST_PACKAGE_NAME"
186 LIB_FILE="$TEST_LIB_PACKAGE_NAME"
188 echo $TEXT_ERROR"Test package not found, check if it was built."
194 if [ -f "$BASE_PACKAGE_NAME" -a -f "$TEST_PACKAGE_NAME" ]; then
195 BASE_FILE="$BASE_PACKAGE_NAME"
196 TEST_FILE="$TEST_PACKAGE_NAME"
197 LIB_FILE="$TEST_LIB_PACKAGE_NAME"
199 echo $TEXT_ERROR"Not all packages exist, check if they were built."
205 echo $TEXT_ERROR"Cannot install, valid options for installing are: base, tests, all"
210 check_if_target_connected
212 echo $TEXT_INFO"Following packages will be installed: $BASE_FILE $TEST_FILE $LIB_FILE"
213 rpm_install "$BASE_FILE" "$TEST_FILE" $LIB_FILE
216 if [ $CLEAN_JOURNAL -eq 1 ]; then
217 check_if_target_connected
219 sdb shell 'journalctl --vacuum-size=1K'
222 if [ $RUN_TESTS -eq 1 ]; then
223 check_if_target_connected
225 echo $TEXT_INFO"Setting vconf keys..."
226 dir="$(dirname "$0")"
227 "$dir"/utils/setVconfKeys.sh "accessibilityTests/"
233 for i in /usr/apps/org.tizen.universal-switch-tests/no-ui-scenarios/*
238 echo "Tests with Graphical User Interface"
239 UI_PID=`app_launcher -s org.tizen.universal-switch-tests | sed "s/^.*pid \= \([[:digit:]]*\).*$/\1/"`
240 journalctl --since "$DATE" -f | grep universal-switch-tests &
241 while kill -0 $UI_PID 2> /dev/null