diff options
Diffstat (limited to 'tests')
49 files changed, 1304 insertions, 68 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 6e3923f5..99f9da9d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,209 @@ +2020-06-06 Mark Wielaard <mark@klomp.org> + + * testfilesyms32.bz2: New test file. + * testfilesyms64.bz2: Likewise. + * run-nm-syms.sh: New test. + * Makefile.am (TESTS): Add run-nm-syms.sh. + (EXTRA_DIST): run-nm-syms.sh, testfilesyms32.bz2 and + testfilesyms64.bz2 + +2020-05-08 Mark Wielaard <mark@klomp.org> + + * elfputzdata.c (main): Explicitly check orig_buf is not NULL + before calling memcmp. + +2020-05-05 Mark Wielaard <mark@klomp.org> + + * testfile-lto-gcc8.bz2: New test file. + * testfile-lto-gcc9.bz2: Likewise. + * Makefile.am (EXTRA_DIST): Add testfile-lto-gcc8.bz2 and + testfile-lto-gcc9.bz2. + * run-allfcts.sh: Add testfile-lto-gcc9 and testfile-lto-gcc8 + tests. + +2020-05-05 Mark Wielaard <mark@klomp.org> + + * testfile-lto-gcc10.bz2: New test file. + * Makefile.am (EXTRA_DIST): Add testfile-lto-gcc10.bz2. + * run-allfcts.sh: Add testfile-lto-gcc10 test. + +2020-04-17 Mark Wielaard <mark@klomp.org> + + * test-subr.sh (testrun_on_self_obj): New function. + * run-varlocs-self.sh: Run testrun_on_self_exe and + testrun_on_self_lib with -e, run testrun_on_self_obj with + --exprlocs -e. + +2020-04-17 Mark Wielaard <mark@klomp.org> + + * Makefile.am (test-nlist$): New goal with minimal CFLAGS. + (test_nlist_CFLAGS): New variable. + +2020-03-28 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test timestamps of archive-origin files. + +2020-03-27 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test /path/-based debuginfod-find. + +2020-03-24 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test relay of UA and XFF headers across + federating debuginfods. + +2020-03-26 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Look for debuginfod's new + http_responses_* metrics. + +2020-03-26 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Look for bsdtar instead of dpkg. + +2020-03-26 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Check for bsdtar zstd capability + for running tests against zstd-compressed fedora31 rpms. + +2020-03-26 Mark Wielaard <mark@klomp.org> + + * Makefile.am (EXTRA_DIST): Add + debuginfod-rpms/fedora31/hello3-1.0-2.src.rpm, + debuginfod-rpms/fedora31/hello3-1.0-2.x86_64.rpm, + debuginfod-rpms/fedora31/hello3-debuginfo-1.0-2.x86_64.rpm, + debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm, + debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm, + debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm + +2020-03-24 Frank Ch. Eigler <fche@redhat.com> + + * debuginfod-rpms/hello3.spec., /fedora31/*: New files with + uncanonicalized source paths. + * run-debuginfod-find.sh: Test them. + +2020-03-24 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test the more detailed debuginfod + webapi log format. + +2020-03-23 Mark Wielaard <mark@klomp.org> + + * getphdrnum.c: Include config.h. + * run-lfs-symbols.sh: Also check that file exists. Add more logs. + Remove ebl modules check. + +2020-03-22 Omar Sandoval <osandov@fb.com> + Mark Wielaard <mark@klomp.org> + + * getphdrnum.c: New file. + * run-getphdrnum.sh: New test. + * testfile-phdrs.elf.bz2: New test file. + * Makefile.am (check_PROGRAMS): Add getphdrnum. + (TESTS): Add run-getphdrnum.sh. + (EXTRA_DIST): Add run-getphdrnum.sh and testfile-phdrs.elf.bz2. + (getphdrnum_LDADD): New variable. + +2020-03-22 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Look for URL in default progressfn + and from debuginfod-find -v. + +2020-02-19 Aaron Merey <amerey@redhat.com> + + * run-debuginfod-find.sh: Run tests for verifying default + client cache locations. + +2020-02-26 Konrad Kleine <kkleine@redhat.com> + + * run-debuginfod-find.sh: added tests for DEBUGINFOD_URLS beginning + with "file://" + +2020-02-21 Mark Wielaard <mark@klomp.org> + + * Makefile.am (TESTS_ENVIRONMENT): Explicitly unset DEBUGINFOD_URLS. + (installed_TESTS_ENVIRONMENT): Likewise. + +2020-02-19 Aaron Merey <amerey@redhat.com> + + * run-debuginfod-find.sh: Test that files unrelated to debuginfod + survive cache cleaning. + +2020-02-08 Mark Wielaard <mark@klomp.org> + + * run-pt_gnu_prop-tests.sh: New test. + * testfile_pt_gnu_prop.bz2: New test file. + * testfile_pt_gnu_prop32.bz2: Likewise. + * Makefile.am (TESTS): Add run-pt_gnu_prop-tests.sh + (EXTRA_DISTS): Likewise. Add testfile_pt_gnu_prop.bz2 and + testfile_pt_gnu_prop32.bz2. + +2020-02-05 Frank Ch. Eigler <fche@redhat.com> + + * debuginfo-tars/*: New test files from Eli Schwartz of ArchLinux. + * Makefile.am (EXTRA_DIST): Package them. + * run-debuginfod-find.sh: Run basic archive extraction tests. + +2020-02-03 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Protect against missing curl & rpm2cpio. + +2020-01-19 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Check for proper groom completion count. + +2020-01-18 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test empty source_paths[]. + +2020-01-08 Mark Wielaard <mark@klomp.org> + + * asm-test?.c: include libebl.h. + +2020-01-11 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Test --fdcache* options. + +2020-01-11 Frank Ch. Eigler <fche@redhat.com> + + * run-debuginfod-find.sh: Adjust to new work-queue metrics. + +2020-01-02 Mark Wielaard <mark@klomp.org> + + * run-debuginfod-find.sh: Set DEBUGINFOD_TIMEOUT to 10. + +2019-12-22 Frank Ch. Eigler <fche@redhat.com> + + * debuginfod-debs/*: New test files, based on + https://wiki.debian.org/Packaging/Intro. + * run-debuginfod-find.sh: Test deb file processing (if dpkg + installed). + +2019-12-04 Frank Ch. Eigler <fche@redhat.com> + + * run-debuinfod-find.sh: Test $DEBUGINFOD_PROGRESS. + +2019-12-11 Omar Sandoval <osandov@fb.com> + + * dwfl-report-segment-coalesce.c: New test. + * Makefile.am: Add dwfl-report-segment-coalesce + +2019-12-06 Mark Wielaard <mark@klomp.org> + + * run-debuginfod-find.sh: Force -Wl,--build-id. + +2019-12-05 Mark Wielaard <mark@klomp.org> + + * run-findinfod-find.sh: Run strip under testrun. + +2019-12-06 Mark Wielaard <mark@klomp.org> + + * backtrace-data.c (main): Add break after assert. + +2019-12-05 Mark Wielaard <mark@klomp.org> + + * run-elfclassify.sh: Run elfcompress under testrun. + 2019-11-26 Mark Wielaard <mark@klomp.org> * Makefile.am (BUILD_STATIC): Add libraries needed for libdw. diff --git a/tests/Makefile.am b/tests/Makefile.am index 03eebfa8..fa4999df 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -50,7 +50,8 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ test-flag-nobits dwarf-getstring rerequest_tag \ alldts typeiter typeiter2 low_high_pc \ test-elf_cntl_gelf_getshdr dwflsyms dwfllines \ - dwfl-report-elf-align varlocs backtrace backtrace-child \ + dwfl-report-elf-align dwfl-report-segment-contiguous \ + varlocs backtrace backtrace-child \ backtrace-data backtrace-dwarf debuglink debugaltlink \ buildid deleted deleted-lib.so aggregate_size peel_type \ vdsosyms \ @@ -61,7 +62,8 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ get-units-invalid get-units-split attr-integrate-skel \ all-dwarf-ranges unit-info next_cfi \ elfcopy addsections xlate_notes elfrdwrnop \ - dwelf_elf_e_machine_string + dwelf_elf_e_machine_string \ + getphdrnum asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ asm-tst6 asm-tst7 asm-tst8 asm-tst9 @@ -78,6 +80,14 @@ backtrace-child-biarch$(EXEEXT): backtrace-child.c $(AM_LDFLAGS) $(LDFLAGS) $(backtrace_child_LDFLAGS) \ -o $@ $< +# test_nlist checks its own symbol table, and expects various symbols +# to be in the order as specified in the source file. Explicitly set +# minimal CFLAGS +test-nlist$(EXEEXT): test-nlist.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(test_nlist_CFLAGS) $(test_nlist_LDADD) -o $@ $< + TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ update1 update2 update3 update4 \ run-show-die-info.sh run-get-files.sh run-get-lines.sh \ @@ -99,7 +109,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ run-find-prologues.sh run-allregs.sh run-addrcfi.sh \ - run-dwarfcfi.sh \ + run-dwarfcfi.sh run-nm-syms.sh \ run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \ run-readelf-compressed.sh \ run-readelf-const-values.sh \ @@ -112,7 +122,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-native-test.sh run-bug1-test.sh \ run-debuglink.sh run-debugaltlink.sh run-buildid.sh \ dwfl-bug-addr-overflow run-addrname-test.sh \ - dwfl-bug-fd-leak dwfl-bug-report \ + dwfl-bug-fd-leak dwfl-bug-report dwfl-report-segment-contiguous \ run-dwfl-bug-offline-rel.sh run-dwfl-addr-sect.sh \ run-disasm-x86.sh run-disasm-x86-64.sh \ run-early-offscn.sh run-dwarf-getmacros.sh run-dwarf-ranges.sh \ @@ -164,7 +174,9 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-strip-version.sh run-xlate-note.sh \ run-readelf-discr.sh \ run-dwelf_elf_e_machine_string.sh \ - run-elfclassify.sh run-elfclassify-self.sh + run-elfclassify.sh run-elfclassify-self.sh \ + run-pt_gnu_prop-tests.sh \ + run-getphdrnum.sh if !BIARCH export ELFUTILS_DISABLE_BIARCH = 1 @@ -204,6 +216,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile9.bz2 testfile10.bz2 testfile11.bz2 testfile12.bz2 \ testfile13.bz2 run-strip-test3.sh run-allfcts.sh \ testfile_class_func.bz2 testfile_nested_funcs.bz2 \ + testfile-lto-gcc10.bz2 \ + testfile-lto-gcc9.bz2 testfile-lto-gcc8.bz2 \ run-line2addr.sh run-elflint-test.sh testfile14.bz2 \ run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \ @@ -227,6 +241,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ + run-nm-syms.sh testfilesyms32.bz2 testfilesyms64.bz2 \ run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \ run-readelf-compressed.sh \ run-readelf-const-values.sh testfile-const-values.debug.bz2 \ @@ -451,6 +466,12 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ debuginfod-rpms/fedora30/hello2-debugsource-1.0-2.x86_64.rpm \ debuginfod-rpms/fedora30/hello2-two-1.0-2.x86_64.rpm \ debuginfod-rpms/fedora30/hello2-two-debuginfo-1.0-2.x86_64.rpm \ + debuginfod-rpms/fedora31/hello3-1.0-2.src.rpm \ + debuginfod-rpms/fedora31/hello3-1.0-2.x86_64.rpm \ + debuginfod-rpms/fedora31/hello3-debuginfo-1.0-2.x86_64.rpm \ + debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm \ + debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm \ + debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm \ debuginfod-rpms/hello2.spec. \ debuginfod-rpms/rhel6/hello2-1.0-2.i686.rpm \ debuginfod-rpms/rhel6/hello2-1.0-2.src.rpm \ @@ -459,8 +480,21 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ debuginfod-rpms/rhel7/hello2-1.0-2.src.rpm \ debuginfod-rpms/rhel7/hello2-1.0-2.x86_64.rpm \ debuginfod-rpms/rhel7/hello2-debuginfo-1.0-2.x86_64.rpm \ - debuginfod-rpms/rhel7/hello2-two-1.0-2.x86_64.rpm - + debuginfod-rpms/rhel7/hello2-two-1.0-2.x86_64.rpm \ + debuginfod-rpms/rhel7/hello2-two-1.0-2.x86_64.rpm \ + debuginfod-debs/hithere-dbgsym_1.0-1_amd64.ddeb \ + debuginfod-debs/hithere_1.0-1.debian.tar.xz \ + debuginfod-debs/hithere_1.0-1.dsc \ + debuginfod-debs/hithere_1.0-1_amd64.deb \ + debuginfod-debs/hithere_1.0.orig.tar.gz \ + debuginfod-tars/hello-1-1-x86_64.pkg.tar.xz \ + debuginfod-tars/hello-debug-1-1-x86_64.pkg.tar.bz2 \ + debuginfod-tars/pacman-sources/PKGBUILD \ + debuginfod-tars/pacman-sources/README.md \ + debuginfod-tars/pacman-sources/hello.c \ + run-pt_gnu_prop-tests.sh \ + testfile_pt_gnu_prop.bz2 testfile_pt_gnu_prop32.bz2 \ + run-getphdrnum.sh testfile-phdrs.elf.bz2 if USE_VALGRIND @@ -479,6 +513,7 @@ installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \ export abs_top_builddir; \ export libdir; export bindir; \ export LC_ALL; export LANG; export VALGRIND_CMD; \ + unset DEBUGINFOD_URLS; \ NM=$(NM); export NM; installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \ installed $(tests_rpath) \ @@ -493,6 +528,7 @@ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; VALGRIND_CMD=$(valgrind_cmd); \ export abs_srcdir; export abs_builddir; \ export abs_top_builddir; \ export LC_ALL; export LANG; export VALGRIND_CMD; \ + unset DEBUGINFOD_URLS; \ NM=$(NM); export NM; LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \ $(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm:$(abs_top_builddir)/debuginfod @@ -530,6 +566,7 @@ scnnames_LDADD = $(libelf) sectiondump_LDADD = $(libelf) showptable_LDADD = $(libelf) hash_LDADD = $(libelf) +test_nlist_CFLAGS =-g -O0 test_nlist_LDADD = $(libelf) msg_tst_LDADD = $(libelf) newscn_LDADD = $(libelf) @@ -588,6 +625,7 @@ test_elf_cntl_gelf_getshdr_LDADD = $(libelf) dwflsyms_LDADD = $(libdw) $(libelf) $(argp_LDADD) dwfllines_LDADD = $(libdw) $(libelf) $(argp_LDADD) dwfl_report_elf_align_LDADD = $(libdw) +dwfl_report_segment_contiguous_LDADD = $(libdw) $(libebl) $(libelf) varlocs_LDADD = $(libdw) $(libelf) $(argp_LDADD) backtrace_LDADD = $(libdw) $(libelf) $(argp_LDADD) # backtrace-child-biarch also uses those *_CFLAGS and *_LDLAGS variables: @@ -636,6 +674,7 @@ debuginfod_build_id_find_LDADD = $(libelf) $(libdw) xlate_notes_LDADD = $(libelf) elfrdwrnop_LDADD = $(libelf) dwelf_elf_e_machine_string_LDADD = $(libelf) $(libdw) +getphdrnum_LDADD = $(libelf) $(libdw) # We want to test the libelf header against the system elf.h header. # Don't include any -I CPPFLAGS. Except when we install our own elf.h. diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c index 9afc676b..cdf2a921 100644 --- a/tests/asm-tst1.c +++ b/tests/asm-tst1.c @@ -20,6 +20,7 @@ #endif #include <fcntl.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c index 2556d0c4..9e88b70c 100644 --- a/tests/asm-tst2.c +++ b/tests/asm-tst2.c @@ -20,6 +20,7 @@ #endif #include <fcntl.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c index e52cfbe1..39c1d90c 100644 --- a/tests/asm-tst3.c +++ b/tests/asm-tst3.c @@ -20,6 +20,7 @@ #endif #include <fcntl.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c index 52e9e20b..5114938b 100644 --- a/tests/asm-tst4.c +++ b/tests/asm-tst4.c @@ -20,6 +20,7 @@ #endif #include <fcntl.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c index 5a29b01c..dcb852f8 100644 --- a/tests/asm-tst5.c +++ b/tests/asm-tst5.c @@ -20,6 +20,7 @@ #endif #include <fcntl.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c index bd9b362b..829cd90c 100644 --- a/tests/asm-tst6.c +++ b/tests/asm-tst6.c @@ -19,6 +19,7 @@ # include <config.h> #endif +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c index 00cb2bfe..90179769 100644 --- a/tests/asm-tst7.c +++ b/tests/asm-tst7.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <inttypes.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c index 4fb0d998..a65509fe 100644 --- a/tests/asm-tst8.c +++ b/tests/asm-tst8.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <inttypes.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c index b6d0e431..681e872d 100644 --- a/tests/asm-tst9.c +++ b/tests/asm-tst9.c @@ -21,6 +21,7 @@ #include <fcntl.h> #include <inttypes.h> +#include ELFUTILS_HEADER(ebl) #include ELFUTILS_HEADER(asm) #include <libelf.h> #include <stdio.h> diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c index 907b4780..c81880d9 100644 --- a/tests/backtrace-data.c +++ b/tests/backtrace-data.c @@ -280,6 +280,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))) { case -1: assert (0); + break; case 0:; long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL); assert (l == 0); diff --git a/tests/debuginfod-debs/hithere-dbgsym_1.0-1_amd64.ddeb b/tests/debuginfod-debs/hithere-dbgsym_1.0-1_amd64.ddeb Binary files differnew file mode 100644 index 00000000..f9879eb6 --- /dev/null +++ b/tests/debuginfod-debs/hithere-dbgsym_1.0-1_amd64.ddeb diff --git a/tests/debuginfod-debs/hithere_1.0-1.debian.tar.xz b/tests/debuginfod-debs/hithere_1.0-1.debian.tar.xz Binary files differnew file mode 100644 index 00000000..9f0ce684 --- /dev/null +++ b/tests/debuginfod-debs/hithere_1.0-1.debian.tar.xz diff --git a/tests/debuginfod-debs/hithere_1.0-1.dsc b/tests/debuginfod-debs/hithere_1.0-1.dsc new file mode 100644 index 00000000..d5f72b90 --- /dev/null +++ b/tests/debuginfod-debs/hithere_1.0-1.dsc @@ -0,0 +1,19 @@ +Format: 3.0 (quilt) +Source: hithere +Binary: hithere +Architecture: any +Version: 1.0-1 +Maintainer: Lars Wirzenius <liw@liw.fi> +Standards-Version: 3.9.2 +Build-Depends: debhelper (>= 9) +Package-List: + hithere deb misc optional arch=any +Checksums-Sha1: + 2dcd65497a12a3ea03223f52186447bd5733dce9 617 hithere_1.0.orig.tar.gz + 0b71331ef1c714c5bac67878551864b7356c56ce 764 hithere_1.0-1.debian.tar.xz +Checksums-Sha256: + 63062b582a712f169f37a5f52a41aa3ca9a405aafb8aa837bc906fa413b62cdb 617 hithere_1.0.orig.tar.gz + 9afa907e360e626639ccb86b86e799429bea27149034aec5d5c7e500971d651e 764 hithere_1.0-1.debian.tar.xz +Files: + 5b2830fa1fcd44ce489774771625526e 617 hithere_1.0.orig.tar.gz + 70106164d9397c70c2c1a4594e9897e4 764 hithere_1.0-1.debian.tar.xz diff --git a/tests/debuginfod-debs/hithere_1.0-1_amd64.deb b/tests/debuginfod-debs/hithere_1.0-1_amd64.deb Binary files differnew file mode 100644 index 00000000..11d1e958 --- /dev/null +++ b/tests/debuginfod-debs/hithere_1.0-1_amd64.deb diff --git a/tests/debuginfod-debs/hithere_1.0.orig.tar.gz b/tests/debuginfod-debs/hithere_1.0.orig.tar.gz Binary files differnew file mode 100644 index 00000000..23abea70 --- /dev/null +++ b/tests/debuginfod-debs/hithere_1.0.orig.tar.gz diff --git a/tests/debuginfod-rpms/fedora31/hello3-1.0-2.src.rpm b/tests/debuginfod-rpms/fedora31/hello3-1.0-2.src.rpm Binary files differnew file mode 100644 index 00000000..d0b34540 --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-1.0-2.src.rpm diff --git a/tests/debuginfod-rpms/fedora31/hello3-1.0-2.x86_64.rpm b/tests/debuginfod-rpms/fedora31/hello3-1.0-2.x86_64.rpm Binary files differnew file mode 100644 index 00000000..8b2fe9bb --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-1.0-2.x86_64.rpm diff --git a/tests/debuginfod-rpms/fedora31/hello3-debuginfo-1.0-2.x86_64.rpm b/tests/debuginfod-rpms/fedora31/hello3-debuginfo-1.0-2.x86_64.rpm Binary files differnew file mode 100644 index 00000000..ee479ecb --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-debuginfo-1.0-2.x86_64.rpm diff --git a/tests/debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm b/tests/debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm Binary files differnew file mode 100644 index 00000000..890478e4 --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-debugsource-1.0-2.x86_64.rpm diff --git a/tests/debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm b/tests/debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm Binary files differnew file mode 100644 index 00000000..73fd939d --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-two-1.0-2.x86_64.rpm diff --git a/tests/debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm b/tests/debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm Binary files differnew file mode 100644 index 00000000..0cc24073 --- /dev/null +++ b/tests/debuginfod-rpms/fedora31/hello3-two-debuginfo-1.0-2.x86_64.rpm diff --git a/tests/debuginfod-rpms/hello3.spec. b/tests/debuginfod-rpms/hello3.spec. new file mode 100644 index 00000000..ffb95134 --- /dev/null +++ b/tests/debuginfod-rpms/hello3.spec. @@ -0,0 +1,60 @@ +Summary: hello3 -- double hello, world rpm +Name: hello3 +Version: 1.0 +Release: 2 +Group: Utilities +License: GPL +Distribution: RPM ^W Elfutils test suite. +Vendor: Red Hat Software +Packager: Red Hat Software <bugs@redhat.com> +URL: http://www.redhat.com +BuildRequires: gcc make +Source0: hello-1.0.tar.gz + +%description +Simple rpm demonstration with an eye to consumption by debuginfod. + +%package two +Summary: hello3two +License: GPL + +%description two +Dittoish. + +%prep +%setup -q -n hello-1.0 + +%build +mkdir foobar +gcc -g -O1 foobar///./../hello.c -o hello +gcc -g -O2 -D_FORTIFY_SOURCE=2 foobar///./../hello.c -o hello3 + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +cp hello $RPM_BUILD_ROOT/usr/local/bin/ +cp hello3 $RPM_BUILD_ROOT/usr/local/bin/ + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%attr(0751,root,root) /usr/local/bin/hello + +%files two +%defattr(-,root,root) +%attr(0751,root,root) /usr/local/bin/hello3 + +%changelog +* Tue Mar 24 2020 Frank Ch. Eigler <fche@redhat.com> +- New variant of hello2, with crazy source file paths + +* Thu Nov 14 2019 Frank Ch. Eigler <fche@redhat.com> +- Dropped misc files not relevant to debuginfod testing. + +* Wed May 18 2016 Mark Wielaard <mjw@redhat.com> +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com> +- create. diff --git a/tests/debuginfod-tars/hello-1-1-x86_64.pkg.tar.xz b/tests/debuginfod-tars/hello-1-1-x86_64.pkg.tar.xz Binary files differnew file mode 100644 index 00000000..fd784332 --- /dev/null +++ b/tests/debuginfod-tars/hello-1-1-x86_64.pkg.tar.xz diff --git a/tests/debuginfod-tars/hello-debug-1-1-x86_64.pkg.tar.bz2 b/tests/debuginfod-tars/hello-debug-1-1-x86_64.pkg.tar.bz2 Binary files differnew file mode 100644 index 00000000..8701861f --- /dev/null +++ b/tests/debuginfod-tars/hello-debug-1-1-x86_64.pkg.tar.bz2 diff --git a/tests/debuginfod-tars/pacman-sources/PKGBUILD b/tests/debuginfod-tars/pacman-sources/PKGBUILD new file mode 100644 index 00000000..0cac1706 --- /dev/null +++ b/tests/debuginfod-tars/pacman-sources/PKGBUILD @@ -0,0 +1,19 @@ +pkgname=hello +pkgver=1 +pkgrel=1 +pkgdesc="Simple hello world program to exercise debuginfod" +arch=('x86_64') +source=('hello.c') +sha256sums=('f85badd2007451bbda4791e7fe820b41be0a424172a567573511688bff975235') + +# guarantee that split debug packages are turned on +options=('strip' 'debug') + +build() { + # implicit Makefile + make hello +} + +package() { + install -Dm755 hello "${pkgdir}"/usr/bin/hello +} diff --git a/tests/debuginfod-tars/pacman-sources/README.md b/tests/debuginfod-tars/pacman-sources/README.md new file mode 100644 index 00000000..17f59bcb --- /dev/null +++ b/tests/debuginfod-tars/pacman-sources/README.md @@ -0,0 +1,19 @@ +# Creating sample pacman packages + +You will need: +- an archlinux installation +- `pacman -S base-devel` for basic build requirements (like debian "build-essential") + +Run `makepkg` inside this directory to produce *.pkg.tar.* archives. This may +be .xz, .zst, .gz etc. depending on the current defaults, see makepkg.conf(5) +"PKGEXT" for details. The archives will appear in the current directory, or the +"PKGDEST" defined by makepkg.conf(5). + +# Byte-for-byte reproduction + +You will need: +- an archlinux installation +- `pacman -S devtools` for the clean chroot builder/reproducer + +Run `makerepropkg /path/to/hello-debug-1-1-x86_64.pkg.tar.xz` (or whichever the +archive filename is) inside this directory. diff --git a/tests/debuginfod-tars/pacman-sources/hello.c b/tests/debuginfod-tars/pacman-sources/hello.c new file mode 100644 index 00000000..c1ef1554 --- /dev/null +++ b/tests/debuginfod-tars/pacman-sources/hello.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main() { + printf("hello\n"); + return 0; +} diff --git a/tests/dwfl-report-segment-contiguous.c b/tests/dwfl-report-segment-contiguous.c new file mode 100644 index 00000000..61e6bfee --- /dev/null +++ b/tests/dwfl-report-segment-contiguous.c @@ -0,0 +1,82 @@ +/* Test bug in dwfl_report_segment() coalescing. + Copyright (C) 2019 Facebook + This file is part of elfutils. + + This file 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 3 of the License, or + (at your option) any later version. + + elfutils 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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> +#include <assert.h> +#include <inttypes.h> +#include <stdio.h> +#include <stdio_ext.h> +#include <locale.h> +#include ELFUTILS_HEADER(dwfl) + + +static const Dwfl_Callbacks offline_callbacks = + { + .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo), + .section_address = INTUSE(dwfl_offline_section_address), + }; + + +int +main (void) +{ + /* We use no threads here which can interfere with handling a stream. */ + (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); + + /* Set locale. */ + (void) setlocale (LC_ALL, ""); + + Dwfl *dwfl = dwfl_begin (&offline_callbacks); + assert (dwfl != NULL); + + GElf_Phdr phdr1 = + { + .p_type = PT_LOAD, + .p_flags = PF_R, + .p_offset = 0xf00, + .p_vaddr = 0xf00, + .p_filesz = 0x100, + .p_memsz = 0x100, + .p_align = 4, + }; + + int ndx = dwfl_report_segment (dwfl, 1, &phdr1, 0, dwfl); + assert(ndx == 1); + + ndx = dwfl_addrsegment (dwfl, 0xf00, NULL); + assert(ndx == 1); + + GElf_Phdr phdr2 = + { + .p_type = PT_LOAD, + .p_flags = PF_R | PF_W, + .p_offset = 0x1000, + .p_vaddr = 0x1000, + .p_filesz = 0x100, + .p_memsz = 0x100, + .p_align = 4, + }; + ndx = dwfl_report_segment (dwfl, 2, &phdr2, 0, dwfl); + assert(ndx == 2); + + ndx = dwfl_addrsegment (dwfl, 0x1000, NULL); + assert(ndx == 1 || ndx == 2); + + dwfl_end (dwfl); + + return 0; +} diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c index 66ab77ba..0d9c020e 100644 --- a/tests/elfputzdata.c +++ b/tests/elfputzdata.c @@ -105,14 +105,17 @@ main (int argc, char *argv[]) printf ("Unexpected data size for orig section %zd\n", idx); return -1; } - char *orig_buf = malloc (d->d_size); - if (orig_size > 0 && orig_buf == NULL) + char *orig_buf = NULL; + if (orig_size > 0) { - printf ("No memory to copy section %zd data\n", idx); - return -1; + orig_buf = malloc (d->d_size); + if (orig_buf == NULL) + { + printf ("No memory to copy section %zd data\n", idx); + return -1; + } + memcpy (orig_buf, d->d_buf, orig_size); } - if (orig_size > 0) - memcpy (orig_buf, d->d_buf, orig_size); bool forced = false; if (gnu) @@ -175,7 +178,8 @@ main (int argc, char *argv[]) } if (new_size == orig_size - && memcmp (orig_buf, d->d_buf, orig_size) == 0) + && (orig_buf == NULL + || memcmp (orig_buf, d->d_buf, orig_size) == 0)) { printf ("section %zd didn't compress\n", idx); return -1; @@ -211,7 +215,8 @@ main (int argc, char *argv[]) return -1; } if (newer_size != orig_size - && memcmp (orig_buf, d->d_buf, orig_size) != 0) + && (orig_buf == NULL + || memcmp (orig_buf, d->d_buf, orig_size) != 0)) { printf ("section %zd didn't correctly uncompress\n", idx); return -1; diff --git a/tests/getphdrnum.c b/tests/getphdrnum.c new file mode 100644 index 00000000..07f75db0 --- /dev/null +++ b/tests/getphdrnum.c @@ -0,0 +1,48 @@ +#include "config.h" + +#include <fcntl.h> +#include <libelf.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> + +int main (int argc, const char **argv) +{ + int fd; + Elf *elf; + size_t phnum; + + if (argc != 2) + { + fprintf (stderr, "usage: %s FILE\n", argv[0]); + return EXIT_FAILURE; + } + + fd = open (argv[1], O_RDONLY); + if (fd == -1) + { + perror ("open"); + return EXIT_FAILURE; + } + elf_version (EV_CURRENT); + elf = elf_begin (fd, ELF_C_READ, NULL); + if (!elf) + { + fprintf (stderr, "elf_begin: %s\n", elf_errmsg (-1)); + return EXIT_FAILURE; + } + if (elf_getphdrnum (elf, &phnum)) + { + fprintf(stderr, "elf_getphdrnum: %s\n", elf_errmsg (-1)); + return EXIT_FAILURE; + } + + printf("%zu\n", phnum); + + elf_end (elf); + close (fd); + + return EXIT_SUCCESS; +} diff --git a/tests/run-allfcts.sh b/tests/run-allfcts.sh index 6eaf13c8..9c0a55d8 100755 --- a/tests/run-allfcts.sh +++ b/tests/run-allfcts.sh @@ -91,4 +91,83 @@ testrun_compare ${abs_builddir}/allfcts testfile_nested_funcs testfile_class_fun /home/mark/src/tests/nested/class_func.cxx:13:main EOF +# = testfile-lto.h = +# struct t +# { +# int *p; +# int c; +# }; +# +# extern int foo (int i, struct t *t); + +# = testfile-lto-func.c = +# #include "testfile-lto.h" +# +# int +# foo (int i, struct t *t) +# { +# int j, res = 0; +# for (j = 0; j < i && j < t->c; j++) +# res += t->p[j]; +# +# return res; +# } + +# = testfile-lto-main.c = +# #include "testfile-lto.h" +# +# static struct t g; +# +# int +# main (int argc, char **argv) +# { +# int i; +# int j[argc]; +# g.c = argc; +# g.p = j; +# for (i = 0; i < argc; i++) +# j[i] = (int) argv[i][0]; +# return foo (3, &g); +# } + +# Using gcc (GCC) 10.0.1 20200430 (Red Hat 10.0.1-0.13) +# gcc -g -O2 -flto -c testfile-lto-func.c +# gcc -g -O2 -flto -c testfile-lto-main.c +# gcc -g -O2 -flto -o testfile-lto-gcc10 testfile-lto-func.o testfile-lto-main.o + +testfiles testfile-lto-gcc10 + +testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc10 <<\EOF +/home/mark/src/tests/testfile-lto-main.c:6:main +/home/mark/src/tests/testfile-lto-func.c:4:foo +/home/mark/src/tests/testfile-lto-main.c:6:main +EOF + +# Using gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3) +# gcc -g -O2 -flto -c testfile-lto-func.c +# gcc -g -O2 -flto -c testfile-lto-main.c +# gcc -g -O2 -flto -o testfile-lto-gcc8 testfile-lto-func.o testfile-lto-main.o + +testfiles testfile-lto-gcc8 + +testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc8 <<\EOF +/home/mark/src/tests/testfile-lto-func.c:4:foo +/home/mark/src/tests/testfile-lto-main.c:6:main +/home/mark/src/tests/testfile-lto-main.c:6:main +/home/mark/src/tests/testfile-lto-func.c:4:foo +EOF + +# gcc (GCC) 9.1.1 20190605 (Red Hat 9.1.1-2) +# gcc -g -O2 -flto -c testfile-lto-func.c +# gcc -g -O2 -flto -c testfile-lto-main.c +# gcc -g -O2 -flto -o testfile-lto-gcc9 testfile-lto-func.o testfile-lto-main.o + +testfiles testfile-lto-gcc9 + +testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc9 <<\EOF +/home/mark/src/tests/testfile-lto-main.c:6:main +/home/mark/src/tests/testfile-lto-func.c:4:foo +/home/mark/src/tests/testfile-lto-main.c:6:main +EOF + exit 0 diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh index 0ade03b7..7faad331 100755 --- a/tests/run-debuginfod-find.sh +++ b/tests/run-debuginfod-find.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2019 Red Hat, Inc. +# Copyright (C) 2019-2020 Red Hat, Inc. # This file is part of elfutils. # # This file is free software; you can redistribute it and/or modify @@ -18,19 +18,31 @@ . $srcdir/test-subr.sh # includes set -e +type curl 2>/dev/null || (echo "need curl"; exit 77) +type rpm2cpio 2>/dev/null || (echo "need rpm2cpio"; exit 77) +type bzcat 2>/dev/null || (echo "need bzcat"; exit 77) +bsdtar --version | grep -q zstd && zstd=true || zstd=false +echo "zstd=$zstd bsdtar=`bsdtar --version`" + +# for test case debugging, uncomment: +#set -x +#VERBOSE=-vvvv + DB=${PWD}/.debuginfod_tmp.sqlite tempfiles $DB export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache PID1=0 PID2=0 +PID3=0 cleanup() { if [ $PID1 -ne 0 ]; then kill $PID1; wait $PID1; fi if [ $PID2 -ne 0 ]; then kill $PID2; wait $PID2; fi + if [ $PID3 -ne 0 ]; then kill $PID3; wait $PID3; fi - rm -rf F R L ${PWD}/.client_cache* + rm -rf F R D L Z ${PWD}/foobar ${PWD}/mocktree ${PWD}/.client_cache* ${PWD}/tmp* exit_cleanup } @@ -52,8 +64,8 @@ done # So we gather the LD_LIBRARY_PATH with this cunning trick: ldpath=`testrun sh -c 'echo $LD_LIBRARY_PATH'` -mkdir F R L -# not tempfiles F R L - they are directories which we clean up manually +mkdir F R L D Z +# not tempfiles F R L D Z - they are directories which we clean up manually ln -s ${abs_builddir}/dwfllines L/foo # any program not used elsewhere in this test wait_ready() @@ -77,13 +89,15 @@ wait_ready() done; if [ $timeout -eq 0 ]; then - echo "metric $what never changed to $value on port $port" + echo "metric $what never changed to $value on port $port" + curl -s http://127.0.0.1:$port/metrics exit 1; fi } -env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod -F -R -d $DB -p $PORT1 -t0 -g0 R F L & +env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 --fdcache-fds 1 --fdcache-mbs 2 -Z .tar.xz -Z .tar.bz2=bzcat -v R F Z L > vlog4 2>&1 & PID1=$! +tempfiles vlog4 # Server must become ready wait_ready $PORT1 'ready' 1 export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing / @@ -101,16 +115,21 @@ export DEBUGINFOD_TIMEOUT=10 # cannot find it without debuginfod. echo "int main() { return 0; }" > ${PWD}/prog.c tempfiles prog.c -gcc -g -o prog ${PWD}/prog.c - ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog +# Create a subdirectory to confound source path names +mkdir foobar +gcc -Wl,--build-id -g -o prog ${PWD}/foobar///./../prog.c +testrun ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ -a prog | grep 'Build ID' | cut -d ' ' -f 7` +wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 mv prog F mv prog.debug F kill -USR1 $PID1 # Wait till both files are in the index. -wait_ready $PORT1 'thread_work_total{file="F"}' 2 +wait_ready $PORT1 'thread_work_total{role="traverse"}' 2 +wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 +wait_ready $PORT1 'thread_busy{role="scan"}' 0 ######################################################################## @@ -125,12 +144,62 @@ rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID` cmp $filename F/prog.debug -filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID` +filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable F/prog` cmp $filename F/prog +# raw source filename +filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID ${PWD}/foobar///./../prog.c` +cmp $filename ${PWD}/prog.c + +# and also the canonicalized one filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID ${PWD}/prog.c` cmp $filename ${PWD}/prog.c + +######################################################################## + +# Test whether the cache default locations are correct + +mkdir tmphome + +# $HOME/.cache should be created. +testrun env HOME=$PWD/tmphome XDG_CACHE_HOME= DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID +if [ ! -f $PWD/tmphome/.cache/debuginfod_client/$BUILDID/debuginfo ]; then + echo "could not find cache in $PWD/tmphome/.cache" + exit 1 +fi + +# $HOME/.cache should be found. +testrun env HOME=$PWD/tmphome XDG_CACHE_HOME= DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID +if [ ! -f $PWD/tmphome/.cache/debuginfod_client/$BUILDID/executable ]; then + echo "could not find cache in $PWD/tmphome/.cache" + exit 1 +fi + +# $XDG_CACHE_HOME should take priority over $HOME.cache. +testrun env HOME=$PWD/tmphome XDG_CACHE_HOME=$PWD/tmpxdg DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID +if [ ! -f $PWD/tmpxdg/debuginfod_client/$BUILDID/debuginfo ]; then + echo "could not find cache in $PWD/tmpxdg/" + exit 1 +fi + +# A cache at the old default location ($HOME/.debuginfod_client_cache) should take +# priority over $HOME/.cache, $XDG_CACHE_HOME. +cp -r $DEBUGINFOD_CACHE_PATH tmphome/.debuginfod_client_cache + +# Add a file that doesn't exist in $HOME/.cache, $XDG_CACHE_HOME. +mkdir tmphome/.debuginfod_client_cache/deadbeef +echo ELF... > tmphome/.debuginfod_client_cache/deadbeef/debuginfo +filename=`testrun env HOME=$PWD/tmphome XDG_CACHE_HOME=$PWD/tmpxdg DEBUGINFOD_CACHE_PATH= ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo deadbeef` +cmp $filename tmphome/.debuginfod_client_cache/deadbeef/debuginfo + +# $DEBUGINFO_CACHE_PATH should take priority over all else. +testrun env HOME=$PWD/tmphome XDG_CACHE_HOME=$PWD/tmpxdg DEBUGINFOD_CACHE_PATH=$PWD/tmpcache ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID +if [ ! -f $PWD/tmpcache/$BUILDID/debuginfo ]; then + echo "could not find cache in $PWD/tmpcache/" + exit 1 +fi + ######################################################################## # Add artifacts to the search paths and test whether debuginfod finds them while already running. @@ -138,31 +207,46 @@ cmp $filename ${PWD}/prog.c # Build another, non-stripped binary echo "int main() { return 0; }" > ${PWD}/prog2.c tempfiles prog2.c -gcc -g -o prog2 ${PWD}/prog2.c +gcc -Wl,--build-id -g -o prog2 ${PWD}/prog2.c BUILDID2=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ -a prog2 | grep 'Build ID' | cut -d ' ' -f 7` mv prog2 F kill -USR1 $PID1 # Now there should be 3 files in the index -wait_ready $PORT1 'thread_work_total{file="F"}' 3 +wait_ready $PORT1 'thread_work_total{role="traverse"}' 3 +wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 +wait_ready $PORT1 'thread_busy{role="scan"}' 0 # Rerun same tests for the prog2 binary filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find -v debuginfo $BUILDID2 2>vlog` cmp $filename F/prog2 cat vlog grep -q Progress vlog +grep -q Downloaded.from vlog tempfiles vlog -filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2` +filename=`testrun env DEBUGINFOD_PROGRESS=1 ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 2>vlog2` cmp $filename F/prog2 +cat vlog2 +grep -q 'Downloading.*http' vlog2 +tempfiles vlog2 filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c` cmp $filename ${PWD}/prog2.c -cp -rp ${abs_srcdir}/debuginfod-rpms R +cp -rvp ${abs_srcdir}/debuginfod-rpms R +if [ "$zstd" = "false" ]; then # nuke the zstd fedora 31 ones + rm -vrf R/debuginfod-rpms/fedora31 +fi + +cp -rvp ${abs_srcdir}/debuginfod-tars Z kill -USR1 $PID1 # All rpms need to be in the index rpms=$(find R -name \*rpm | wc -l) -wait_ready $PORT1 'scanned_total{source="rpm"}' $rpms +wait_ready $PORT1 'scanned_total{source=".rpm archive"}' $rpms +txz=$(find Z -name \*tar.xz | wc -l) +wait_ready $PORT1 'scanned_total{source=".tar.xz archive"}' $txz +tb2=$(find Z -name \*tar.bz2 | wc -l) +wait_ready $PORT1 'scanned_total{source=".tar.bz2 archive"}' $tb2 kill -USR1 $PID1 # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs # Expect all source files found in the rpms (they are all called hello.c :) @@ -177,7 +261,7 @@ for i in $newrpms; do mkdir $subdir; cd $subdir; ls -lah ../$i - rpm2cpio ../$i | cpio -id; + rpm2cpio ../$i | cpio -ivd; cd ..; done sourcefiles=$(find -name \*\\.debug \ @@ -187,11 +271,11 @@ sourcefiles=$(find -name \*\\.debug \ cd .. rm -rf extracted -wait_ready $PORT1 'found_sourcerefs_total{source="rpm"}' $sourcefiles +wait_ready $PORT1 'found_sourcerefs_total{source=".rpm archive"}' $sourcefiles -# Run a bank of queries against the debuginfod-rpms test cases +# Run a bank of queries against the debuginfod-rpms / debuginfod-debs test cases -rpm_test() { +archive_test() { __BUILDID=$1 __SOURCEPATH=$2 __SOURCESHA1=$3 @@ -200,29 +284,51 @@ rpm_test() { buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ -a $filename | grep 'Build ID' | cut -d ' ' -f 7` test $__BUILDID = $buildid + # check that timestamps are plausible - older than the near-present (tmpdir mtime) + test $filename -ot `pwd` + + # run again to assure that fdcache is being enjoyed + filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $__BUILDID` + buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ + -a $filename | grep 'Build ID' | cut -d ' ' -f 7` + test $__BUILDID = $buildid + test $filename -ot `pwd` filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $__BUILDID` buildid=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ -a $filename | grep 'Build ID' | cut -d ' ' -f 7` test $__BUILDID = $buildid - - filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $__BUILDID $__SOURCEPATH` - hash=`cat $filename | sha1sum | awk '{print $1}'` - test $__SOURCESHA1 = $hash + test $filename -ot `pwd` + + if test "x$__SOURCEPATH" != "x"; then + filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $__BUILDID $__SOURCEPATH` + hash=`cat $filename | sha1sum | awk '{print $1}'` + test $__SOURCESHA1 = $hash + test $filename -ot `pwd` + fi } # common source file sha1 SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1 +# fedora31 +if [ $zstd = true ]; then + # fedora31 uses zstd compression on rpms, older rpm2cpio/libarchive can't handle it + # and we're not using the fancy -Z '.rpm=(rpm2cpio|zstdcat)<' workaround in this testsuite + archive_test 420e9e3308971f4b817cc5bf83928b41a6909d88 /usr/src/debug/hello3-1.0-2.x86_64/foobar////./../hello.c $SHA + archive_test 87c08d12c78174f1082b7c888b3238219b0eb265 /usr/src/debug/hello3-1.0-2.x86_64///foobar/./..//hello.c $SHA +fi # fedora30 -rpm_test c36708a78618d597dee15d0dc989f093ca5f9120 /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA -rpm_test 41a236eb667c362a1c4196018cc4581e09722b1b /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA +archive_test c36708a78618d597dee15d0dc989f093ca5f9120 /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA +archive_test 41a236eb667c362a1c4196018cc4581e09722b1b /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA # rhel7 -rpm_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA -rpm_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA +archive_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA +archive_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA # rhel6 -rpm_test bbbf92ebee5228310e398609c23c2d7d53f6e2f9 /usr/src/debug/hello-1.0/hello.c $SHA -rpm_test d44d42cbd7d915bc938c81333a21e355a6022fb7 /usr/src/debug/hello-1.0/hello.c $SHA +archive_test bbbf92ebee5228310e398609c23c2d7d53f6e2f9 /usr/src/debug/hello-1.0/hello.c $SHA +archive_test d44d42cbd7d915bc938c81333a21e355a6022fb7 /usr/src/debug/hello-1.0/hello.c $SHA +# arch +archive_test cee13b2ea505a7f37bd20d271c6bc7e5f8d2dfcb /usr/src/debug/hello.c 7a1334e086b97e5f124003a6cfb3ed792d10cdf4 RPM_BUILDID=d44d42cbd7d915bc938c81333a21e355a6022fb7 # in rhel6/ subdir, for a later test @@ -235,6 +341,8 @@ RPM_BUILDID=d44d42cbd7d915bc938c81333a21e355a6022fb7 # in rhel6/ subdir, for a l rm -r R/debuginfod-rpms/rhel6/* kill -USR2 $PID1 # groom cycle # Expect 3 rpms to be deleted by the groom +# 1 groom already took place at/soon-after startup, so -USR2 makes 2 +wait_ready $PORT1 'thread_work_total{role="groom"}' 2 wait_ready $PORT1 'groom{statistic="file d/e"}' 3 rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests @@ -257,16 +365,43 @@ export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache2 mkdir -p $DEBUGINFOD_CACHE_PATH # NB: inherits the DEBUGINFOD_URLS to the first server # NB: run in -L symlink-following mode for the L subdir -env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod -F -d ${DB}_2 -p $PORT2 -L L & +env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -U -d ${DB}_2 -p $PORT2 -L L D > vlog3 2>&1 & PID2=$! +tempfiles vlog3 tempfiles ${DB}_2 wait_ready $PORT2 'ready' 1 +wait_ready $PORT2 'thread_work_total{role="traverse"}' 1 +wait_ready $PORT2 'thread_work_pending{role="scan"}' 0 +wait_ready $PORT2 'thread_busy{role="scan"}' 0 # have clients contact the new server export DEBUGINFOD_URLS=http://127.0.0.1:$PORT2 + +if type bsdtar 2>/dev/null; then + # copy in the deb files + cp -rvp ${abs_srcdir}/debuginfod-debs/*deb D + kill -USR1 $PID2 + # All debs need to be in the index + debs=$(find D -name \*.deb | wc -l) + wait_ready $PORT2 'scanned_total{source=".deb archive"}' `expr $debs` + ddebs=$(find D -name \*.ddeb | wc -l) + wait_ready $PORT2 'scanned_total{source=".ddeb archive"}' `expr $ddebs` + + # ubuntu + archive_test f17a29b5a25bd4960531d82aa6b07c8abe84fa66 "" "" +fi + rm -rf $DEBUGINFOD_CACHE_PATH testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID +# send a request to stress XFF and User-Agent federation relay; +# we'll grep for the two patterns in vlog4 +curl -s -H 'User-Agent: TESTCURL' -H 'X-Forwarded-For: TESTXFF' $DEBUGINFOD_URLS/buildid/deaddeadbeef00000000/debuginfo -o /dev/null || true + +grep UA:TESTCURL vlog4 +grep XFF:TESTXFF vlog4 + + # confirm that first server can't resolve symlinked info in L/ but second can BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \ -a L/foo | grep 'Build ID' | cut -d ' ' -f 7` @@ -288,14 +423,22 @@ testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog2 1 ######################################################################## -# Fetch some metrics, if curl program is installed -if type curl 2>/dev/null; then - curl http://127.0.0.1:$PORT1/badapi - curl http://127.0.0.1:$PORT1/metrics - curl http://127.0.0.1:$PORT2/metrics - curl http://127.0.0.1:$PORT1/metrics | grep -q 'http_responses_total.*result.*error' - curl http://127.0.0.1:$PORT2/metrics | grep -q 'http_responses_total.*result.*upstream' -fi +# Fetch some metrics +curl -s http://127.0.0.1:$PORT1/badapi +curl -s http://127.0.0.1:$PORT1/metrics +curl -s http://127.0.0.1:$PORT2/metrics +curl -s http://127.0.0.1:$PORT1/metrics | grep -q 'http_responses_total.*result.*error' +curl -s http://127.0.0.1:$PORT1/metrics | grep -q 'http_responses_total.*result.*fdcache' +curl -s http://127.0.0.1:$PORT2/metrics | grep -q 'http_responses_total.*result.*upstream' +curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_duration_milliseconds_count' +curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_duration_milliseconds_sum' +curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count' +curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_sum' + +# And generate a few errors into the second debuginfod's logs, for analysis just below +curl -s http://127.0.0.1:$PORT2/badapi > /dev/null || true +curl -s http://127.0.0.1:$PORT2/buildid/deadbeef/debuginfo > /dev/null || true + ######################################################################## @@ -310,8 +453,21 @@ tempfiles .debuginfod_* testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog2 1 +# check out the debuginfod logs for the new style status lines +# cat vlog3 +grep -q 'UA:.*XFF:.*GET /buildid/.* 200 ' vlog3 +grep -q 'UA:.*XFF:.*GET /metrics 200 ' vlog3 +grep -q 'UA:.*XFF:.*GET /badapi 503 ' vlog3 +grep -q 'UA:.*XFF:.*GET /buildid/deadbeef.* 404 ' vlog3 + ######################################################################## +# Add some files to the cache that do not fit its naming format. +# They should survive cache cleaning. +mkdir $DEBUGINFOD_CACHE_PATH/malformed +touch $DEBUGINFOD_CACHE_PATH/malformed0 +touch $DEBUGINFOD_CACHE_PATH/malformed/malformed1 + # Trigger a cache clean and run the tests again. The clients should be unable to # find the target. echo 0 > $DEBUGINFOD_CACHE_PATH/cache_clean_interval_s @@ -321,4 +477,36 @@ testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1 testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 && false || true +if [ ! -f $DEBUGINFOD_CACHE_PATH/malformed0 ] \ + || [ ! -f $DEBUGINFOD_CACHE_PATH/malformed/malformed1 ]; then + echo "unrelated files did not survive cache cleaning" + exit 1 +fi + +# Test debuginfod without a path list; reuse $PORT1 +env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -U -d :memory: -p $PORT1 -L -F & +PID3=$! +wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 +wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 +wait_ready $PORT1 'thread_busy{role="scan"}' 0 +kill -int $PID3 +wait $PID3 +PID3=0 + +######################################################################## +# Test fetching a file using file:// . No debuginfod server needs to be run for +# this test. +local_dir=${PWD}/mocktree/buildid/aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd/source/my/path +mkdir -p ${local_dir} +echo "int main() { return 0; }" > ${local_dir}/main.c + +# first test that is doesn't work, when no DEBUGINFOD_URLS is set +DEBUGINFOD_URLS="" +testrun ${abs_top_builddir}/debuginfod/debuginfod-find source aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd /my/path/main.c && false || true + +# Now test is with proper DEBUGINFOD_URLS +DEBUGINFOD_URLS="file://${PWD}/mocktree/" +filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd /my/path/main.c` +cmp $filename ${local_dir}/main.c + exit 0 diff --git a/tests/run-elfclassify.sh b/tests/run-elfclassify.sh index 5a849bbd..fb14139d 100755 --- a/tests/run-elfclassify.sh +++ b/tests/run-elfclassify.sh @@ -267,7 +267,7 @@ $(echo $kmod_files | sed -e "s/ /\n/g") EOF echo "gnu compressed kmods are unstripped" -${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files +testrun ${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files testrun ${abs_top_builddir}/src/elfclassify --unstripped $kmod_files testrun_compare ${abs_top_builddir}/src/elfclassify --unstripped --print $kmod_files <<EOF $(echo $kmod_files | sed -e "s/ /\n/g") @@ -312,7 +312,7 @@ $(echo $debug_files | sed -e "s/ /\n/g") EOF echo "compress the debug sections and try again" -${abs_top_builddir}/src/elfcompress -t gnu --force $debug_files +testrun ${abs_top_builddir}/src/elfcompress -t gnu --force $debug_files echo "again unstripped" testrun ${abs_top_builddir}/src/elfclassify --unstripped $debug_files diff --git a/tests/run-getphdrnum.sh b/tests/run-getphdrnum.sh new file mode 100755 index 00000000..889cdaf1 --- /dev/null +++ b/tests/run-getphdrnum.sh @@ -0,0 +1,137 @@ +#! /bin/sh + +# testfile-phdrs.elf generated with python3 script +# import struct +# import sys +# +# phnum = 66000 +# +# sys.stdout.buffer.write( +# struct.pack( +# "<16BHHIQQQIHHHHHH", +# # EI_MAG +# *b"\x7fELF", +# # EI_CLASS = ELFCLASS64 +# 2, +# # EI_DATA = ELFDATA2LSB +# 1, +# # EI_VERSION +# 1, +# # EI_OSABI = ELFOSABI_SYSV +# 0, +# # EI_ABIVERSION +# 0, +# # EI_PAD +# *bytes(7), +# # e_type = ET_CORE +# 4, +# # e_machine = EM_X86_64 +# 62, +# # e_version +# 1, +# # e_entry +# 0, +# # e_phoff = sizeof(Elf64_Ehdr) + sizeof(Elf64_Shdr) +# 128, +# # e_shoff = sizeof(Elf64_Ehdr) +# 64, +# # e_flags +# 0, +# # e_ehsize +# 64, +# # e_phentsize +# 56, +# # e_phnum = PN_XNUM +# 0xFFFF, +# # e_shentsize +# 64, +# # e_shnum +# 1, +# # e_shstrndx +# 0, +# ) +# ) +# +# sys.stdout.buffer.write( +# struct.pack( +# "<IIQQQQIIQQ", +# # sh_name +# 0, +# # sh_type = SHT_NULL +# 0, +# # sh_flags +# 0, +# # sh_addr +# 0, +# # sh_offset +# 0, +# # sh_size +# 0, +# # sh_link +# 0, +# # sh_info +# phnum, +# # sh_addralign +# 0, +# # sh_entsize +# 0, +# ) +# ) +# +# for i in range(phnum): +# sys.stdout.buffer.write( +# struct.pack( +# "<IIQQQQQQ", +# # p_type = PT_LOAD +# 1, +# # p_flags = PF_X|PF_W|PF_R +# 0x7, +# # p_offset +# 0, +# # p_vaddr +# # i * 4096, +# 4096, +# # p_paddr +# 0, +# # p_filesz +# 0, +# # p_memsz +# 4096, +# # p_align +# 0, +# ) +# ) + +. $srcdir/test-subr.sh + +testfiles testfile-phdrs.elf + +testrun_compare ${abs_top_builddir}/src/readelf -h testfile-phdrs.elf<<\EOF +ELF Header: + Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 + Class: ELF64 + Data: 2's complement, little endian + Ident Version: 1 (current) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: CORE (Core file) + Machine: AMD x86-64 + Version: 1 (current) + Entry point address: 0 + Start of program headers: 128 (bytes into file) + Start of section headers: 64 (bytes into file) + Flags: + Size of this header: 64 (bytes) + Size of program header entries: 56 (bytes) + Number of program headers entries: 65535 (66000 in [0].sh_info) + Size of section header entries: 64 (bytes) + Number of section headers entries: 1 + Section header string table index: 0 + +EOF + +testrun_compare ${abs_builddir}/getphdrnum testfile-phdrs.elf<<\EOF +66000 +EOF + +exit 0 diff --git a/tests/run-lfs-symbols.sh b/tests/run-lfs-symbols.sh index f0894405..b65391b6 100755 --- a/tests/run-lfs-symbols.sh +++ b/tests/run-lfs-symbols.sh @@ -46,41 +46,44 @@ makeprint() { } testrun_lfs() { - bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS") - if [ -n "$bad" ]; then - echo "$1 contains non-lfs symbols:" $bad + echo "checking $1" + if [ -e "$1" ]; then + bad=$(testrun ${abs_top_builddir}/src/nm -u "$1" | awk "$LFS") + if [ -n "$bad" ]; then + echo "$1 contains non-lfs symbols:" $bad + exit_status=1 + fi + else + echo "$1 doesn't exist" exit_status=1 fi } -# First sanity-check that LFS detection works. +echo First sanity-check that LFS detection works. exit_status=0 testrun_lfs ./testfile-nolfs if [ $exit_status -eq 0 ]; then echo "Didn't detect any problem with testfile-nolfs!" exit 99 fi +echo exit_status=0 -# Check all normal build targets. +echo Check all normal build targets. for dir in libelf libdw libasm libcpu src; do dir=${abs_top_builddir}/$dir for program in $(makeprint PROGRAMS $dir); do testrun_lfs $dir/$program done done +echo -# Check all libebl modules. -dir=${abs_top_builddir}/backends -for module in $(makeprint modules $dir); do - testrun_lfs $dir/libebl_$module.so -done - -# Check all test programs. +echo Check all test programs. dir=${abs_builddir} for program in $(makeprint check_PROGRAMS $dir); do testrun_lfs $dir/$program done +echo exit $exit_status diff --git a/tests/run-nm-syms.sh b/tests/run-nm-syms.sh new file mode 100755 index 00000000..ddf09222 --- /dev/null +++ b/tests/run-nm-syms.sh @@ -0,0 +1,166 @@ +#! /bin/sh +# Copyright (C) 2020 Red Hat, Inc. +# This file is part of elfutils. +# +# This file 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 3 of the License, or +# (at your option) any later version. +# +# elfutils 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 <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +# void *SYM1; +# void *SYM2 = 0; +# extern void *SYM3; +# static void *SYM4; +# +# void *SYM6 = &SYM3; +# static void *SYM7 = &SYM3; +# +# void *SYM8 __attribute__((__weak__)); +# +# void FUN1 (void) { } +# static void FUN2 (void) { } +# extern void FUN3 (void); +# +# void *FREF = FUN3; +# +# void __attribute__((__weak__)) FUN4 (void) { }; +# +# int NUM0 = 0; __asm__(".type NUM0,%gnu_unique_object"); +# int __thread NUM1 = 1; +# +# gcc -m64 -c syms.c -o testfilesyms64 +# gcc -m32 -c syms.c -o testfilesyms32 + +testfiles testfilesyms32 testfilesyms64 + +testrun_compare ${abs_top_builddir}/src/nm --format=bsd testfilesyms32 <<\EOF +00000008 D FREF +00000000 T FUN1 +00000010 t FUN2 + U FUN3 +00000020 W FUN4 +00000008 u NUM0 +00000000 D NUM1 +00000004 C SYM1 +00000000 B SYM2 + U SYM3 +0000000c b SYM4 +00000000 D SYM6 +00000004 d SYM7 +00000004 V SYM8 + U _GLOBAL_OFFSET_TABLE_ +00000000 T __x86.get_pc_thunk.ax +EOF + +testrun_compare ${abs_top_builddir}/src/nm --format=posix testfilesyms32 <<\EOF +FREF D 00000008 00000004 +FUN1 T 00000000 00000010 +FUN2 t 00000010 00000010 +FUN3 U +FUN4 W 00000020 00000010 +NUM0 u 00000008 00000004 +NUM1 D 00000000 00000004 +SYM1 C 00000004 00000004 +SYM2 B 00000000 00000004 +SYM3 U +SYM4 b 0000000c 00000004 +SYM6 D 00000000 00000004 +SYM7 d 00000004 00000004 +SYM8 V 00000004 00000004 +_GLOBAL_OFFSET_TABLE_ U +__x86.get_pc_thunk.ax T 00000000 00000000 +EOF + +testrun_compare ${abs_top_builddir}/src/nm --format=sysv testfilesyms32 <<\EOF + + +Symbols from testfilesyms32: + +Name Value Class Type Size Line Section + +FREF |00000008|GLOBAL|OBJECT |00000004| |.data.rel +FUN1 |00000000|GLOBAL|FUNC |00000010| |.text +FUN2 |00000010|LOCAL |FUNC |00000010| |.text +FUN3 | |GLOBAL|NOTYPE | | |UNDEF +FUN4 |00000020|WEAK |FUNC |00000010| |.text +NUM0 |00000008|UNIQUE|OBJECT |00000004| |.bss +NUM1 |00000000|GLOBAL|TLS |00000004| |.tdata +SYM1 |00000004|GLOBAL|OBJECT |00000004| |COMMON +SYM2 |00000000|GLOBAL|OBJECT |00000004| |.bss +SYM3 | |GLOBAL|NOTYPE | | |UNDEF +SYM4 |0000000c|LOCAL |OBJECT |00000004| |.bss +SYM6 |00000000|GLOBAL|OBJECT |00000004| |.data.rel +SYM7 |00000004|LOCAL |OBJECT |00000004| |.data.rel +SYM8 |00000004|WEAK |OBJECT |00000004| |.bss +_GLOBAL_OFFSET_TABLE_| |GLOBAL|NOTYPE | | |UNDEF +__x86.get_pc_thunk.ax|00000000|GLOBAL|FUNC |00000000| |.text.__x86.get_pc_thunk.ax +EOF + +testrun_compare ${abs_top_builddir}/src/nm --format=bsd testfilesyms64 <<\EOF +0000000000000010 D FREF +0000000000000000 T FUN1 +0000000000000007 t FUN2 + U FUN3 +000000000000000e W FUN4 +0000000000000010 u NUM0 +0000000000000000 D NUM1 +0000000000000008 C SYM1 +0000000000000000 B SYM2 + U SYM3 +0000000000000018 b SYM4 +0000000000000000 D SYM6 +0000000000000008 d SYM7 +0000000000000008 V SYM8 +EOF + +testrun_compare ${abs_top_builddir}/src/nm --format=posix testfilesyms64 <<\EOF +FREF D 0000000000000010 0000000000000008 +FUN1 T 0000000000000000 0000000000000007 +FUN2 t 0000000000000007 0000000000000007 +FUN3 U +FUN4 W 000000000000000e 0000000000000007 +NUM0 u 0000000000000010 0000000000000004 +NUM1 D 0000000000000000 0000000000000004 +SYM1 C 0000000000000008 0000000000000008 +SYM2 B 0000000000000000 0000000000000008 +SYM3 U +SYM4 b 0000000000000018 0000000000000008 +SYM6 D 0000000000000000 0000000000000008 +SYM7 d 0000000000000008 0000000000000008 +SYM8 V 0000000000000008 0000000000000008 +EOF + +testrun_compare ${abs_top_builddir}/src/nm --format=sysv testfilesyms64 <<\EOF + + +Symbols from testfilesyms64: + +Name Value Class Type Size Line Section + +FREF |0000000000000010|GLOBAL|OBJECT |0000000000000008| |.data.rel +FUN1 |0000000000000000|GLOBAL|FUNC |0000000000000007| |.text +FUN2 |0000000000000007|LOCAL |FUNC |0000000000000007| |.text +FUN3 | |GLOBAL|NOTYPE | | |UNDEF +FUN4 |000000000000000e|WEAK |FUNC |0000000000000007| |.text +NUM0 |0000000000000010|UNIQUE|OBJECT |0000000000000004| |.bss +NUM1 |0000000000000000|GLOBAL|TLS |0000000000000004| |.tdata +SYM1 |0000000000000008|GLOBAL|OBJECT |0000000000000008| |COMMON +SYM2 |0000000000000000|GLOBAL|OBJECT |0000000000000008| |.bss +SYM3 | |GLOBAL|NOTYPE | | |UNDEF +SYM4 |0000000000000018|LOCAL |OBJECT |0000000000000008| |.bss +SYM6 |0000000000000000|GLOBAL|OBJECT |0000000000000008| |.data.rel +SYM7 |0000000000000008|LOCAL |OBJECT |0000000000000008| |.data.rel +SYM8 |0000000000000008|WEAK |OBJECT |0000000000000008| |.bss +EOF + +exit 0 diff --git a/tests/run-pt_gnu_prop-tests.sh b/tests/run-pt_gnu_prop-tests.sh new file mode 100755 index 00000000..a9a8d912 --- /dev/null +++ b/tests/run-pt_gnu_prop-tests.sh @@ -0,0 +1,135 @@ +#! /bin/sh +# Copyright (C) 2020 Red Hat, Inc. +# This file is part of elfutils. +# +# This file 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 3 of the License, or +# (at your option) any later version. +# +# elfutils 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 <http://www.gnu.org/licenses/>. + +. $srcdir/test-subr.sh + +# On Fedora 31 with GCC 9.2.1 and binutils 2.32-31 +# echo "int main () { }" | \ +# gcc -o testfile_pt_gnu_prop \ +# -Os -fstack-clash-protection -fcf-protection=full -xc - && \ +# eu-strip --remove-comment -R .gnu.build.attributes testfile_pt_gnu_prop +# +# echo "int main () { }" | \ +# gcc -m32 -o testfile_pt_gnu_prop \ +# -Os -fstack-clash-protection -fcf-protection=full -xc - && \ +# eu-strip --remove-comment -R .gnu.build.attributes testfile_pt_gnu_prop32 + +testfiles testfile_pt_gnu_prop testfile_pt_gnu_prop32 + +testrun_compare ${abs_top_builddir}/src/readelf -ln testfile_pt_gnu_prop32 <<\EOF +Program Headers: + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align + PHDR 0x000034 0x08048034 0x08048034 0x000180 0x000180 R 0x4 + INTERP 0x0001b4 0x080481b4 0x080481b4 0x000013 0x000013 R 0x1 + [Requesting program interpreter: /lib/ld-linux.so.2] + LOAD 0x000000 0x08048000 0x08048000 0x000308 0x000308 R 0x1000 + LOAD 0x001000 0x08049000 0x08049000 0x000224 0x000224 R E 0x1000 + LOAD 0x002000 0x0804a000 0x0804a000 0x00015c 0x00015c R 0x1000 + LOAD 0x002f0c 0x0804bf0c 0x0804bf0c 0x000108 0x00010c RW 0x1000 + DYNAMIC 0x002f14 0x0804bf14 0x0804bf14 0x0000e8 0x0000e8 RW 0x4 + NOTE 0x0001c8 0x080481c8 0x080481c8 0x000060 0x000060 R 0x4 + GNU_PROPERTY 0x0001ec 0x080481ec 0x080481ec 0x00001c 0x00001c R 0x4 + GNU_EH_FRAME 0x00200c 0x0804a00c 0x0804a00c 0x00004c 0x00004c R 0x4 + GNU_STACK 0x000000 0x00000000 0x00000000 0x000000 0x000000 RW 0x10 + GNU_RELRO 0x002f0c 0x0804bf0c 0x0804bf0c 0x0000f4 0x0000f4 R 0x1 + + Section to Segment mapping: + Segment Sections... + 00 + 01 [RO: .interp] + 02 [RO: .interp .note.gnu.build-id .note.gnu.property .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt] + 03 [RO: .init .plt .plt.sec .text .fini] + 04 [RO: .rodata .eh_frame_hdr .eh_frame] + 05 [RELRO: .init_array .fini_array .dynamic .got] .got.plt .data .bss + 06 [RELRO: .dynamic] + 07 [RO: .note.gnu.build-id .note.gnu.property .note.ABI-tag] + 08 [RO: .note.gnu.property] + 09 [RO: .eh_frame_hdr] + 10 + 11 [RELRO: .init_array .fini_array .dynamic .got] + +Note section [ 2] '.note.gnu.build-id' of 36 bytes at offset 0x1c8: + Owner Data size Type + GNU 20 GNU_BUILD_ID + Build ID: 2fcce91f5c2532f78b00a9f5f565354d2f44bc19 + +Note section [ 3] '.note.gnu.property' of 28 bytes at offset 0x1ec: + Owner Data size Type + GNU 12 GNU_PROPERTY_TYPE_0 + X86 FEATURE_1_AND: 00000003 IBT SHSTK + +Note section [ 4] '.note.ABI-tag' of 32 bytes at offset 0x208: + Owner Data size Type + GNU 16 GNU_ABI_TAG + OS: Linux, ABI: 3.2.0 +EOF + +testrun ${abs_top_builddir}/src/elflint --gnu testfile_pt_gnu_prop32 + +testrun_compare ${abs_top_builddir}/src/readelf -ln testfile_pt_gnu_prop <<\EOF +Program Headers: + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align + PHDR 0x000040 0x0000000000400040 0x0000000000400040 0x0002d8 0x0002d8 R 0x8 + INTERP 0x000318 0x0000000000400318 0x0000000000400318 0x00001c 0x00001c R 0x1 + [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] + LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x000498 0x000498 R 0x1000 + LOAD 0x001000 0x0000000000401000 0x0000000000401000 0x0001a5 0x0001a5 R E 0x1000 + LOAD 0x002000 0x0000000000402000 0x0000000000402000 0x000100 0x000100 R 0x1000 + LOAD 0x002e50 0x0000000000403e50 0x0000000000403e50 0x0001cc 0x0001d0 RW 0x1000 + DYNAMIC 0x002e60 0x0000000000403e60 0x0000000000403e60 0x000190 0x000190 RW 0x8 + NOTE 0x000338 0x0000000000400338 0x0000000000400338 0x000020 0x000020 R 0x8 + NOTE 0x000358 0x0000000000400358 0x0000000000400358 0x000044 0x000044 R 0x4 + GNU_PROPERTY 0x000338 0x0000000000400338 0x0000000000400338 0x000020 0x000020 R 0x8 + GNU_EH_FRAME 0x002010 0x0000000000402010 0x0000000000402010 0x000034 0x000034 R 0x4 + GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10 + GNU_RELRO 0x002e50 0x0000000000403e50 0x0000000000403e50 0x0001b0 0x0001b0 R 0x1 + + Section to Segment mapping: + Segment Sections... + 00 + 01 [RO: .interp] + 02 [RO: .interp .note.gnu.property .note.gnu.build-id .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn] + 03 [RO: .init .text .fini] + 04 [RO: .rodata .eh_frame_hdr .eh_frame] + 05 [RELRO: .init_array .fini_array .dynamic .got] .got.plt .data .bss + 06 [RELRO: .dynamic] + 07 [RO: .note.gnu.property] + 08 [RO: .note.gnu.build-id .note.ABI-tag] + 09 [RO: .note.gnu.property] + 10 [RO: .eh_frame_hdr] + 11 + 12 [RELRO: .init_array .fini_array .dynamic .got] + +Note section [ 2] '.note.gnu.property' of 32 bytes at offset 0x338: + Owner Data size Type + GNU 16 GNU_PROPERTY_TYPE_0 + X86 FEATURE_1_AND: 00000003 IBT SHSTK + +Note section [ 3] '.note.gnu.build-id' of 36 bytes at offset 0x358: + Owner Data size Type + GNU 20 GNU_BUILD_ID + Build ID: 84fa4d40bad074bc82431575821902da624a5b22 + +Note section [ 4] '.note.ABI-tag' of 32 bytes at offset 0x37c: + Owner Data size Type + GNU 16 GNU_ABI_TAG + OS: Linux, ABI: 3.2.0 +EOF + +testrun ${abs_top_builddir}/src/elflint --gnu testfile_pt_gnu_prop + +exit 0 diff --git a/tests/run-varlocs-self.sh b/tests/run-varlocs-self.sh index 54b6a8d7..5454fc70 100755 --- a/tests/run-varlocs-self.sh +++ b/tests/run-varlocs-self.sh @@ -19,4 +19,6 @@ # Make sure varlocs doesn't crash, doesn't trigger self-check/asserts # or leaks running under valgrind. -testrun_on_self_quiet ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_exe ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_lib ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_obj ${abs_top_builddir}/tests/varlocs --exprlocs -e diff --git a/tests/test-subr.sh b/tests/test-subr.sh index e768c1e5..411e5f28 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -168,6 +168,19 @@ testrun_on_self_lib() if test $exit_status != 0; then exit $exit_status; fi } +testrun_on_self_obj() +{ + exit_status=0 + + for file in $self_test_files_obj; do + testrun $* $file \ + || { echo "*** failure in $* $file"; exit_status=1; } + done + + # Only exit if something failed + if test $exit_status != 0; then exit $exit_status; fi +} + # Compress the files first. Compress both debug sections and symtab. testrun_on_self_compressed() { diff --git a/tests/testfile-lto-gcc10.bz2 b/tests/testfile-lto-gcc10.bz2 Binary files differnew file mode 100755 index 00000000..e8ef621f --- /dev/null +++ b/tests/testfile-lto-gcc10.bz2 diff --git a/tests/testfile-lto-gcc8.bz2 b/tests/testfile-lto-gcc8.bz2 Binary files differnew file mode 100755 index 00000000..cf744d9e --- /dev/null +++ b/tests/testfile-lto-gcc8.bz2 diff --git a/tests/testfile-lto-gcc9.bz2 b/tests/testfile-lto-gcc9.bz2 Binary files differnew file mode 100755 index 00000000..df503618 --- /dev/null +++ b/tests/testfile-lto-gcc9.bz2 diff --git a/tests/testfile-phdrs.elf.bz2 b/tests/testfile-phdrs.elf.bz2 Binary files differnew file mode 100644 index 00000000..024ed79d --- /dev/null +++ b/tests/testfile-phdrs.elf.bz2 diff --git a/tests/testfile_pt_gnu_prop.bz2 b/tests/testfile_pt_gnu_prop.bz2 Binary files differnew file mode 100755 index 00000000..f030fb9c --- /dev/null +++ b/tests/testfile_pt_gnu_prop.bz2 diff --git a/tests/testfile_pt_gnu_prop32.bz2 b/tests/testfile_pt_gnu_prop32.bz2 Binary files differnew file mode 100755 index 00000000..6a7515a6 --- /dev/null +++ b/tests/testfile_pt_gnu_prop32.bz2 diff --git a/tests/testfilesyms32.bz2 b/tests/testfilesyms32.bz2 Binary files differnew file mode 100644 index 00000000..b3b7812c --- /dev/null +++ b/tests/testfilesyms32.bz2 diff --git a/tests/testfilesyms64.bz2 b/tests/testfilesyms64.bz2 Binary files differnew file mode 100644 index 00000000..cdec3817 --- /dev/null +++ b/tests/testfilesyms64.bz2 |