[3/3] Add abidiff --offset-changes-are-harmless tests.

Message ID 20200504162439.74028-4-gprocida@google.com
State Rejected
Headers
Series Add an option to give finer-grained control of offset reporting. |

Commit Message

Giuliano Procida May 4, 2020, 4:24 p.m. UTC
  The new --offset-changes-are-harmless option changes the default
interpretation of what constitutes a harmless change and impacts the
--harmless and --no-harmful options.

This commit adds tests covering the various possibilities.

The object files have the following changes.

- S::z changes from void* to int* (harmless)
- S::a changes size (harmful)
- S::b changes offset (normally harmful, harmless with new flag)

	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-offset-harm-report0.txt:
	New test case.
	* tests/data/test-abidiff-exit/test-offset-harm-report1.txt:
	Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-report2.txt:
	Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-report3.txt:
	Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-v0.c: Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-v1.c: Ditto.
	* tests/data/test-abidiff-exit/test-offset-harm-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run new test cases.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 tests/data/Makefile.am                        |   8 ++++
 .../test-offset-harm-report0.txt              |  15 ++++++++
 .../test-offset-harm-report1.txt              |  20 ++++++++++
 .../test-offset-harm-report2.txt              |   3 ++
 .../test-offset-harm-report3.txt              |  14 +++++++
 .../test-abidiff-exit/test-offset-harm-v0.c   |   7 ++++
 .../test-abidiff-exit/test-offset-harm-v0.o   | Bin 0 -> 2872 bytes
 .../test-abidiff-exit/test-offset-harm-v1.c   |   7 ++++
 .../test-abidiff-exit/test-offset-harm-v1.o   | Bin 0 -> 2864 bytes
 tests/test-abidiff-exit.cc                    |  36 ++++++++++++++++++
 10 files changed, 110 insertions(+)
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-report0.txt
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-report1.txt
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-report2.txt
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-report3.txt
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-v0.c
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-v0.o
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-v1.c
 create mode 100644 tests/data/test-abidiff-exit/test-offset-harm-v1.o
  

Comments

Dodji Seketeli May 13, 2020, 11:48 a.m. UTC | #1
Giuliano Procida <gprocida@google.com> a écrit:

> The new --offset-changes-are-harmless option changes the default
> interpretation of what constitutes a harmless change and impacts the
> --harmless and --no-harmful options.
>
> This commit adds tests covering the various possibilities.
>
> The object files have the following changes.
>
> - S::z changes from void* to int* (harmless)
> - S::a changes size (harmful)
> - S::b changes offset (normally harmful, harmless with new flag)

This patch depends on the resolution of the concern I have raised at
https://sourceware.org/pipermail/libabigail/2020q2/002229.html.

Cheers,
  

Patch

diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index a1b9bf64..6b116c55 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -151,6 +151,14 @@  test-abidiff-exit/test-decl-struct-v0.o \
 test-abidiff-exit/test-decl-struct-v1.c \
 test-abidiff-exit/test-decl-struct-v1.o \
 test-abidiff-exit/test-decl-struct-report.txt \
