summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-11-29 10:59:30 +0100
committerMartin Liska <mliska@suse.cz>2022-12-23 09:44:05 +0100
commita5b07cdf9c491fb7a4a16598c482c68b718f59b9 (patch)
tree5d92b6cf6cb6840869010a0a222649068659a8c9 /tests
parentd868db89553bd9b994c24842441f5ad3c1ed0d84 (diff)
downloadelfutils-a5b07cdf9c491fb7a4a16598c482c68b718f59b9.tar.gz
support ZSTD compression algorithm
config/ChangeLog: * libelf.pc.in: Add LIBLZSTD to Requires.private. ChangeLog: * configure.ac: Detect ZSTD streaming API. libelf/ChangeLog: * Makefile.am: Use zstd_LIBS. * elf_compress.c: (__libelf_compress): Split into ... (__libelf_compress_zlib): ... this. (do_zstd_cleanup): New. (zstd_cleanup): New. (__libelf_compress_zstd): New. (__libelf_decompress): Switch in between zlib and zstd. (__libelf_decompress_zlib): Renamed from __libelf_decompress. (__libelf_decompress_zstd): New. (__libelf_decompress_elf): Dispatch in between compression algorithms. (elf_compress): Likewise. * elf_compress_gnu.c (elf_compress_gnu): Call with ELFCOMPRESS_ZLIB. * libelfP.h (__libelf_compress): Add new argument. (__libelf_decompress): Add chtype argument. src/ChangeLog: * elfcompress.c (enum ch_type): Add ZSTD. (parse_opt): Parse "zstd". (get_section_chtype): New. (process_file): Support zstd compression. (main): Add zstd to help. * readelf.c (elf_ch_type_name): Rewrite with switch. tests/ChangeLog: * Makefile.am: Add ELFUTILS_ZSTD if zstd is enabled. * run-compress-test.sh: Test zstd compression algorithm for debug sections.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/run-compress-test.sh28
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c35a7c33..71b19601 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -220,6 +220,10 @@ if HAVE_ZSTD
TESTS += run-readelf-compressed-zstd.sh
endif
+if USE_ZSTD_COMPRESS
+export ELFUTILS_ZSTD = 1
+endif
+
if DEBUGINFOD
check_PROGRAMS += debuginfod_build_id_find
# With the dummy delegation doesn't work
diff --git a/tests/run-compress-test.sh b/tests/run-compress-test.sh
index a6a298f5..2d4eebd6 100755
--- a/tests/run-compress-test.sh
+++ b/tests/run-compress-test.sh
@@ -61,6 +61,34 @@ testrun_elfcompress_file()
echo "uncompress $elfcompressedfile -> $elfuncompressedfile"
testrun ${abs_top_builddir}/src/elfcompress -v -t none -o ${elfuncompressedfile} ${elfcompressedfile}
testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${elfuncompressedfile}
+
+ if test -z "$ELFUTILS_ZSTD"; then
+ return;
+ fi
+
+ outputfile="${infile}.gabi.zstd"
+ tempfiles "$outputfile"
+ echo "zstd compress $elfcompressedfile -> $outputfile"
+ testrun ${abs_top_builddir}/src/elfcompress -v -t zstd -o ${outputfile} ${elfcompressedfile}
+ testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${outputfile}
+ echo "checking compressed section header" $outputfile
+ testrun ${abs_top_builddir}/src/readelf -Sz ${outputfile} | grep "ELF ZSTD" >/dev/null
+
+ zstdfile="${infile}.zstd"
+ tempfiles "$zstdfile"
+ echo "zstd compress $uncompressedfile -> $zstdfile"
+ testrun ${abs_top_builddir}/src/elfcompress -v -t zstd -o ${zstdfile} ${elfuncompressedfile}
+ testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${zstdfile}
+ echo "checking compressed section header" $zstdfile
+ testrun ${abs_top_builddir}/src/readelf -Sz ${zstdfile} | grep "ELF ZSTD" >/dev/null
+
+ zstdgnufile="${infile}.zstd.gnu"
+ tempfiles "$zstdgnufile"
+ echo "zstd re-compress to GNU ZLIB $zstdfile -> $zstdgnufile"
+ testrun ${abs_top_builddir}/src/elfcompress -v -t zlib-gnu -o ${zstdgnufile} ${zstdfile}
+ testrun ${abs_top_builddir}/src/elfcmp ${uncompressedfile} ${zstdgnufile}
+ echo "checking .zdebug section name" $zstdgnufile
+ testrun ${abs_top_builddir}/src/readelf -S ${zstdgnufile} | grep ".zdebug" >/dev/null
}
testrun_elfcompress()