summarylogtreecommitdiffstats
path: root/0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch
blob: e19ae26b769a3c6f777d52fa83dbb9229bd976d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
From 51096b8055c73c9cdbadfa4ad75955eab8ef91a5 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 2 Aug 2018 05:00:45 -0700
Subject: [PATCH] Add a testcase for PR binutils/23460

Add a testcase to limit open files to 16 for AR with plugin.  Before

commit 103da91bc083f94769e3758175a96d06cef1f8fe
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Aug 1 14:34:41 2018 +0100

    Close resource leaks in the BFD library's plugin handler.

it failed with:

../binutils/ar: tmpdir/pr23460f.o: plugin needed to handle lto object

	PR binutils/23460
	* testsuite/ld-plugin/lto.exp: Run the PR binutils/23460 test.
	* testsuite/ld-plugin/pr23460a.c: New file.
	* testsuite/ld-plugin/pr23460b.c: Likewise.
	* testsuite/ld-plugin/pr23460c.c: Likewise.
	* testsuite/ld-plugin/pr23460d.c: Likewise.
	* testsuite/ld-plugin/pr23460e.c: Likewise.
	* testsuite/ld-plugin/pr23460f.c: Likewise.
---
 ld/testsuite/ld-plugin/lto.exp    | 26 ++++++++++++++++++++++++++
 ld/testsuite/ld-plugin/pr23460a.c |  4 ++++
 ld/testsuite/ld-plugin/pr23460b.c |  4 ++++
 ld/testsuite/ld-plugin/pr23460c.c |  4 ++++
 ld/testsuite/ld-plugin/pr23460d.c |  4 ++++
 ld/testsuite/ld-plugin/pr23460e.c |  4 ++++
 ld/testsuite/ld-plugin/pr23460f.c |  4 ++++
 7 files changed, 50 insertions(+)
 create mode 100644 ld/testsuite/ld-plugin/pr23460a.c
 create mode 100644 ld/testsuite/ld-plugin/pr23460b.c
 create mode 100644 ld/testsuite/ld-plugin/pr23460c.c
 create mode 100644 ld/testsuite/ld-plugin/pr23460d.c
 create mode 100644 ld/testsuite/ld-plugin/pr23460e.c
 create mode 100644 ld/testsuite/ld-plugin/pr23460f.c

diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 7c50b0f102..5d354bfa9e 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -556,6 +556,32 @@ if { [at_least_gcc_version 4 7] } {
     } {
         fail $testname
     }
+
+    run_cc_link_tests [list \
+	[list \
+	    "Build pr23460*.o" \
+	    "$plug_opt" \
+	    "-O2 -fPIC -flto $lto_no_fat" \
+	    {pr23460a.c pr23460b.c pr23460c.c \
+	     pr23460d.c pr23460e.c pr23460f.c} \
+	] \
+    ]
+    set exec_output [run_host_cmd "sh" \
+				  "-c \"ulimit -n 16; \
+				   $ar -rc $plug_opt \
+				   tmpdir/libpr23460.a \
+				   tmpdir/pr23460a.o \
+				   tmpdir/pr23460b.o \
+				   tmpdir/pr23460c.o \
+				   tmpdir/pr23460d.o \
+				   tmpdir/pr23460e.o \
+				   tmpdir/pr23460f.o\""]
+    set exec_output [prune_warnings $exec_output]
+    if [string match "" $exec_output] then {
+	pass "PR binutils/23460"
+    } else {
+	fail "PR binutils/23460"
+    }
 }
 
 # Run "ld -r" to generate inputs for complex LTO tests.
diff --git a/ld/testsuite/ld-plugin/pr23460a.c b/ld/testsuite/ld-plugin/pr23460a.c
new file mode 100644
index 0000000000..4a8cd140a2
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460a.c
@@ -0,0 +1,4 @@
+void
+x1 (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23460b.c b/ld/testsuite/ld-plugin/pr23460b.c
new file mode 100644
index 0000000000..6c178fbc76
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460b.c
@@ -0,0 +1,4 @@
+void
+x2 (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23460c.c b/ld/testsuite/ld-plugin/pr23460c.c
new file mode 100644
index 0000000000..99b23c5dcd
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460c.c
@@ -0,0 +1,4 @@
+void
+x3 (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23460d.c b/ld/testsuite/ld-plugin/pr23460d.c
new file mode 100644
index 0000000000..432d39b39c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460d.c
@@ -0,0 +1,4 @@
+void
+x4 (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23460e.c b/ld/testsuite/ld-plugin/pr23460e.c
new file mode 100644
index 0000000000..2809011ee7
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460e.c
@@ -0,0 +1,4 @@
+void
+x5 (void)
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23460f.c b/ld/testsuite/ld-plugin/pr23460f.c
new file mode 100644
index 0000000000..e500bf5ae6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23460f.c
@@ -0,0 +1,4 @@
+void
+x6 (void)
+{
+}
-- 
2.18.0