docs: Add 24.12 release notes
[coreboot2.git] / util / gitconfig / test / timeout.sh
blob2d600f4a779ca9b081c5b7c49a193eb4e36e14c9
1 #!/usr/bin/env bash
2 ##
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; version 3 or later of the License.
6 ##
7 ## This program is distributed in the hope that it will be useful,
8 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
9 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 ## GNU General Public License for more details.
12 ## SPDX-License-Identifier: GPL-3.0-or-later
13 ## <https://spdx.org/licenses/GPL-3.0-or-later.html>
16 set -o errexit
17 set -o nounset
19 # static analysis
20 if command -v shellcheck 1>/dev/null; then
21 shellcheck --exclude=1090,1091 \
22 "${BASH_SOURCE[0]}" \
23 "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
24 else
25 echo "shellcheck not found, running unchecked" >&2
28 # dependency check
29 dependencies=(dirname git make mktemp rm timeout)
30 for dependency in "${dependencies[@]}"; do
31 if ! command -v "${dependency}" 1>/dev/null; then
32 echo "missing ${dependency}, test skipped" >&2
33 exit 0
35 done
37 source "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
39 # setup
40 base_dir="$(mktemp --directory --tmpdir \
41 "test-$(basename "${BASH_SOURCE[0]}" .sh)-XXXXXXXX")"
42 clone_dir="${base_dir}/coreboot"
43 git clone "$(git rev-parse --show-toplevel)" "${clone_dir}" \
44 1>"${base_dir}/clone.log" 2>&1
47 set -o errexit
48 set -o nounset
50 clone_submodules "${clone_dir}" "${base_dir}"
52 # mock
53 git config user.name "John Doe"
54 git config user.email "john.doe@example.com"
56 # test
57 log_file="${base_dir}/gitconfig.log"
58 timeout 2s make gitconfig \
59 1>"${log_file}" 2>&1 \
60 || check_exit_code positive "${log_file}"
63 # teardown
64 rm --force --recursive "${base_dir}"