xref: /aosp_15_r20/external/vboot_reference/tests/vhost_reference.sh (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1*8617a60dSAndroid Build Coastguard Worker#!/bin/bash
2*8617a60dSAndroid Build Coastguard Worker# Copyright 2024 The ChromiumOS Authors
3*8617a60dSAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
4*8617a60dSAndroid Build Coastguard Worker# found in the LICENSE file.
5*8617a60dSAndroid Build Coastguard Worker
6*8617a60dSAndroid Build Coastguard Worker# Load common constants and variables.
7*8617a60dSAndroid Build Coastguard Worker. "$(dirname "$0")/common.sh"
8*8617a60dSAndroid Build Coastguard Worker
9*8617a60dSAndroid Build Coastguard WorkerTMPD="$(mktemp -d /tmp/"$(basename "$0")".XXXXX)"
10*8617a60dSAndroid Build Coastguard Workertrap '/bin/rm -rf "${TMPD}"' EXIT
11*8617a60dSAndroid Build Coastguard Worker
12*8617a60dSAndroid Build Coastguard Workerreturn_code=0
13*8617a60dSAndroid Build Coastguard Worker
14*8617a60dSAndroid Build Coastguard Workermain() {
15*8617a60dSAndroid Build Coastguard Worker  local hostlib_def_symbols=$1
16*8617a60dSAndroid Build Coastguard Worker  local hostlib_undef_symbols=$2
17*8617a60dSAndroid Build Coastguard Worker  local never_def_vb2_functions="${TMPD}/vb2_undef.txt"
18*8617a60dSAndroid Build Coastguard Worker
19*8617a60dSAndroid Build Coastguard Worker  if [ ! -s "${hostlib_def_symbols}" ] || [ ! -s "${hostlib_undef_symbols}" ]; then
20*8617a60dSAndroid Build Coastguard Worker    echo "Missing input data." >&2
21*8617a60dSAndroid Build Coastguard Worker    exit 1
22*8617a60dSAndroid Build Coastguard Worker  fi
23*8617a60dSAndroid Build Coastguard Worker
24*8617a60dSAndroid Build Coastguard Worker  # We should see any vb2 symbols undefined.
25*8617a60dSAndroid Build Coastguard Worker  grep -vf "${hostlib_def_symbols}" "${hostlib_undef_symbols}" | \
26*8617a60dSAndroid Build Coastguard Worker    grep vb2 > "${never_def_vb2_functions}"
27*8617a60dSAndroid Build Coastguard Worker
28*8617a60dSAndroid Build Coastguard Worker  if [ -s "${never_def_vb2_functions}" ]; then
29*8617a60dSAndroid Build Coastguard Worker    echo "libvboot_host: Unexpected undefined symbols: " >&2
30*8617a60dSAndroid Build Coastguard Worker    cat "${never_def_vb2_functions}" >&2
31*8617a60dSAndroid Build Coastguard Worker    return_code=1
32*8617a60dSAndroid Build Coastguard Worker  fi
33*8617a60dSAndroid Build Coastguard Worker  return "${return_code}"
34*8617a60dSAndroid Build Coastguard Worker}
35*8617a60dSAndroid Build Coastguard Worker
36*8617a60dSAndroid Build Coastguard Workermain "$@"
37