Skip to content

Commit

Permalink
Auto merge of #3320 - str4d:macos-tests, r=bitcartel
Browse files Browse the repository at this point in the history
Fix MacOS tests

Includes code cherry-picked from upstream PR bitcoin/bitcoin#8270.
  • Loading branch information
zkbot committed Jun 19, 2018
2 parents 3e38e24 + 341a22a commit 4e3ff06
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
7 changes: 6 additions & 1 deletion contrib/devtools/security-check.py
@@ -1,11 +1,12 @@
#!/usr/bin/python2
#!/usr/bin/env python
'''
Perform basic ELF security checks on a series of executables.
Exit status will be 0 if successful, and the program will be silent.
Otherwise the exit status will be 1 and it will log which executables failed which checks.
Needs `readelf` (for ELF) and `objdump` (for PE).
'''
from __future__ import division,print_function,unicode_literals
import struct
import subprocess
import sys
import os
Expand Down Expand Up @@ -171,6 +172,8 @@ def check_PE_NX(executable):
('DYNAMIC_BASE', check_PE_DYNAMIC_BASE),
('HIGH_ENTROPY_VA', check_PE_HIGH_ENTROPY_VA),
('NX', check_PE_NX)
],
'MachO64': [
]
}

Expand All @@ -181,6 +184,8 @@ def identify_executable(executable):
return 'PE'
elif magic.startswith(b'\x7fELF'):
return 'ELF'
elif struct.unpack('I', magic)[0] == 0xFEEDFACF:
return 'MachO64'
return None

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion contrib/devtools/symbol-check.py
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/env python
# Copyright (c) 2014 Wladimir J. van der Laan
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down
2 changes: 1 addition & 1 deletion contrib/devtools/test-security-check.py
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/env python2
'''
Test script for security-check.py
'''
Expand Down
2 changes: 1 addition & 1 deletion contrib/linearize/linearize-data.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
#
# linearize-data.py: Construct a linear, no-fork version of the chain.
#
Expand Down
2 changes: 1 addition & 1 deletion contrib/linearize/linearize-hashes.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
#
# linearize-hashes.py: List blocks in a linear, no-fork version of the chain.
#
Expand Down
4 changes: 2 additions & 2 deletions contrib/seeds/generate-seeds.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
# Copyright (c) 2014 Wladmir J. van der Laan
#!/usr/bin/env python
# Copyright (c) 2014 Wladimir J. van der Laan
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Expand Down
23 changes: 17 additions & 6 deletions qa/zcash/full_test_suite.py
Expand Up @@ -4,6 +4,7 @@
#

import argparse
from glob import glob
import os
import re
import subprocess
Expand Down Expand Up @@ -62,6 +63,13 @@ def check_security_hardening():
# PIE, RELRO, Canary, and NX are tested by make check-security.
ret &= subprocess.call(['make', '-C', repofile('src'), 'check-security']) == 0

# The remaining checks are only for ELF binaries
# Assume that if zcashd is an ELF binary, they all are
with open(repofile('src/zcashd'), 'rb') as f:
magic = f.read(4)
if not magic.startswith(b'\x7fELF'):
return ret

ret &= test_rpath_runpath('src/zcashd')
ret &= test_rpath_runpath('src/zcash-cli')
ret &= test_rpath_runpath('src/zcash-gtest')
Expand All @@ -79,11 +87,14 @@ def check_security_hardening():
return ret

def ensure_no_dot_so_in_depends():
arch_dir = os.path.join(
REPOROOT,
'depends',
'x86_64-unknown-linux-gnu',
)
depends_dir = os.path.join(REPOROOT, 'depends')
arch_dir = os.path.join(depends_dir, 'x86_64-unknown-linux-gnu')
if not os.path.isdir(arch_dir):
# Not Linux, try MacOS
arch_dirs = glob(os.path.join(depends_dir, 'x86_64-apple-darwin*'))
if arch_dirs:
# Just try the first one; there will only be on in CI
arch_dir = arch_dirs[0]

exit_code = 0

Expand All @@ -97,7 +108,7 @@ def ensure_no_dot_so_in_depends():
exit_code = 1
else:
exit_code = 2
print "arch-specific build dir not present: {}".format(arch_dir)
print "arch-specific build dir not present"
print "Did you build the ./depends tree?"
print "Are you on a currently unsupported architecture?"

Expand Down
2 changes: 1 addition & 1 deletion src/test/bitcoin-util-test.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# Copyright 2014 BitPay, Inc.
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down
2 changes: 1 addition & 1 deletion src/test/buildenv.py.in
@@ -1,2 +1,2 @@
#!/usr/bin/python
#!/usr/bin/env python
exeext="@EXEEXT@"
2 changes: 1 addition & 1 deletion src/wallet/gtest/test_wallet.cpp
Expand Up @@ -581,7 +581,7 @@ TEST(wallet_tests, cached_witnesses_empty_chain) {

// Until #1302 is implemented, this should triggger an assertion
EXPECT_DEATH(wallet.DecrementNoteWitnesses(&index),
"Assertion `nWitnessCacheSize > 0' failed.");
".*nWitnessCacheSize > 0.*");
}

TEST(wallet_tests, cached_witnesses_chain_tip) {
Expand Down

0 comments on commit 4e3ff06

Please sign in to comment.