blob: 5e2164f811c9e8aa353c33ec37fad725738441a9 [file] [log] [blame]
Alex Thiessen15aad882018-01-02 17:40:55 +00001#!/bin/bash
2
3##
4## This file is part of the coreboot project.
5##
6## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot@gmail.com>
7##
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; version 3 or later of the License.
11##
12## This program is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## SPDX-License-Identifier: GPL-3.0-or-later
18## <https://spdx.org/licenses/GPL-3.0-or-later.html>
19##
20
21set -o errexit
22set -o nounset
23
24# static analysis
25if command -v shellcheck 1>/dev/null; then
26 shellcheck --exclude=1090,1091 \
27 "${BASH_SOURCE[0]}" \
28 "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
29else
30 echo "shellcheck not found, running unchecked" >&2
31fi
32
33# dependency check
34dependencies=(dirname git make mktemp rm timeout)
35for dependency in "${dependencies[@]}"; do
36 if ! command -v "${dependency}" 1>/dev/null; then
37 echo "missing ${dependency}, test skipped" >&2
38 exit 0
39 fi
40done
41
42source "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
43
44# setup
45base_dir="$(mktemp --directory --tmpdir \
46 "test-$(basename "${BASH_SOURCE[0]}" .sh)-XXXXXXXX")"
47clone_dir="${base_dir}/coreboot"
48git clone "$(git rev-parse --show-toplevel)" "${clone_dir}" \
49 1>"${base_dir}/clone.log" 2>&1
50
51(
52 set -o errexit
53 set -o nounset
54
55 clone_submodules "${clone_dir}" "${base_dir}"
56
57 # mock
58 git config user.name "John Doe"
59 git config user.email "john.doe@example.com"
60
61 # test
62 log_file="${base_dir}/gitconfig.log"
63 timeout 2s make gitconfig \
64 1>"${log_file}" 2>&1 \
65 || check_exit_code positive "${log_file}"
66)
67
68# teardown
69rm --force --recursive "${base_dir}"