Bug 1227248 - Part 2: Add GeneratedTest{Certificate,Key} mozbuild templates. r=gps
authorNick Alexander <nalexander@mozilla.com>
Mon, 14 Dec 2015 11:50:56 -0800
changeset 311633 009b3d8932c655b68198189610d545f7f39a8ee3
parent 311632 8ce39c03f90b01f476b890904090b58d7f09300e
child 311634 634a4690d5a09609ea13f28aacde14c1b4079a9b
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1227248
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1227248 - Part 2: Add GeneratedTest{Certificate,Key} mozbuild templates. r=gps
build/templates.mozbuild
build/test_templates.mozbuild
security/manager/ssl/tests/unit/bad_certs/moz.build
security/manager/ssl/tests/unit/ocsp_certs/moz.build
security/manager/ssl/tests/unit/test_cert_eku/generate.py
security/manager/ssl/tests/unit/test_cert_eku/moz.build
security/manager/ssl/tests/unit/test_cert_embedded_null/moz.build
security/manager/ssl/tests/unit/test_cert_keyUsage/moz.build
security/manager/ssl/tests/unit/test_cert_sha1/moz.build
security/manager/ssl/tests/unit/test_cert_signatures/moz.build
security/manager/ssl/tests/unit/test_cert_trust/moz.build
security/manager/ssl/tests/unit/test_cert_version/moz.build
security/manager/ssl/tests/unit/test_ev_certs/moz.build
security/manager/ssl/tests/unit/test_getchain/moz.build
security/manager/ssl/tests/unit/test_intermediate_basic_usage_constraints/moz.build
security/manager/ssl/tests/unit/test_keysize/moz.build
security/manager/ssl/tests/unit/test_keysize_ev/moz.build
security/manager/ssl/tests/unit/test_name_constraints/moz.build
security/manager/ssl/tests/unit/test_ocsp_fetch_method/moz.build
security/manager/ssl/tests/unit/test_ocsp_url/moz.build
security/manager/ssl/tests/unit/test_onecrl/moz.build
security/manager/ssl/tests/unit/test_pinning_dynamic/moz.build
security/manager/ssl/tests/unit/test_validity/moz.build
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -112,8 +112,9 @@ def HostSimplePrograms(names, ext='.cpp'
 
 @template
 def HostLibrary(name):
     '''Template for build tools libraries.'''
     HOST_LIBRARY_NAME = name
 
 
 include('gecko_templates.mozbuild')
+include('test_templates.mozbuild')
new file mode 100644
--- /dev/null
+++ b/build/test_templates.mozbuild
@@ -0,0 +1,33 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@template
+def GeneratedTestCertificate(name):
+    GENERATED_FILES += [name]
+    props = GENERATED_FILES[name]
+    props.script = '/security/manager/ssl/tests/unit/pycert.py'
+    props.inputs = ['%s.certspec' % name]
+    # Turn RELATIVEDIR into list entry: like
+    # 'security/manager/ssl/tests/unit/bad_certs' ->
+    # TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.bad_certs.
+    files = TEST_HARNESS_FILES.xpcshell
+    for part in RELATIVEDIR.split('/'):
+        files = files[part]
+    files += ['!%s' % name]
+
+@template
+def GeneratedTestKey(name):
+    GENERATED_FILES += [name]
+    props = GENERATED_FILES[name]
+    props.script = '/security/manager/ssl/tests/unit/pykey.py'
+    props.inputs = ['%s.keyspec' % name]
+    # Turn RELATIVEDIR into list entry: like
+    # 'security/manager/ssl/tests/unit/bad_certs' ->
+    # TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.bad_certs.
+    files = TEST_HARNESS_FILES.xpcshell
+    for part in RELATIVEDIR.split('/'):
+        files = files[part]
+    files += ['!%s' % name]
--- a/security/manager/ssl/tests/unit/bad_certs/moz.build
+++ b/security/manager/ssl/tests/unit/bad_certs/moz.build
@@ -44,28 +44,18 @@ test_certificates = (
     'test-int.pem',
     'unknownissuer.pem',
     'untrusted-expired.pem',
     'untrustedissuer.pem',
     'v1Cert.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.bad_certs += ['!%s' % test_certificate]
-
+    GeneratedTestCertificate(test_certificate)
+    
 test_keys = (
     'default-ee.key',
     'inadequateKeySizeEE.key',
     'other-test-ca.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.bad_certs += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/ocsp_certs/moz.build
+++ b/security/manager/ssl/tests/unit/ocsp_certs/moz.build
@@ -24,28 +24,18 @@ test_certificates = (
     'rsa-1016-keysizeDelegatedSigner.pem',
     'test-ca.pem',
     'test-int.pem',
     'test-multi-tls-feature-int.pem',
     'test-must-staple-int.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.ocsp_certs += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'default-ee.key',
     'other-test-ca.key',
     'rsa-1016-keysizeDelegatedSigner.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.ocsp_certs += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/test_cert_eku/generate.py
+++ b/security/manager/ssl/tests/unit/test_cert_eku/generate.py
@@ -218,22 +218,17 @@ def generate_mozbuild_file(generated_cer
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 test_certificates = (
 """
 
     MOZ_BUILD_FOOTER = """)
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_eku += ['!%s' % test_certificate]
+    TestCertificate(test_certificate)
 """
 
     with open("moz.build", "w") as f:
         f.write(MOZ_BUILD_HEADER)
         for cert_filename in sorted(generated_cert_filenames):
             f.write("    '%s',\n" % cert_filename)
         f.write(MOZ_BUILD_FOOTER)
 
--- a/security/manager/ssl/tests/unit/test_cert_eku/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_eku/moz.build
@@ -557,14 +557,9 @@ test_certificates = (
     'int-EKU-OS_SA.pem',
     'int-EKU-OS_TS.pem',
     'int-EKU-SA.pem',
     'int-EKU-SA_TS.pem',
     'int-EKU-TS.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_eku += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_embedded_null/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_embedded_null/moz.build
@@ -8,14 +8,9 @@ test_certificates = (
     'ca.pem',
     'embeddedNull.pem',
     'embeddedNullCNAndSAN.pem',
     'embeddedNullSAN.pem',
     'embeddedNullSAN2.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_embedded_null += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_keyUsage/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_keyUsage/moz.build
@@ -18,14 +18,9 @@ test_certificates = (
     'ee-keyEncipherment-only-ca-missing-keyCertSign.pem',
     'ee-keyEncipherment-only-ca-no-keyUsage-extension.pem',
     'ee-no-keyUsage-extension-ca-all-usages.pem',
     'ee-no-keyUsage-extension-ca-missing-keyCertSign.pem',
     'ee-no-keyUsage-extension-ca-no-keyUsage-extension.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_keyUsage += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_sha1/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_sha1/moz.build
@@ -9,14 +9,9 @@ test_certificates = (
     'int-pre.pem',
     'ee-pre_int-pre.pem',
     'ee-post_int-pre.pem',
     'int-post.pem',
     'ee-post_int-post.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_sha1 += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_signatures/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_signatures/moz.build
@@ -11,14 +11,9 @@ test_certificates = (
     'ee-rsa.pem',
     'ee-secp384r1-direct.pem',
     'ee-secp384r1.pem',
     'int-rsa.pem',
     'int-secp384r1.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_signatures += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_trust/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_trust/moz.build
@@ -6,14 +6,9 @@
 
 test_certificates = (
     'ca.pem',
     'ee.pem',
     'int.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_trust += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_cert_version/moz.build
+++ b/security/manager/ssl/tests/unit/test_cert_version/moz.build
@@ -52,14 +52,9 @@ test_certificates = (
     'ss-v3-BC-not-cA.pem',
     'ss-v3-noBC.pem',
     'ss-v4-BC-cA.pem',
     'ss-v4-BC-not-cA.pem',
     'ss-v4-noBC.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_cert_version += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_ev_certs/moz.build
+++ b/security/manager/ssl/tests/unit/test_ev_certs/moz.build
@@ -12,27 +12,17 @@ test_certificates = (
     'int-ev-valid.pem',
     'int-non-ev-root.pem',
     'no-ocsp-url-cert.pem',
     'non-ev-root.pem',
     'non-evroot-ca.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ev_certs += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'evroot.key',
     'int-ev-valid.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ev_certs += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/test_getchain/moz.build
+++ b/security/manager/ssl/tests/unit/test_getchain/moz.build
@@ -6,14 +6,9 @@
 
 test_certificates = (
     'ca-1.pem',
     'ca-2.pem',
     'ee.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_getchain += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_intermediate_basic_usage_constraints/moz.build
+++ b/security/manager/ssl/tests/unit/test_intermediate_basic_usage_constraints/moz.build
@@ -26,14 +26,9 @@ test_certificates = (
     'int-no-ku-no-eku.pem',
     'int-no-ku-server-eku.pem',
     'int-not-a-ca.pem',
     'int-valid-ku-no-eku.pem',
     'int-valid-ku-server-eku.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_intermediate_basic_usage_constraints += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_keysize/moz.build
+++ b/security/manager/ssl/tests/unit/test_keysize/moz.build
@@ -32,14 +32,9 @@ test_certificates = (
     'root_rsa_1024.pem',
     'root_rsa_2048.pem',
     'root_secp224r1_224.pem',
     'root_secp256k1_256.pem',
     'root_secp256r1_256.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_keysize += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_keysize_ev/moz.build
+++ b/security/manager/ssl/tests/unit/test_keysize_ev/moz.build
@@ -12,29 +12,19 @@ test_certificates = (
     'ev_int_rsa_2040-evroot.pem',
     'ev_int_rsa_2048-ev_root_rsa_2040.pem',
     'ev_int_rsa_2048-evroot.pem',
     'ev_root_rsa_2040.pem',
     'evroot.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_keysize_ev += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'ev_int_rsa_2040.key',
     'ev_int_rsa_2048.key',
     'ev_root_rsa_2040.key',
     'evroot.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_keysize_ev += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/test_name_constraints/moz.build
+++ b/security/manager/ssl/tests/unit/test_name_constraints/moz.build
@@ -158,14 +158,9 @@ test_certificates = (
     'int-nc-foo.com-int-nc-foo.com_a.us.pem',
     'int-nc-foo.com_a.us.pem',
     'int-nc-perm-c-uk-ca-nc.pem',
     'int-nc-perm-foo.com-ca-nc.pem',
     'int-nc-perm-foo.com_c-us-ca-nc.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_name_constraints += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_ocsp_fetch_method/moz.build
+++ b/security/manager/ssl/tests/unit/test_ocsp_fetch_method/moz.build
@@ -6,26 +6,16 @@
 
 test_certificates = (
     'a.pem',
     'ca.pem',
     'int.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ocsp_fetch_method += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'int.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ocsp_fetch_method += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/test_ocsp_url/moz.build
+++ b/security/manager/ssl/tests/unit/test_ocsp_url/moz.build
@@ -17,26 +17,16 @@ test_certificates = (
     'no-host-url.pem',
     'no-path-url.pem',
     'no-scheme-host-port.pem',
     'no-scheme-url.pem',
     'unknown-scheme.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ocsp_url += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'int.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_ocsp_url += ['!%s' % test_key]
+    GeneratedTestKey(test_key)
--- a/security/manager/ssl/tests/unit/test_onecrl/moz.build
+++ b/security/manager/ssl/tests/unit/test_onecrl/moz.build
@@ -5,14 +5,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 test_certificates = (
     'same-issuer-ee.pem',
     'test-int-ee.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_onecrl += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_pinning_dynamic/moz.build
+++ b/security/manager/ssl/tests/unit/test_pinning_dynamic/moz.build
@@ -15,14 +15,9 @@ test_certificates = (
     'cn-x.a.pinning2.example.com-badca.pem',
     'cn-x.a.pinning2.example.com-pinningroot.pem',
     'cn-x.b.pinning2.example.com-badca.pem',
     'cn-x.b.pinning2.example.com-pinningroot.pem',
     'pinningroot.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_pinning_dynamic += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
--- a/security/manager/ssl/tests/unit/test_validity/moz.build
+++ b/security/manager/ssl/tests/unit/test_validity/moz.build
@@ -7,27 +7,17 @@
 test_certificates = (
     'ev_ee_27_months-ev_int_60_months-evroot.pem',
     'ev_ee_28_months-ev_int_60_months-evroot.pem',
     'ev_int_60_months-evroot.pem',
     'evroot.pem',
 )
 
 for test_certificate in test_certificates:
-    input_file = test_certificate + '.certspec'
-    GENERATED_FILES += [test_certificate]
-    props = GENERATED_FILES[test_certificate]
-    props.script = '../pycert.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_validity += ['!%s' % test_certificate]
+    GeneratedTestCertificate(test_certificate)
 
 test_keys = (
     'ev_int_60_months-evroot.key',
     'evroot.key',
 )
 
 for test_key in test_keys:
-    input_file = test_key + '.keyspec'
-    GENERATED_FILES += [test_key]
-    props = GENERATED_FILES[test_key]
-    props.script = '../pykey.py'
-    props.inputs = [input_file]
-    TEST_HARNESS_FILES.xpcshell.security.manager.ssl.tests.unit.test_validity += ['!%s' % test_key]
+    GeneratedTestKey(test_key)