xref: /aosp_15_r20/external/zstd/contrib/linux-kernel/test/macro-test.sh (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1#!/usr/bin/env sh
2
3set -e
4
5SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
6INCLUDE_DIR="$SCRIPT_DIR/../linux/include"
7LIB_DIR="$SCRIPT_DIR/../linux/lib"
8
9
10print() {
11    printf '%b' "${*}"
12}
13
14println() {
15    printf '%b\n' "${*}"
16}
17
18die() {
19    println "$@" 1>&2
20    exit 1
21}
22
23test_not_present() {
24    print "Testing that '$1' is not present... "
25    grep -r $1 "$INCLUDE_DIR" "$LIB_DIR" && die "Fail!"
26    println "Okay"
27}
28
29println "This test checks that the macro removal process worked as expected"
30println "If this test fails, then freestanding.py wasn't able to remove one of these"
31println "macros from the source code completely. You'll either need to rewrite the check"
32println "or improve freestanding.py."
33println ""
34
35test_not_present "ZSTD_NO_INTRINSICS"
36test_not_present "ZSTD_NO_UNUSED_FUNCTIONS"
37test_not_present "ZSTD_LEGACY_SUPPORT"
38test_not_present "STATIC_BMI2"
39test_not_present "ZSTD_DLL_EXPORT"
40test_not_present "ZSTD_DLL_IMPORT"
41test_not_present "__ICCARM__"
42test_not_present "_MSC_VER"
43test_not_present "_WIN32"
44test_not_present "__linux__"
45