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