Skip to content

Commit a38c960

Browse files
committed
contrib: use c++ rather than c for binary tests
We don't actually use a c compiler as part of Core's build (only for secp). We should be testing against what we're actually using instead.
1 parent 3714692 commit a38c960

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

Makefile.am

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ clean-local: clean-docs
334334

335335
test-security-check:
336336
if TARGET_DARWIN
337-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO
338-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_MACHO
337+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO
338+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_MACHO
339339
endif
340340
if TARGET_WINDOWS
341-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE
342-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_PE
341+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE
342+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_PE
343343
endif
344344
if TARGET_LINUX
345-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF
346-
$(AM_V_at) CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_ELF
345+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF
346+
$(AM_V_at) CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' $(PYTHON) $(top_srcdir)/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_ELF
347347
endif

contrib/devtools/test-security-check.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def env_flags() -> list[str]:
3434
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
3535
# reference.
3636
flags: list[str] = []
37-
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
37+
for var in ['CXXFLAGS', 'CPPFLAGS', 'LDFLAGS']:
3838
flags += filter(None, os.environ.get(var, '').split(' '))
3939
return flags
4040

@@ -52,9 +52,9 @@ def get_arch(cc, source, executable):
5252

5353
class TestSecurityChecks(unittest.TestCase):
5454
def test_ELF(self):
55-
source = 'test1.c'
55+
source = 'test1.cpp'
5656
executable = 'test1'
57-
cc = determine_wellknown_cmd('CC', 'gcc')
57+
cc = determine_wellknown_cmd('CXX', 'g++')
5858
write_testcode(source)
5959
arch = get_arch(cc, source, executable)
6060

@@ -90,9 +90,9 @@ def test_ELF(self):
9090
clean_files(source, executable)
9191

9292
def test_PE(self):
93-
source = 'test1.c'
93+
source = 'test1.cpp'
9494
executable = 'test1.exe'
95-
cc = determine_wellknown_cmd('CC', 'x86_64-w64-mingw32-gcc')
95+
cc = determine_wellknown_cmd('CXX', 'x86_64-w64-mingw32-g++')
9696
write_testcode(source)
9797

9898
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--disable-nxcompat','-Wl,--disable-reloc-section','-Wl,--disable-dynamicbase','-Wl,--disable-high-entropy-va','-no-pie','-fno-PIE','-fno-stack-protector']),
@@ -113,9 +113,9 @@ def test_PE(self):
113113
clean_files(source, executable)
114114

115115
def test_MACHO(self):
116-
source = 'test1.c'
116+
source = 'test1.cpp'
117117
executable = 'test1'
118-
cc = determine_wellknown_cmd('CC', 'clang')
118+
cc = determine_wellknown_cmd('CXX', 'clang++')
119119
write_testcode(source)
120120
arch = get_arch(cc, source, executable)
121121

contrib/devtools/test-symbol-check.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def call_symbol_check(cc: list[str], source, executable, options):
1818
# See the definitions for ac_link in autoconf's lib/autoconf/c.m4 file for
1919
# reference.
2020
env_flags: list[str] = []
21-
for var in ['CFLAGS', 'CPPFLAGS', 'LDFLAGS']:
21+
for var in ['CXXFLAGS', 'CPPFLAGS', 'LDFLAGS']:
2222
env_flags += filter(None, os.environ.get(var, '').split(' '))
2323

2424
subprocess.run([*cc,source,'-o',executable] + env_flags + options, check=True)
@@ -29,13 +29,13 @@ def call_symbol_check(cc: list[str], source, executable, options):
2929

3030
class TestSymbolChecks(unittest.TestCase):
3131
def test_ELF(self):
32-
source = 'test1.c'
32+
source = 'test1.cpp'
3333
executable = 'test1'
34-
cc = determine_wellknown_cmd('CC', 'gcc')
34+
cc = determine_wellknown_cmd('CXX', 'g++')
3535

3636
# -lutil is part of the libc6 package so a safe bet that it's installed
3737
# it's also out of context enough that it's unlikely to ever become a real dependency
38-
source = 'test2.c'
38+
source = 'test2.cpp'
3939
executable = 'test2'
4040
with open(source, 'w', encoding="utf8") as f:
4141
f.write('''
@@ -53,7 +53,7 @@ def test_ELF(self):
5353
executable + ': failed LIBRARY_DEPENDENCIES'))
5454

5555
# finally, check a simple conforming binary
56-
source = 'test3.c'
56+
source = 'test3.cpp'
5757
executable = 'test3'
5858
with open(source, 'w', encoding="utf8") as f:
5959
f.write('''
@@ -70,9 +70,9 @@ def test_ELF(self):
7070
(0, ''))
7171

7272
def test_MACHO(self):
73-
source = 'test1.c'
73+
source = 'test1.cpp'
7474
executable = 'test1'
75-
cc = determine_wellknown_cmd('CC', 'clang')
75+
cc = determine_wellknown_cmd('CXX', 'clang++')
7676

7777
with open(source, 'w', encoding="utf8") as f:
7878
f.write('''
@@ -90,7 +90,7 @@ def test_MACHO(self):
9090
(1, 'libexpat.1.dylib is not in ALLOWED_LIBRARIES!\n' +
9191
f'{executable}: failed DYNAMIC_LIBRARIES MIN_OS SDK'))
9292

93-
source = 'test2.c'
93+
source = 'test2.cpp'
9494
executable = 'test2'
9595
with open(source, 'w', encoding="utf8") as f:
9696
f.write('''
@@ -106,7 +106,7 @@ def test_MACHO(self):
106106
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics', '-Wl,-platform_version','-Wl,macos', '-Wl,11.4', '-Wl,11.4']),
107107
(1, f'{executable}: failed MIN_OS SDK'))
108108

109-
source = 'test3.c'
109+
source = 'test3.cpp'
110110
executable = 'test3'
111111
with open(source, 'w', encoding="utf8") as f:
112112
f.write('''
@@ -120,9 +120,9 @@ def test_MACHO(self):
120120
(1, f'{executable}: failed SDK'))
121121

122122
def test_PE(self):
123-
source = 'test1.c'
123+
source = 'test1.cpp'
124124
executable = 'test1.exe'
125-
cc = determine_wellknown_cmd('CC', 'x86_64-w64-mingw32-gcc')
125+
cc = determine_wellknown_cmd('CXX', 'x86_64-w64-mingw32-g++')
126126

127127
with open(source, 'w', encoding="utf8") as f:
128128
f.write('''
@@ -139,7 +139,7 @@ def test_PE(self):
139139
(1, 'pdh.dll is not in ALLOWED_LIBRARIES!\n' +
140140
executable + ': failed DYNAMIC_LIBRARIES'))
141141

142-
source = 'test2.c'
142+
source = 'test2.cpp'
143143
executable = 'test2.exe'
144144

145145
with open(source, 'w', encoding="utf8") as f:
@@ -153,7 +153,7 @@ def test_PE(self):
153153
self.assertEqual(call_symbol_check(cc, source, executable, ['-Wl,--major-subsystem-version', '-Wl,9', '-Wl,--minor-subsystem-version', '-Wl,9']),
154154
(1, executable + ': failed SUBSYSTEM_VERSION'))
155155

156-
source = 'test3.c'
156+
source = 'test3.cpp'
157157
executable = 'test3.exe'
158158
with open(source, 'w', encoding="utf8") as f:
159159
f.write('''

0 commit comments

Comments
 (0)