public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed 9/13][odr, testsuite] Add test-cases odr-{struct,class,union}.sh
@ 2020-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2020-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub

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  <tdevries@suse.de>

	* 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-06 16:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [committed 9/13][odr, testsuite] Add test-cases odr-{struct,class,union}.sh Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).