File: build_and_run_test.sh

package info (click to toggle)
eclipse-titan 7.2.0-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 103,144 kB
  • sloc: cpp: 264,784; ansic: 33,124; yacc: 23,073; makefile: 14,730; lex: 9,190; java: 4,849; perl: 3,783; sh: 2,298; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (90 lines) | stat: -rwxr-xr-x 3,416 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
###############################################################################
# Copyright (c) 2000-2020 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
#   Balasko, Jeno
#   Lovassy, Arpad
#
###############################################################################

# EDIT THESE LINES TO SET CORRECT JAR LOCATIONS

JUNIT_FULL=$HOME/lib/org.junit_4.11.0.v201303080030/junit.jar
HAMCREST_FULL=$HOME/lib/org.hamcrest.core_1.3.0.v201303031735.jar

#---------------------------------------------------------------------
# DO NOT EDIT AFTER THIS LINE

# check if JAVA exists
# http://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
if type -p java; then
    echo found java executable in PATH
    _java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]];  then
    echo found java executable in JAVA_HOME
    _java="$JAVA_HOME/bin/java"
else
    echo "no java, exiting"; exit 1;
fi

# check java version (>=1.7)
if [[ "$_java" ]]; then
    version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
    echo version "$version"
    if [[ "$version" > "1.7" ]]; then
        echo "version is at least 1.7, OK";
    else
        echo "version is less than 1.7, NOT OK, exiting"; exit 1;
    fi
fi

# check java version (>=1.7) in another way
[ $(java -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/; 1q') -ge 17 ] && echo "version is at least 1.7, OK" || { echo "version is less than 1.7, NOT OK, exiting"; exit 1; }

# checks if file exists, exits if not
# @param $1 file full path
function file_exist {
	[ -f "$1" ] && echo "$1 FOUND, OK" || { echo "$1 NOT FOUND, exiting"; exit 1; }
}

# checks if directory exists, exits if not
# @param $1 directory full path
function dir_exist {
	[ -d "$1" ] && echo "$1 DIRECTORY FOUND, OK" || { echo "$1 DIRECTORY NOT FOUND, exiting"; exit 1; }
}

# check TITAN dependencies
[ ! -z "${TTCN3_DIR}" ] && echo "\$TTCN3_DIR is set to ${TTCN3_DIR}, OK" \
|| { echo "\$TTCN3_DIR is not set, NOT OK, exiting"; exit 1; }
dir_exist ${TTCN3_DIR}
file_exist ${TTCN3_DIR}/lib/libmctrjninative.so
[[ "${LD_LIBRARY_PATH}" == *"${TTCN3_DIR}/lib"* ]] && echo "\$TTCN3_DIR/lib is added to \$LD_LIBRARY_PATH=${LD_LIBRARY_PATH}, OK" \
|| { echo "\$TTCN3_DIR is NOT added to \$LD_LIBRARY_PATH=${LD_LIBRARY_PATH}, NOT OK, exiting"; exit 1; }

# make sure, that the demo is compiled, which is cleaned in make install
pushd ${TTCN3_DIR}/demo
make
popd
file_exist ${TTCN3_DIR}/demo/MyExample

# Check if HelloWorld demo binary is compiled in parallel mode: output of MyExample -v contains "(parallel mode)"
[ `${TTCN3_DIR}/demo/MyExample -v 2>&1 | grep "(parallel mode)" | wc -l` != 0 ] && echo "${TTCN3_DIR}/demo/MyExample is compiled in parallel mode, OK" \
|| { echo "${TTCN3_DIR}/demo/MyExample is compiled in single mode, NOT in parallel mode, NOT OK, exiting"; exit 1; }

# check JAR dependencies
file_exist ${JUNIT_FULL}
file_exist ${HAMCREST_FULL}

# run test (and build its dependencies if needed)
BASEDIR=$(dirname $0)
echo BASEDIR: $BASEDIR
ant \
-f $BASEDIR/build.xml \
-Djunit.full=${JUNIT_FULL} \
-Dhamcrest.full=${HAMCREST_FULL} \
TITAN_Executor_API_test