libabigail/tests/data
Dodji Seketeli e57abd7828 Add support for reading XZ-compressed files
In preparation for an upcoming patch about comparing sets of packages
(especially kernel packages that can contain xz-compressed kernel
modules) this patch adds support for detecting the content of an input
file compressed with the XZ tool.

Note that the various libabigail tools need to know the kind of input
file they are given in order to know what front-end to instantiate to
handle the input file.  The determination of the kind of file is done
by the function tools::utils::guess_file_type either by looking at the
suffix of the file name (for certain special files like tar files) or
by opening the file and looking at its magic bytes.

This patch uses liblzma to de-compress xz-ed files.  The decompressing
is done by a custom-written std::streambuf class.  That decompressor
streambuf is then instantiated with the input compressed ifstream.
Then, an istream is constructed using that decompressor and so readers
of that istream can just transparently just read from it, without
knowing anything about the upstream decompressor streambuf.

The existing code of guess_file_type has been adapted to instantiate
the right decompressor streambuf.  Once it has it and constructed the
(decompressed) istream, the rest of the code remains unchanged and
uses the istream as before.

A new function tools_utils::get_decompressed_streambuf is introduced
to get the right streambuf decompressor for the given input file.
That function must be amended to support new compression schemes to
come.

With this patch, libabigail now can transparently read xz-ed ABIXML
files as well as xz'ed ELF files.  Note that both elfutils and libxml2
know how to read xz'ed binaries so I haven't had to do anything for
them to handle the xz'ed input files.  Pretty neat.

The patch also adds regression tests handling input ABIXML files and
ELF files.

	* configure.ac: Detect the liblzma library.
	* include/abg-tools-utils.h (enum file_type): Add a new
	FILE_TYPE_XZ enumerator.
	(class xz_decompressor_type): Declare a new custom std::streambuf
	class.
	* src/abg-elf-helpers.h: Include elfutils/libdwelf.h.
	* src/abg-elf-reader.cc (get_type_of_elf_file): Use
	dwelf_elf_begin instead of elf_begin to transparently handle
	compressed input file.
	* src/abg-tools-util*s.cc (struct xz_decompressor_type::priv):
	Define private type.
	(xz_decompressor_type::{xz_decompressor_type,
	~xz_decompressor_type, underflow}): Define new methods for
	xz_decompressor_type.
	(operator<<(ostream&, file_type)): Add
	support for the new FILE_TYPE_XZ enumerator.
	(enum compression_kind): Define new enum.
	(is_compressed_file_type, get_decompressed_streambuf): Define new
	static functions.
	(guess_file_type): In the overload for std::istream, detect the XZ file
	type.  In the overload for std::string, use the new
	is_compressed_file_type and get_decompressed_streambuf to
	decompress a compressed file on the fly and handing the resulting
	decompressed istream to the overload for std::istream.
	* tests/data/test-read-dwarf/test0.xz: New input binary test.
	* tests/data/test-read-dwarf/test0.xzbinary: Likewise.
	* tests/data/test-read-write/test28.xml.xz: Likewise.
	* tests/data/test-read-write/test28.xml.xzed: Likewise.
	* tests/data/Makefile.am: Add the new test input to source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test input
	to this test harness.
	* tests/test-read-write.cc (in_out_specs): Likewise.
	* tools/abicompat.cc (read_corpus): Add support for the new
	abigail::tools_utils::FILE_TYPE_XZ.
	* tools/abidiff.cc (main): Likewise.
	* tools/abilint.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2025-02-03 12:36:59 +01:00
..
test-abicompat
test-abidb
test-abidiff
test-abidiff-exit comparison: Sort anonymous types using their flat representation 2024-09-02 10:06:22 +02:00
test-alt-dwarf-file
test-annotate hash: Use the faster XXH3 hashing algorithm from xxhash 2024-10-01 17:04:12 +02:00
test-core-diff
test-default-supprs
test-diff-dwarf dwarf-reader: Avoid duplicating anonymous member types 2024-08-29 17:15:43 +02:00
test-diff-dwarf-abixml hash: Use the faster XXH3 hashing algorithm from xxhash 2024-10-01 17:04:12 +02:00
test-diff-filter dwarf-reader,ir,writer: Better support for static member variables 2024-08-29 17:15:44 +02:00
test-diff-pkg ir: Always use canonical types in comparison when possible 2024-09-27 18:31:02 +02:00
test-diff-pkg-ctf
test-diff-suppr
test-fedabipkgdiff abipkgdiff: Extract devel and main packages in the same directory 2024-08-29 17:15:44 +02:00
test-ini
test-kmi-whitelist
test-lookup-syms
test-read-btf hash: Use the faster XXH3 hashing algorithm from xxhash 2024-10-01 17:04:12 +02:00
test-read-common
test-read-ctf hash: Use the faster XXH3 hashing algorithm from xxhash 2024-10-01 17:04:12 +02:00
test-read-dwarf Add support for reading XZ-compressed files 2025-02-03 12:36:59 +01:00
test-read-write Add support for reading XZ-compressed files 2025-02-03 12:36:59 +01:00
test-symtab
test-types-stability
test-write-read-archive
Makefile.am Add support for reading XZ-compressed files 2025-02-03 12:36:59 +01:00