+test-abidiff-exit/test-offset-harm-v0.c \
+test-abidiff-exit/test-offset-harm-v0.o \
+test-abidiff-exit/test-offset-harm-v1.c \
+test-abidiff-exit/test-offset-harm-v1.o \
+test-abidiff-exit/test-offset-harm-report0.txt \
+test-abidiff-exit/test-offset-harm-report1.txt \
+test-abidiff-exit/test-offset-harm-report2.txt \
+test-abidiff-exit/test-offset-harm-report3.txt \
 \
 test-diff-dwarf/test0-v0.cc		\
 test-diff-dwarf/test0-v0.o			\
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-report0.txt b/tests/data/test-abidiff-exit/test-offset-harm-report0.txt
new file mode 100644
index 00000000..6ac7022d
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-report0.txt
@@ -0,0 +1,15 @@ 
+Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+1 function with some indirect sub-type change:
+
+  [C] 'function void reg(S*)' at test-offset-harm-v1.c:7:1 has some indirect sub-type changes:
+    parameter 1 of type 'S*' has sub-type changes:
+      in pointed to type 'struct S' at test-offset-harm-v1.c:1:1:
+        type size changed from 256 to 384 (in bits)
+        1 data member changes (2 filtered):
+          type of 'int S::a[4]' changed:
+            type name changed from 'int[4]' to 'int[8]'
+            array type size changed from 128 to 256
+            array type subrange 1 changed length from 4 to 8
+
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-report1.txt b/tests/data/test-abidiff-exit/test-offset-harm-report1.txt
new file mode 100644
index 00000000..85a64b07
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-report1.txt
@@ -0,0 +1,20 @@ 
+Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+1 function with some indirect sub-type change:
+
+  [C] 'function void reg(S*)' at test-offset-harm-v1.c:7:1 has some indirect sub-type changes:
+    parameter 1 of type 'S*' has sub-type changes:
+      in pointed to type 'struct S' at test-offset-harm-v1.c:1:1:
+        type size changed from 256 to 384 (in bits)
+        3 data member changes:
+          type of 'void* S::z' changed:
+            in pointed to type 'void':
+              type name changed from 'void' to 'int'
+              type size changed from 0 to 32 (in bits)
+          type of 'int S::a[4]' changed:
+            type name changed from 'int[4]' to 'int[8]'
+            array type size changed from 128 to 256
+            array type subrange 1 changed length from 4 to 8
+          'int S::b' offset changed from 192 to 320 (in bits) (by +128 bits)
+
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-report2.txt b/tests/data/test-abidiff-exit/test-offset-harm-report2.txt
new file mode 100644
index 00000000..9666a8fd
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-report2.txt
@@ -0,0 +1,3 @@ 
+Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-report3.txt b/tests/data/test-abidiff-exit/test-offset-harm-report3.txt
new file mode 100644
index 00000000..c4eb748f
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-report3.txt
@@ -0,0 +1,14 @@ 
+Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+1 function with some indirect sub-type change:
+
+  [C] 'function void reg(S*)' at test-offset-harm-v1.c:7:1 has some indirect sub-type changes:
+    parameter 1 of type 'S*' has sub-type changes:
+      in pointed to type 'struct S' at test-offset-harm-v1.c:1:1:
+        2 data member changes (1 filtered):
+          type of 'void* S::z' changed:
+            in pointed to type 'void':
+              type name changed from 'void' to 'int'
+          'int S::b' offset changed from 192 to 320 (in bits) (by +128 bits)
+
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-v0.c b/tests/data/test-abidiff-exit/test-offset-harm-v0.c
new file mode 100644
index 00000000..c05e9742
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-v0.c
@@ -0,0 +1,7 @@ 
+struct S {
+  void* z;
+  int a[4];
+  int b;
+};
+
+void reg(struct S* s) { (void)s; }
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-v0.o b/tests/data/test-abidiff-exit/test-offset-harm-v0.o
new file mode 100644
index 0000000000000000000000000000000000000000..b6222d63e7f27c8ea10d8173bbd98419650e657c
GIT binary patch
literal 2872
zcmbtV&ubiY6o22H-Rx|p*(TXa6XIbCN-a1uNtBwlq^?HW1d9}<7g56O?ssPgXJ^99
zY~5BxC?fP0Q4rCCAP61=j~<0yJ$U!*AK<OvLEoGCemCF!c5>0j?!5Ot@8|dTC$HbS
zQDY1wF}MyVnnVGn3ny~75WCQURk*YN@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tNK3@heF0v|8#5V
z{SOe+b0P$f1bB-Sg>>ITv{lvrPSlt4MD^)h>-CQiqnxr&6bm{l4&!eU5M0)m{6oa6
z;{Ooww7*o6agu+EMk%X)_=;DO?)$ZfpSwE{Ge!K4mPL+V!e63LHGjWU%pbi9GG5Lr
w^`qCO++9)swrH5{Z+dO?cv_RHp&nCHNOV7_q>rESR>l7=`u|=HMp=*l7e>q3{{R30

literal 0
HcmV?d00001

diff --git a/tests/data/test-abidiff-exit/test-offset-harm-v1.c b/tests/data/test-abidiff-exit/test-offset-harm-v1.c
new file mode 100644
index 00000000..025e8462
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-offset-harm-v1.c
@@ -0,0 +1,7 @@ 
+struct S {
+  int* z;
+  int a[8];
+  int b;
+};
+
+void reg(struct S* s) { (void)s; }
diff --git a/tests/data/test-abidiff-exit/test-offset-harm-v1.o b/tests/data/test-abidiff-exit/test-offset-harm-v1.o
new file mode 100644
index 0000000000000000000000000000000000000000..0b2ee10ccb2c4512f1671b5455057fb33de2b914
GIT binary patch
literal 2864
zcmbtVUuzsy6hC)oH#^BBYm%)rAwEn&X$zg1Bud@3q^?HW1d9}<FG7iTckj*)?#_gn
z**1-eAX4mG1wjShd=Wv=Z&2{X2S0#czz^V?V4<EfbMNl#&E!Q7yZ4;?JAdz)`{&cQ
zZr!Lb28tM5hv`hA0Ecr^xt)n^Xu>Mo*?aWo-lI?ceth@WpAfEQDl?0)n8}5~D#(@h
zV3RTPeT0l-V3kY)g99__K7yvv0amSlfZ_$Hn#60>S`el%NAi9A*RugkvyKy(kA)Ac
zJ}FZrW8eLV+JyvlXGp4iIly=hxv&-XQln`Zjg7_%TdgmjMQxKAre$5Vu31+s*2LnL
zz%cXaezS!^tIvUD?W3mlA_~_n!vvUPY`;m?^>eV_^w7$b$_5tZve(vCjPvW1slE2~
z8|!4hP%A{QtYJ-;s6;9bFm8d=atcr;?%`-;UX1<ISOSKG5dImYB1xU7-%mv940t?p
z?rpi<%&T@5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 b/tests/test-abidiff-exit.cc
@@ -203,6 +203,42 @@  InOutSpec in_out_specs[] =
     "data/test-abidiff-exit/test-decl-struct-report.txt",
     "output/test-abidiff-exit/test-decl-struct-report.txt"
   },
+  {
+    "data/test-abidiff-exit/test-offset-harm-v0.o",
+    "data/test-abidiff-exit/test-offset-harm-v1.o",
+    "",
+    "--offset-changes-are-harmless",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/test-offset-harm-report0.txt",
+    "output/test-abidiff-exit/test-offset-harm-report0.txt"
+  },
+  {
+    "data/test-abidiff-exit/test-offset-harm-v0.o",
+    "data/test-abidiff-exit/test-offset-harm-v1.o",
+    "",
+    "--offset-changes-are-harmless --harmless",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/test-offset-harm-report1.txt",
+    "output/test-abidiff-exit/test-offset-harm-report1.txt"
+  },
+  {
+    "data/test-abidiff-exit/test-offset-harm-v0.o",
+    "data/test-abidiff-exit/test-offset-harm-v1.o",
+    "",
+    "--offset-changes-are-harmless --no-harmful",
+    abigail::tools_utils::ABIDIFF_OK,
+    "data/test-abidiff-exit/test-offset-harm-report2.txt",
+    "output/test-abidiff-exit/test-offset-harm-report2.txt"
+  },
+  {
+    "data/test-abidiff-exit/test-offset-harm-v0.o",
+    "data/test-abidiff-exit/test-offset-harm-v1.o",
+    "",
+    "--offset-changes-are-harmless --harmless --no-harmful",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/test-offset-harm-report3.txt",
+    "output/test-abidiff-exit/test-offset-harm-report3.txt"
+  },
   {0, 0, 0 ,0,  abigail::tools_utils::ABIDIFF_OK, 0, 0}
 };