Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / scripts / tests / esp32_qemu_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 #    Description:
20 #      This is scripts builds ESP32 QEMU, and runs CHIP unit tests using it.
21 #
22
23 set -e
24 set -o pipefail
25 set -x
26
27 here=$(cd "$(dirname "$0")" && pwd)
28 chip_dir="$here"/../..
29
30 if [[ -n "$1" ]]; then
31     log_dir=$1
32     shift
33 fi
34
35 # shellcheck source=/dev/null
36 source "$chip_dir"/src/test_driver/esp32/idf.sh
37 "$chip_dir"/src/test_driver/esp32/qemu_setup.sh
38
39 if [ $? -ne 0 ]; then
40     echo "Setup failure"
41     exit 1
42 fi
43
44 really_run_suite() {
45     idf scripts/tools/qemu_run_test.sh src/test_driver/esp32/build/chip "$1" "$2"
46 }
47
48 run_suite() {
49     if [[ -d "${log_dir}" ]]; then
50         suite=${1%.a}
51         suite=${suite#lib}
52         really_run_suite "$1" "$2" |& tee "$log_dir/$suite.log"
53     else
54         really_run_suite "$1" "$2"
55     fi
56 }
57
58 # Currently only crypto, inet, and system tests are configured to run on QEMU.
59 # The specific qualifiers will be removed, once all CHIP unit tests are
60 # updated to run on QEMU.
61 SUITES=(
62 )
63
64 run_suite libAppTests.a
65 run_suite libASN1Tests.a
66 run_suite libBleLayerTests.a
67 run_suite libCoreTests.a
68 run_suite libInetLayerTests.a
69 run_suite libRetransmitTests.a
70 run_suite libSystemLayerTests.a
71 run_suite libChipCryptoTests.a
72
73 # TODO: Transport layer tests do not link:
74 #    - getpid undefined
75 #    - ArgParser for IPAddresses are not linked in
76 #    - std::__throw_bad_alloc() linker errors
77 # run_suite libRawTransportTests.a "-lNetworkTestHelpers -lInetTestHelpers"
78
79 # TODO: Transport layer tests do not link:
80 #    - getpid undefined
81 #    - ArgParser for IPAddresses are not linked in
82 #    - std::__throw_bad_alloc() linker errors
83 # run_suite libTransportLayerTests.a "-lNetworkTestHelpers -lInetTestHelpers"