xref: /openbmc/libpldm/scripts/pre-submit (revision a4cfba4976b28f3b135f819df1b88d4550fb5b16)
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 -Dabi-compliance-check=false "$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 the test suite links when testing symbols are removed from the ABI
46meson configure --buildtype=debug "$BUILD"
47meson configure -Dabi=deprecated,stable "$BUILD"
48meson compile -C "$BUILD"
49meson test -C "$BUILD"
50
51# Ensure the build completes for maintenance purposes. Note that tests are
52# disabled as we don't yet guard them appropriately.
53meson configure -Dabi=stable,testing -Dtests=false "$BUILD"
54meson compile -C "$BUILD"
55