blob: c4378688c806fcf975a38002b2e1a5c708059e08 [file] [log] [blame]
Fathi Boudra422bf772019-12-02 11:10:16 +02001#!/bin/bash
2#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8set -e
9
10ci_root="$(readlink -f "$(dirname "$0")/..")"
11source "$ci_root/utils.sh"
12
13# Change directory to the TF-A checkout ready to build
14cd "$TF_CHECKOUT_LOC"
15
16# Build TF-A to get blx.bin images and the tools (fiptool and cert_create)
17# Debug build enabled so that valgrind has access to source file line numbers
18if ! make CROSS_COMPILE="aarch64-linux-gnu-" all fiptool certtool DEBUG=1 V=1 \
19 &>"$workspace/build.log"; then
20 echo "Error building tools; see archived build.log"
21 exit 1
22fi
23
24run_valgrind() {
25 valgrind --leak-check=full -v --log-file="$log_file" $*
26 echo
27 if ! grep -iq "All heap blocks were freed -- no leaks are possible" \
28 "$log_file"; then
29 echo "Memory leak reported in $log_file"
30 return 1
31 fi
32 return 0
33}
34
35has_leak=0
36
37fiptool_cmd="./tools/fiptool/fiptool \
38 create \
39 --tb-fw build/fvp/debug/bl2.bin \
40 --soc-fw build/fvp/debug/bl31.bin \
41 fip.bin"
42
43# Build the FIP under Valgrind
44if ! log_file="$workspace/fiptool.log" run_valgrind "$fiptool_cmd"; then
45 echo "fiptool has memory leaks."
46 has_leak=1
47else
48 echo "fiptool does not have memory leaks."
49fi
50
51echo
52
53cert_create_cmd="./tools/cert_create/cert_create \
54 -n \
55 --tb-fw build/fvp/debug/bl2.bin"
56
57# Run cert_create under Valgrind
58if ! log_file="$workspace/cert_create.log" run_valgrind "$cert_create_cmd"; then
59 echo "cert_create has memory leaks."
60 has_leak=1
61else
62 echo "cert_create does not have memory leaks."
63fi
64
65echo
66
67exit "$has_leak"