libabigail/tests/runtestabidb2.sh.in
Frank Ch. Eigler 09338a2590 abidb: Introduce a tool to manage the ABI of a Linux distribution
This patch introduces a new tool named abidb.  It manages a Git
repository of the Application Binary Interfaces of a set of shared
libraries.  Those ABIs are stored in the Git repository in the form of
ABIXML files.

The tool then supports the verification of the ABI compatibility of a
given binary against the stored ABIs of shared libraries.

	* configure.ac: Condition building abidb on the presence of python
	and the required modules.
	* doc/manuals/Makefile.am: Add the abidb.rst documentation to
	source distribution.  Distribute the abidb.1 manpage file as well.
	* doc/manuals/abidb.rst: New documentation file.
	* doc/manuals/conf.py: Configure the generation of the abidb.1
	manage from the abidb.rst file above.
	* doc/manuals/libabigail-tools.rst: Add a reference to the new
	abidb tool.
	* tests/Makefile.am: Register runabidb1.sh and runabidb2.sh as
	tests for abidb.  Register runabidb1.sh.in and runabidb2.sh.in as
	input files for autoconf generated runabidb1.sh and runabidb2.sh.
	* tests/data/Makefile.am: Add abidb2client.c, abidb2so.c and
	abidb2soBAD.c to source distribution.
	* tests/data/abidb2client.c: New source file for test input binaries.
	* tests/data/abidb2so.c: Likewise.
	* tests/data/abidb2soBAD.c: Likewise.
	* tests/runtestabidb1.sh.in: New test script input for autoconf generation.
	* tests/runtestabidb2.sh.in: Likewise.
	* tools/Makefile.am: Add the new abidb tool to the set of tools.
	* tools/abidb: The New Tool, ladies and gentlemen!

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-22 17:18:17 +01:00

74 lines
2.1 KiB
Bash
Executable File

#! /bin/sh
# Run an abidb test based on the binaries right here
# test prereqs
type git 2>/dev/null || (echo "need git" ; exit 77)
type gcc 2>/dev/null || (echo "need gcc" ; exit 77)
type eu-readelf 2>/dev/null || (echo "need eu-readelf" ; exit 77)
type debuginfod-find 2>/dev/null || (echo "need debuginfod-find" ; exit 77)
toolssrcdir=@abs_top_srcdir@/tools
toolsdir=@abs_top_builddir@/tools
PATH=$toolsdir:$PATH
export PATH
type $toolsdir/abidw && ABIDW=$toolsdir/abidw
type $toolsdir/abidiff && ABIDIFF=$toolsdir/abidiff
type $toolssrcdir/abidb && ABIDB=$toolssrcdir/abidb
type $toolsdir/abicompat && ABICOMPAT=$toolsdir/abicompat
datadir=@abs_top_srcdir@/tests/data/test-abidb
odatadir=@abs_top_builddir@/tests/data/test-abidb
test -d $odatadir || mkdir -p $odatadir
set -x
gitdir=$(mktemp -d --tmpdir abidb-XXXXXXXX)
function clean_env
{
echo cleaning "$gitdir"
# comment rm -rf out to preserve the evidence
rm -rf "$gitdir"
rm -rf $odatadir
}
git init $gitdir
# Build a little shared library, a binary against it, then
# break it with an update
gcc -g -fPIC -rdynamic -shared $datadir/abidb2so.c -Wl,-soname=libabidb2.so -o $odatadir/libabidb2.so
$ABIDB --loglevel=debug --abidw $ABIDW --git $gitdir --submit $odatadir/libabidb2.so
gcc -g $datadir/abidb2client.c -L$odatadir -labidb2 -o $odatadir/abidb2client
$ABIDB --loglevel=debug --git $gitdir --check $odatadir/abidb2client
rm $odatadir/libabidb2.so
gcc -g -fPIC -rdynamic -shared $datadir/abidb2soBAD.c -Wl,-soname=libabidb2.so -o $odatadir/libabidb2.so
cmd="$ABIDB --loglevel=debug --abidw $ABIDW --git $gitdir --submit $odatadir/libabidb2.so"
$cmd
RESULT_CODE=$?
if test $RESULT_CODE -eq 0; then
cmd="$ABIDB --loglevel=debug --abicompat $ABICOMPAT --git $gitdir --check $odatadir/abidb2client"
$cmd
RESULT_CODE=$?
echo "expected a failure!"
if test $RESULT_CODE -ne 0; then
echo "executed: $cmd: "
echo "with exit code: $RESULT_CODE"
RESULT_CODE=0
else
RESULT_CODE=1
fi
else
echo "command failed: $cmd"
fi
# How many shared libraries did we collect?
(cd $gitdir; git ls-files; for file in `git ls-files`; do git show $file; done )
clean_env
exit $RESULT_CODE