1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
# debugedit-classify-ar.at: Tests for the debugedit-classify-ar tool
#
# Copyright (C) 2025 Mark J. Wielaard <mark@klomp.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see see <http://www.gnu.org/licenses/>.
# Tests for tools/debugedit-classify-ar
AT_BANNER([debugedit-classify-ar])
# Show which debugedit-classify-ar tool we are testing
AT_TESTED([debugedit-classify-ar])
# Check debugedit-classify-ar --help doesn't crash and burn
AT_SETUP([debugedit-classify-ar help])
AT_KEYWORDS([debugedit-classify-ar] [help])
AT_CHECK([debugedit-classify-ar --help],[0],[ignore],[ignore])
AT_CLEANUP
# Check rejection of none ar file
AT_SETUP([debugedit-classify-ar not and archive])
AT_KEYWORDS([debugedit-classify-ar] [not-an-ar])
echo "not an ar file" > not-an-ar-file.a
AT_CHECK([debugedit-classify-ar -v ./not-an-ar-file.a],[1],[],
[debugedit-classify-ar: not an ELF archive: ./not-an-ar-file.a
])
AT_CLEANUP
# Check empty ar file
AT_SETUP([debugedit-classify-ar empty archive])
AT_KEYWORDS([debugedit-classify-ar] [empty-ar])
${AR} r empty.a
AT_CHECK([debugedit-classify-ar -v ./empty.a],[1],[],
[debugedit-classify-ar: no member with debug sections: ./empty.a
])
AT_CLEANUP
# Check ar file with not ELF member
AT_SETUP([debugedit-classify-ar not ELF member])
AT_KEYWORDS([debugedit-classify-ar] [not-elf-member])
echo "Not an ELF" > not-elf
${AR} qS not-elf.a not-elf
AT_CHECK([debugedit-classify-ar -v ./not-elf.a],[1],[],
[debugedit-classify-ar: no member with debug sections: ./not-elf.a
])
AT_CLEANUP
# Check ar file with ELF member
AT_SETUP([debugedit-classify-ar ELF member])
AT_KEYWORDS([debugedit-classify-ar] [elf-member])
echo "int main () {}" | ${CC} -g -xc -o elf -
${AR} qS elf.a elf
AT_CHECK([debugedit-classify-ar -v ./elf.a],[0],[],
[debugedit-classify-ar: found member(s) with debug sections: ./elf.a
])
AT_CLEANUP
# Check ar file with ELF member (no debug)
AT_SETUP([debugedit-classify-ar ELF member (no debug)])
AT_KEYWORDS([debugedit-classify-ar] [elf-no-debug-member])
echo "int main () {}" | ${CC} -xc -o elf-no-debug -
# Make sure all debug is stripped even from startup files
eu-strip elf-no-debug
${AR} qS elf-no-debug.a elf-no-debug
AT_CHECK([debugedit-classify-ar -v ./elf-no-debug.a],[1],[],
[debugedit-classify-ar: no member with debug sections: ./elf-no-debug.a
])
AT_CLEANUP
# Check ar file with too many ELF members
AT_SETUP([debugedit-classify-ar ELF member (too many)])
AT_KEYWORDS([debugedit-classify-ar] [elf-too-many-member])
echo "int main () {}" | ${CC} -g -xc -o elf1 -
echo "int main () {}" | ${CC} -g -xc -o elf2 -
echo "int main () {}" | ${CC} -g -xc -o elf3 -
${AR} qS elf-too-many.a elf1 elf2 elf3
AT_CHECK([debugedit-classify-ar -v -m 2 ./elf-too-many.a],[1],[],
[debugedit-classify-ar: too many members (3): ./elf-too-many.a
])
AT_CLEANUP
|