| Index: tools/testrunner/server/signatures.py
|
| diff --git a/tools/check-static-initializers.sh b/tools/testrunner/server/signatures.py
|
| old mode 100755
|
| new mode 100644
|
| similarity index 56%
|
| copy from tools/check-static-initializers.sh
|
| copy to tools/testrunner/server/signatures.py
|
| index 1103a9778775dc86e8b59ee4f804670192533f70..9957a18a267521323f7b8e3e8e1a41146239f674
|
| --- a/tools/check-static-initializers.sh
|
| +++ b/tools/testrunner/server/signatures.py
|
| @@ -1,4 +1,3 @@
|
| -#!/bin/bash
|
| # Copyright 2012 the V8 project authors. All rights reserved.
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -26,38 +25,39 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -# Checks that the number of compilation units having at least one static
|
| -# initializer in d8 matches the one defined below.
|
| -# Note that the project must be built with SCons before running this script.
|
|
|
| -# Allow:
|
| -# - _GLOBAL__I__ZN2v810LineEditor6first_E
|
| -# - _GLOBAL__I__ZN2v88internal32AtomicOps_Internalx86CPUFeaturesE
|
| -# - _GLOBAL__I__ZN2v88internal8ThreadId18highest_thread_id_E
|
| -expected_static_init_count=3
|
| -
|
| -v8_root=$(readlink -f $(dirname $BASH_SOURCE)/../)
|
| -
|
| -if [ -n "$1" ] ; then
|
| - d8="${v8_root}/$1"
|
| -else
|
| - d8="${v8_root}/d8"
|
| -fi
|
| -
|
| -if [ ! -f "$d8" ]; then
|
| - echo "d8 binary not found: $d8"
|
| - exit 1
|
| -fi
|
| -
|
| -static_inits=$(nm "$d8" | grep _GLOBAL_ | grep _I_ | awk '{ print $NF; }')
|
| -
|
| -static_init_count=$(echo "$static_inits" | wc -l)
|
| -
|
| -if [ $static_init_count -gt $expected_static_init_count ]; then
|
| - echo "Too many static initializers."
|
| - echo "$static_inits"
|
| - exit 1
|
| -else
|
| - echo "Static initializer check passed ($static_init_count initializers)."
|
| - exit 0
|
| -fi
|
| +import base64
|
| +import os
|
| +import subprocess
|
| +
|
| +
|
| +def ReadFileAndSignature(filename):
|
| + with open(filename, "rb") as f:
|
| + file_contents = base64.b64encode(f.read())
|
| + signature_file = filename + ".signature"
|
| + if (not os.path.exists(signature_file) or
|
| + os.path.getmtime(signature_file) < os.path.getmtime(filename)):
|
| + private_key = "~/.ssh/v8_dtest"
|
| + code = subprocess.call("openssl dgst -out %s -sign %s %s" %
|
| + (signature_file, private_key, filename),
|
| + shell=True)
|
| + if code != 0: return [None, code]
|
| + with open(signature_file) as f:
|
| + signature = base64.b64encode(f.read())
|
| + return [file_contents, signature]
|
| +
|
| +
|
| +def VerifySignature(filename, file_contents, signature, pubkeyfile):
|
| + with open(filename, "wb") as f:
|
| + f.write(base64.b64decode(file_contents))
|
| + signature_file = filename + ".foreign_signature"
|
| + with open(signature_file, "wb") as f:
|
| + f.write(base64.b64decode(signature))
|
| + code = subprocess.call("openssl dgst -verify %s -signature %s %s" %
|
| + (pubkeyfile, signature_file, filename),
|
| + shell=True)
|
| + matched = (code == 0)
|
| + if not matched:
|
| + os.remove(signature_file)
|
| + os.remove(filename)
|
| + return matched
|
|
|