1#! /usr/bin/env bash
2# Test to make sure all EM values in elf.h are recognized
3# Copyright (C) 2019 Red Hat, Inc.
4# This file is part of elfutils.
5#
6# This file is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# elfutils is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19. $srcdir/test-subr.sh
20
21# Get all known EM values from elf.h and pass them through the
22# preprocessor to get the numbers. Call dwelf_elf_e_machine_string on
23# all of them.
24EM_VALUES=$(grep ^\#define\ EM_ ${abs_srcdir}/../libelf/elf.h \
25            | cut -f2 -d\  | cut -f1 | grep -v ^EM_NUM$ | xargs echo)
26# echo "EM_VALUES: $EM_VALUES"
27EM_NUMBERS=$((cat ${abs_srcdir}/../libelf/elf.h; echo "$EM_VALUES") \
28             | gcc -E - | tail -1)
29# echo "EM_NUMBERS: $EM_NUMBERS"
30
31testrun ${abs_top_builddir}/tests/dwelf_elf_e_machine_string $EM_NUMBERS
32