xref: /openbmc/libpldm/scripts/pre-submit (revision aa0aeda7c38dda911c81e9bcd9fae5f8210d303b)
1#!/usr/bin/sh
2set -eu
3
4# For valgrind, value is arbitrarily low-ish
5ulimit -n 2048
6
7BUILD="$(mktemp --directory --tmpdir=.)"
8trap 'rm -rf "$BUILD"' EXIT
9
10meson format --recursive --inplace || true
11if ! git diff --exit-code
12then
13  echo Your changes must meet the upstream meson style guide
14  echo
15  echo https://mesonbuild.com/Style-guide.html
16  echo https://mesonbuild.com/Commands.html#format
17  exit 1
18fi
19
20# Make sure if the change touches the public headers or ABI dump, it also
21# updates the changelog.
22if ! git show --format="" --name-only HEAD -- CHANGELOG.md abi include/libpldm |
23  awk -f scripts/changelog.awk
24then
25  echo Add a CHANGELOG entry to document updates under abi/ and include/libpldm/
26  exit 1
27fi
28
29# Ensure the test suite passes in the default configuration. Note
30# that we don't specify -Dabi=... - the default is equivalent to
31# -Dabi=deprecated,stable,testing.
32CC=gcc CXX=g++ CFLAGS=-fanalyzer meson setup "$BUILD"
33meson compile -C "$BUILD"
34meson test -C "$BUILD"
35
36# Ensure the test suite passes in release mode. libpldm specifies
37# -Db_ndebug=if-release by default, so building with --buildtype=release passes
38# -DNDEBUG to the compiler for the library implementation. This build
39# configuration will catch any unexpected changes in the library implementation
40# and incorrect test case implementations.
41meson configure --buildtype=release "$BUILD"
42meson compile -C "$BUILD"
43meson test -C "$BUILD" --timeout-multiplier 10 --wrapper 'valgrind --error-exitcode=1'
44
45# Ensure that the test suite doesn't fail to link against the stable ABI, and
46# the stable ABI matches what's recorded
47meson configure --buildtype=debug "$BUILD"
48meson configure -Dabi=deprecated,stable "$BUILD"
49! command -v abi-compliance-checker > /dev/null ||
50  meson configure -Dabi-compliance-check=true "$BUILD"
51meson compile -C "$BUILD"
52meson test -C "$BUILD"
53
54# Ensure the build completes for maintenance purposes. Note that tests are
55# disabled as we don't yet guard them appropriately.
56meson configure -Dabi=stable,testing "$BUILD"
57meson configure -Dabi-compliance-check=false "$BUILD"
58meson configure -Dtests=false "$BUILD"
59meson compile -C "$BUILD"
60