#!/bin/sh
# The release binary has no fault-injection code: neither the SUIT_FAULT
# variable name nor the wrapper-name table may appear in it, nor may the
# variables that point install at a fake loader and a fake platform, pin the
# date, the certificate bundle, the user or the network limits. The test build
# must, or this check proves nothing.
# usage: release_clean.sh RELEASE_BINARY TEST_BINARY
set -eu
release=${1:?usage: release_clean.sh RELEASE_BINARY TEST_BINARY}
dev=${2:?usage: release_clean.sh RELEASE_BINARY TEST_BINARY}
for needle in SUIT_FAULT self_path SUIT_LOADER SUIT_PLATFORM SUIT_NOW SUIT_CA_BUNDLE SUIT_NET_TIMEOUT SUIT_NET_DEADLINE SUIT_UID; do
    strings -a "$dev" | grep -q "$needle" || { echo "release_clean: test binary lacks '$needle'; the check is blind"; exit 1; }
    if strings -a "$release" | grep -q "$needle"; then
        echo "release_clean: FAIL release binary contains '$needle'"
        exit 1
    fi
done
echo "release_clean: ok, no fault-injection strings in $release"
