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"
125 '-j'|'--clean-journal')
131 echo "Invalid option, use '--help' for available options"
137 if [ "$BUILD_TYPE" != "" ]; then
139 echo $TEXT_INFO"Build type: "$BUILD_TYPE" chosen"
141 case "$BUILD_TYPE" in
143 gbs build -A armv7l --include-all --ccache --define "jobs 4"
148 gbs build -A armv7l --include-all --noinit --ccache --keep-packs --define "jobs 4"
153 gbs build -A armv7l --include-all --noinit --ccache --keep-packs --define "_without_tests 1" --define "jobs 4"
158 echo $TEXT_ERROR"Cannot build, valid options for building are: initial, fast, no-tests"
164 if [ "$INSTALL_PACKAGE" != "" ]; then
165 GBS_PATH="$HOME/GBS-ROOT/local/repos/public_mobile/armv7l/RPMS"
166 BASE_PACKAGE_NAME="$GBS_PATH/org.tizen.universal-switch-$VERSION-$RELEASE.armv7l.rpm"
167 TEST_PACKAGE_NAME="$GBS_PATH/org.tizen.universal-switch-tests-$VERSION-$RELEASE.armv7l.rpm"
168 TEST_LIB_PACKAGE_NAME="$HOME/GBS-ROOT/local/cache/*/gtest-[0-9]*"
170 case "$INSTALL_PACKAGE" in
172 if [ -f "$BASE_PACKAGE_NAME" ]; then
173 BASE_FILE="$BASE_PACKAGE_NAME"
175 echo $TEXT_ERROR"Base package not found, check if it was built."
181 if [ -f "$TEST_PACKAGE_NAME" ]; then
182 TEST_FILE="$TEST_PACKAGE_NAME"
183 LIB_FILE="$TEST_LIB_PACKAGE_NAME"
185 echo $TEXT_ERROR"Test package not found, check if it was built."
191 if [ -f "$BASE_PACKAGE_NAME" -a -f "$TEST_PACKAGE_NAME" ]; then
192 BASE_FILE="$BASE_PACKAGE_NAME"
193 TEST_FILE="$TEST_PACKAGE_NAME"
194 LIB_FILE="$TEST_LIB_PACKAGE_NAME"
196 echo $TEXT_ERROR"Not all packages exist, check if they were built."
202 echo $TEXT_ERROR"Cannot install, valid options for installing are: base, tests, all"
207 check_if_target_connected
209 echo $TEXT_INFO"Following packages will be installed: $BASE_FILE $TEST_FILE $LIB_FILE"
210 rpm_install "$BASE_FILE" "$TEST_FILE" $LIB_FILE
213 if [ $CLEAN_JOURNAL -eq 1 ]; then
214 check_if_target_connected
216 sdb shell 'journalctl --vacuum-size=1K'
219 if [ $RUN_TESTS -eq 1 ]; then
220 check_if_target_connected
222 echo $TEXT_INFO"Setting vconf keys..."
223 dir="$(dirname "$0")"
224 "$dir"/utils/setVconfKeys.sh "accessibilityTests/"
230 for i in /usr/apps/org.tizen.universal-switch-tests/no-ui-scenarios/*
235 echo "Tests with Graphical User Interface"
236 UI_PID=`app_launcher -s org.tizen.universal-switch-tests | sed "s/^.*pid \= \([[:digit:]]*\).*$/\1/"`
237 journalctl --since "$DATE" -f | grep universal-switch-tests &
238 while kill -0 $UI_PID 2> /dev/null