Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / scripts / tests / happy_tests.sh
1 #!/usr/bin/env bash
2
3 #
4 # Copyright (c) 2020 Project CHIP Authors
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 # This file is used to test a single happy test using (almost) the same
20 # method as ninja does. Suggest passing $HAPPY_LOG_DIR to set path for logs.
21
22 SOURCE="${BASH_SOURCE[0]}"
23 SOURCE_DIR="$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
24 REPO_DIR="$SOURCE_DIR/../../"
25
26 export HAPPY_LOG_DIR="${HAPPY_LOG_DIR:-$(mktemp -d)}"
27
28 set -x
29 env
30
31 function happytest_install_packages() {
32     if [ "$(whoami)" != "root" ]; then
33         echo "install_packages should be invoked under root"
34         return 1
35     fi
36     echo "Install packages: avahi-daemon bridge-utils iproute2 net-tools python3-lockfile python3-pip python3-psutil python3-setuptools strace"
37     apt-get update && apt-get install -y avahi-daemon \
38         bridge-utils \
39         iproute2 \
40         net-tools \
41         python3-lockfile \
42         python3-pip \
43         python3-psutil \
44         python3-setuptools \
45         strace
46 }
47
48 function happytest_bootstrap() {
49     echo "Bootstrapping Happy Test"
50     set -e
51     service dbus start
52     service avahi-daemon start
53     # Bootstrap Happy
54     cd "$REPO_DIR/third_party/happy/repo"
55
56     python3 setup.py install --user
57 }
58
59 function happytest_run() {
60     "$REPO_DIR/scripts/tests/happy_test_wrapper.py" --test-bin-dir "$REPO_DIR/out/$BUILD_TYPE/tests" "$1"
61 }
62
63 subcommand="$1"
64 shift
65
66 case $subcommand in
67     *)
68         happytest_"$subcommand" "$@"
69         ;;
70 esac