From e6fd79f3795d46dfb583e124be49fc063bc3d58b Mon Sep 17 00:00:00 2001 From: Chung-Lin Tang Date: Thu, 21 Oct 2021 21:41:21 +0800 Subject: elf: Testing infrastructure for ld.so DSO sorting (BZ #17645) This is the first of a 2-part patch set that fixes slow DSO sorting behavior in the dynamic loader, as reported in BZ #17645. In order to facilitate such a large modification to the dynamic loader, this first patch implements a testing framework for validating shared object sorting behavior, to enable comparison between old/new sorting algorithms, and any later enhancements. This testing infrastructure consists of a Python script scripts/dso-ordering-test.py' which takes in a description language, consisting of strings that describe a set of link dependency relations between DSOs, and generates testcase programs and Makefile fragments to automatically test the described situation, for example: a->b->c->d # four objects linked one after another a->[bc]->d;b->c # a depends on b and c, which both depend on d, # b depends on c (b,c linked to object a in fixed order) a->b->c;{+a;%a;-a} # a, b, c serially dependent, main program uses # dlopen/dlsym/dlclose on object a a->b->c;{}!->[abc] # a, b, c serially dependent; multiple tests generated # to test all permutations of a, b, c ordering linked # to main program (Above is just a short description of what the script can do, more documentation is in the script comments.) Two files containing several new tests, elf/dso-sort-tests-[12].def are added, including test scenarios for BZ #15311 and Redhat issue #1162810 [1]. Due to the nature of dynamic loader tests, where the sorting behavior and test output occurs before/after main(), generating testcases to use support/test-driver.c does not suffice to control meaningful timeout for ld.so. Therefore a new utility program 'support/test-run-command', based on test-driver.c/support_test_main.c has been added. This does the same testcase control, but for a program specified through a command-line rather than at the source code level. This utility is used to run the dynamic loader testcases generated by dso-ordering-test.py. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1162810 Signed-off-by: Chung-Lin Tang Reviewed-by: Adhemerval Zanella --- elf/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'elf/Makefile') diff --git a/elf/Makefile b/elf/Makefile index bf45d8ee24..bdcf4cb885 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -477,6 +477,21 @@ tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \ $(objpfx)tst-unused-dep-cmp.out endif +# DSO sorting tests: +# The dso-ordering-test.py script generates testcase source files in $(objpfx), +# creating a $(objpfx)-dir for each testcase, and creates a +# Makefile fragment to be included. +define include_dsosort_tests +$(objpfx)$(1).generated-makefile: $(1) + $(PYTHON) $(..)scripts/dso-ordering-test.py \ + --description-file $$< --objpfx $(objpfx) --output-makefile $$@ +include $(objpfx)$(1).generated-makefile +endef + +# Generate from each testcase description file +$(eval $(call include_dsosort_tests,dso-sort-tests-1.def)) +$(eval $(call include_dsosort_tests,dso-sort-tests-2.def)) + check-abi: $(objpfx)check-abi-ld.out tests-special += $(objpfx)check-abi-ld.out update-abi: update-abi-ld -- cgit v1.2.3