From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38105 invoked by alias); 6 Jan 2020 16:09:58 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 38096 invoked by uid 89); 6 Jan 2020 16:09:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=Couldn't, Couldnt X-Spam-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx2.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Wed, 01 Jan 2020 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed 9/13][odr, testsuite] Add test-cases odr-{struct,class,union}.sh Message-ID: <20200106160950.GA20040@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2020-q1/txt/msg00009.txt Hi, Add basic --odr test-cases, for struct, class and union, both inside and outside a namespace. Committed to trunk. Thanks, - Tom [odr, testsuite] Add test-cases odr-{struct,class,union}.sh 2020-01-06 Tom de Vries * Makefile (odr-struct, odr-union, odr-class, odr-struct-ns) (odr-union-ns, odr-class-ns): Add new target. (TEST_EXECS): Add new targets. * testsuite/dwz.tests/odr-2.cc: New test. * testsuite/dwz.tests/odr-class-ns.sh: New test. * testsuite/dwz.tests/odr-class.sh: New test. * testsuite/dwz.tests/odr-struct-ns.sh: New test. * testsuite/dwz.tests/odr-struct.sh: New test. * testsuite/dwz.tests/odr-union-ns.sh: New test. * testsuite/dwz.tests/odr-union.sh: New test. * testsuite/dwz.tests/odr.cc: New test. * testsuite/dwz.tests/odr.h: New test. --- Makefile | 27 +++++++++++++++++++++- testsuite/dwz.tests/odr-2.cc | 18 +++++++++++++++ testsuite/dwz.tests/odr-class-ns.sh | 29 +++++++++++++++++++++++ testsuite/dwz.tests/odr-class.sh | 29 +++++++++++++++++++++++ testsuite/dwz.tests/odr-struct-ns.sh | 45 ++++++++++++++++++++++++++++++++++++ testsuite/dwz.tests/odr-struct.sh | 45 ++++++++++++++++++++++++++++++++++++ testsuite/dwz.tests/odr-union-ns.sh | 29 +++++++++++++++++++++++ testsuite/dwz.tests/odr-union.sh | 29 +++++++++++++++++++++++ testsuite/dwz.tests/odr.cc | 24 +++++++++++++++++++ testsuite/dwz.tests/odr.h | 11 +++++++++ 10 files changed, 285 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3cd5d82..1d5c9ca 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,8 @@ TEST_EXECS_x86_64 = py-section-script dw2-skip-prologue \ implptr-64bit-d2o4a8r8t0 varval TEST_EXECS = hello dwz-for-test min two-typedef start hello-gold-gdb-index \ start-gold hello-gnu-pubnames $(TEST_EXECS_DWARF_ASM) \ - $(TEST_EXECS_$(UNAME)) + $(TEST_EXECS_$(UNAME)) odr-struct odr-class odr-union odr-struct-ns \ + odr-class-ns odr-union-ns UNAME:=$(shell uname -p) @@ -97,6 +98,30 @@ $(TEMP_ASM_FILES): %-dw.S: $(TEST_SRC)/../lib/%.exp $(TEST_EXECS_DWARF_ASM): %: %-dw.S $(CC) $(TEST_SRC)/main.c $< -o $@ +odr-struct: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=struct + +odr-class: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=class + +odr-union: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=union + +odr-struct-ns: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=struct -DNAMESPACE=1 + +odr-class-ns: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=class -DNAMESPACE=1 + +odr-union-ns: + $(CXX) $(TEST_SRC)/odr.cc $(TEST_SRC)/odr-2.cc -I$(TEST_SRC) -o $@ -g \ + -DKIND=union -DNAMESPACE=1 + # On some systems we need to set and export DEJAGNU to suppress # WARNING: Couldn't find the global config file. DEJAGNU ?= /dev/null diff --git a/testsuite/dwz.tests/odr-2.cc b/testsuite/dwz.tests/odr-2.cc new file mode 100644 index 0000000..fd033da --- /dev/null +++ b/testsuite/dwz.tests/odr-2.cc @@ -0,0 +1,18 @@ +#if NAMESPACE +namespace ns { +#endif + KIND bbb + { + int member_four; + }; + KIND ccc; +#if NAMESPACE +} +#endif +#include "odr.h" + +#if NAMESPACE +KIND ns::aaa var2; +#else +KIND aaa var2; +#endif diff --git a/testsuite/dwz.tests/odr-class-ns.sh b/testsuite/dwz.tests/odr-class-ns.sh new file mode 100644 index 0000000..4b890a3 --- /dev/null +++ b/testsuite/dwz.tests/odr-class-ns.sh @@ -0,0 +1,29 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-class-ns 1 + +verify-dwarf.sh 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 2 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 2 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 2 ] + +$execs/dwz-for-test --odr 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 1 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 1 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 1 ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr-class.sh b/testsuite/dwz.tests/odr-class.sh new file mode 100644 index 0000000..872c3ca --- /dev/null +++ b/testsuite/dwz.tests/odr-class.sh @@ -0,0 +1,29 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-class 1 + +verify-dwarf.sh 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 2 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 2 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 2 ] + +$execs/dwz-for-test --odr 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 1 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 1 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 1 ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr-struct-ns.sh b/testsuite/dwz.tests/odr-struct-ns.sh new file mode 100644 index 0000000..4fd00af --- /dev/null +++ b/testsuite/dwz.tests/odr-struct-ns.sh @@ -0,0 +1,45 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-struct-ns 1 + +for name in aaa bbb ccc; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 2 ] +done + +for name in member_one member_two member_three member_four; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + case $name in + member_one|member_two) + [ $cnt -eq 2 ] + ;; + member_three|member_four) + [ $cnt -eq 1 ] + ;; + esac +done + +decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true) + +$execs/dwz-for-test --odr 1 + +verify-dwarf.sh 1 + +for name in aaa bbb ccc; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 1 ] +done + +for name in member_one member_two member_three member_four; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 1 ] +done + +# We expect two decls to be removed, for bbb and ccc. +expected_decl_cnt=$(($decl_cnt - 2)) +decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true) +[ $expected_decl_cnt -eq $decl_cnt ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr-struct.sh b/testsuite/dwz.tests/odr-struct.sh new file mode 100644 index 0000000..d0fddf9 --- /dev/null +++ b/testsuite/dwz.tests/odr-struct.sh @@ -0,0 +1,45 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-struct 1 + +for name in aaa bbb ccc; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 2 ] +done + +for name in member_one member_two member_three member_four; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + case $name in + member_one|member_two) + [ $cnt -eq 2 ] + ;; + member_three|member_four) + [ $cnt -eq 1 ] + ;; + esac +done + +decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true) + +$execs/dwz-for-test --odr 1 + +verify-dwarf.sh 1 + +for name in aaa bbb ccc; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 1 ] +done + +for name in member_one member_two member_three member_four; do + cnt=$(readelf -wi 1 | grep -c "DW_AT_name.*:.*$name" || true) + [ $cnt -eq 1 ] +done + +# We expect two decls to be removed, for bbb and ccc. +expected_decl_cnt=$(($decl_cnt - 2)) +decl_cnt=$(readelf -wi 1 | grep -c "DW_AT_declaration" || true) +[ $expected_decl_cnt -eq $decl_cnt ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr-union-ns.sh b/testsuite/dwz.tests/odr-union-ns.sh new file mode 100644 index 0000000..7d86dba --- /dev/null +++ b/testsuite/dwz.tests/odr-union-ns.sh @@ -0,0 +1,29 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-union-ns 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 2 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 2 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 2 ] + +$execs/dwz-for-test --odr 1 + +verify-dwarf.sh 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 1 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 1 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 1 ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr-union.sh b/testsuite/dwz.tests/odr-union.sh new file mode 100644 index 0000000..a32a46c --- /dev/null +++ b/testsuite/dwz.tests/odr-union.sh @@ -0,0 +1,29 @@ +if ! $execs/dwz-for-test --odr -v 2>/dev/null; then + exit 77 +fi + +cp $execs/odr-union 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 2 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 2 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 2 ] + +$execs/dwz-for-test --odr 1 + +verify-dwarf.sh 1 + +aaa=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*aaa') +[ $aaa -eq 1 ] + +bbb=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*bbb') +[ $bbb -eq 1 ] + +ccc=$(readelf -wi 1 | grep -c 'DW_AT_name.*:.*ccc') +[ $ccc -eq 1 ] + +rm -f 1 diff --git a/testsuite/dwz.tests/odr.cc b/testsuite/dwz.tests/odr.cc new file mode 100644 index 0000000..3f9255b --- /dev/null +++ b/testsuite/dwz.tests/odr.cc @@ -0,0 +1,24 @@ +#if NAMESPACE +namespace ns { +#endif + KIND bbb; + KIND ccc { + int member_three; + }; +#if NAMESPACE +} +#endif + +#include "odr.h" + +#if NAMESPACE +KIND ns::aaa var1; +#else +KIND aaa var1; +#endif + +int +main (void) +{ + return 0; +} diff --git a/testsuite/dwz.tests/odr.h b/testsuite/dwz.tests/odr.h new file mode 100644 index 0000000..ae0e07d --- /dev/null +++ b/testsuite/dwz.tests/odr.h @@ -0,0 +1,11 @@ +#if NAMESPACE +namespace ns { +#endif + KIND aaa + { + KIND bbb *member_one; + KIND ccc *member_two; + }; +#if NAMESPACE +} +#endif