Skip to content

Commit a65e772

Browse files
committed
Merge #21428: test: Cleanup in test-{security,symbol}-check.py
0fc0c00 test: Drop unused get_machine function (Hennadii Stepanov) 61a0f8f test: Cleanup test files in test-{security,symbol}-check.py (Hennadii Stepanov) Pull request description: 1) Test source and executable files are neither ignored by `.gitignore` nor removed by `make clean` and `make distclean`. 2) The `get_machine` function is no longer used since #21255. ACKs for top commit: fanquake: ACK 0fc0c00 Tree-SHA512: ef3fcf22d4a04b6e4f37f748bd4be57e09696d2a77982e26292843cb2a1297789c8325f5c4bdad37d8094fce7765c4cc9ab19809e07471487943361b2b1a252c
2 parents 6834e02 + 0fc0c00 commit a65e772

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

contrib/devtools/test-security-check.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'''
66
Test script for security-check.py
77
'''
8+
import os
89
import subprocess
910
import unittest
1011

@@ -19,6 +20,10 @@ def write_testcode(filename):
1920
}
2021
''')
2122

23+
def clean_files(source, executable):
24+
os.remove(source)
25+
os.remove(executable)
26+
2227
def call_security_check(cc, source, executable, options):
2328
subprocess.run([cc,source,'-o',executable] + options, check=True)
2429
p = subprocess.run(['./contrib/devtools/security-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
@@ -44,6 +49,8 @@ def test_ELF(self):
4449
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE', '-Wl,-z,separate-code']),
4550
(0, ''))
4651

52+
clean_files(source, executable)
53+
4754
def test_PE(self):
4855
source = 'test1.c'
4956
executable = 'test1.exe'
@@ -61,6 +68,8 @@ def test_PE(self):
6168
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--high-entropy-va','-pie','-fPIE']),
6269
(0, ''))
6370

71+
clean_files(source, executable)
72+
6473
def test_MACHO(self):
6574
source = 'test1.c'
6675
executable = 'test1'
@@ -80,6 +89,8 @@ def test_MACHO(self):
8089
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-Wl,-bind_at_load','-fstack-protector-all']),
8190
(0, ''))
8291

92+
clean_files(source, executable)
93+
8394
if __name__ == '__main__':
8495
unittest.main()
8596

contrib/devtools/test-symbol-check.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
'''
66
Test script for symbol-check.py
77
'''
8+
import os
89
import subprocess
910
import unittest
1011

1112
def call_symbol_check(cc, source, executable, options):
1213
subprocess.run([cc,source,'-o',executable] + options, check=True)
1314
p = subprocess.run(['./contrib/devtools/symbol-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
15+
os.remove(source)
16+
os.remove(executable)
1417
return (p.returncode, p.stdout.rstrip())
1518

16-
def get_machine(cc):
17-
p = subprocess.run([cc,'-dumpmachine'], stdout=subprocess.PIPE, universal_newlines=True)
18-
return p.stdout.rstrip()
19-
2019
class TestSymbolChecks(unittest.TestCase):
2120
def test_ELF(self):
2221
source = 'test1.c'

0 commit comments

Comments
 (0)