mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#21428: Cleanup in test-{security,symbol}-check.py
This commit is contained in:
parent
1be3afd82c
commit
d4a8d49e56
@ -5,6 +5,7 @@
|
|||||||
'''
|
'''
|
||||||
Test script for security-check.py
|
Test script for security-check.py
|
||||||
'''
|
'''
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -19,6 +20,10 @@ def write_testcode(filename):
|
|||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
def clean_files(source, executable):
|
||||||
|
os.remove(source)
|
||||||
|
os.remove(executable)
|
||||||
|
|
||||||
def call_security_check(cc, source, executable, options):
|
def call_security_check(cc, source, executable, options):
|
||||||
subprocess.run([cc,source,'-o',executable] + options, check=True)
|
subprocess.run([cc,source,'-o',executable] + options, check=True)
|
||||||
p = subprocess.run(['./contrib/devtools/security-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
|
p = subprocess.run(['./contrib/devtools/security-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
|
||||||
@ -44,6 +49,8 @@ class TestSecurityChecks(unittest.TestCase):
|
|||||||
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE', '-Wl,-z,separate-code']),
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE', '-Wl,-z,separate-code']),
|
||||||
(0, ''))
|
(0, ''))
|
||||||
|
|
||||||
|
clean_files(source, executable)
|
||||||
|
|
||||||
def test_PE(self):
|
def test_PE(self):
|
||||||
source = 'test1.c'
|
source = 'test1.c'
|
||||||
executable = 'test1.exe'
|
executable = 'test1.exe'
|
||||||
@ -61,6 +68,8 @@ class TestSecurityChecks(unittest.TestCase):
|
|||||||
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--high-entropy-va','-pie','-fPIE']),
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--high-entropy-va','-pie','-fPIE']),
|
||||||
(0, ''))
|
(0, ''))
|
||||||
|
|
||||||
|
clean_files(source, executable)
|
||||||
|
|
||||||
def test_MACHO(self):
|
def test_MACHO(self):
|
||||||
source = 'test1.c'
|
source = 'test1.c'
|
||||||
executable = 'test1'
|
executable = 'test1'
|
||||||
@ -80,6 +89,8 @@ class TestSecurityChecks(unittest.TestCase):
|
|||||||
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-Wl,-bind_at_load','-fstack-protector-all']),
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-Wl,-bind_at_load','-fstack-protector-all']),
|
||||||
(0, ''))
|
(0, ''))
|
||||||
|
|
||||||
|
clean_files(source, executable)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
@ -5,18 +5,17 @@
|
|||||||
'''
|
'''
|
||||||
Test script for symbol-check.py
|
Test script for symbol-check.py
|
||||||
'''
|
'''
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
def call_symbol_check(cc, source, executable, options):
|
def call_symbol_check(cc, source, executable, options):
|
||||||
subprocess.run([cc,source,'-o',executable] + options, check=True)
|
subprocess.run([cc,source,'-o',executable] + options, check=True)
|
||||||
p = subprocess.run(['./contrib/devtools/symbol-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
|
p = subprocess.run(['./contrib/devtools/symbol-check.py',executable], stdout=subprocess.PIPE, universal_newlines=True)
|
||||||
|
os.remove(source)
|
||||||
|
os.remove(executable)
|
||||||
return (p.returncode, p.stdout.rstrip())
|
return (p.returncode, p.stdout.rstrip())
|
||||||
|
|
||||||
def get_machine(cc):
|
|
||||||
p = subprocess.run([cc,'-dumpmachine'], stdout=subprocess.PIPE, universal_newlines=True)
|
|
||||||
return p.stdout.rstrip()
|
|
||||||
|
|
||||||
class TestSymbolChecks(unittest.TestCase):
|
class TestSymbolChecks(unittest.TestCase):
|
||||||
def test_ELF(self):
|
def test_ELF(self):
|
||||||
source = 'test1.c'
|
source = 'test1.c'
|
||||||
|
Loading…
Reference in New Issue
Block a user