4 # Copyright (c) 2020 Project CHIP Authors
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
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.
22 SOURCE="${BASH_SOURCE[0]}"
23 SOURCE_DIR="$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
24 REPO_DIR="$SOURCE_DIR/../../"
26 export HAPPY_LOG_DIR="${HAPPY_LOG_DIR:-$(mktemp -d)}"
31 function happytest_install_packages() {
32 if [ "$(whoami)" != "root" ]; then
33 echo "install_packages should be invoked under root"
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 \
48 function happytest_bootstrap() {
49 echo "Bootstrapping Happy Test"
52 service avahi-daemon start
54 cd "$REPO_DIR/third_party/happy/repo"
56 python3 setup.py install --user
59 function happytest_run() {
60 "$REPO_DIR/scripts/tests/happy_test_wrapper.py" --test-bin-dir "$REPO_DIR/out/$BUILD_TYPE/tests" "$1"
68 happytest_"$subcommand" "$@"