summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranziskus Kiefer <franziskuskiefer@gmail.com>2016-05-03 15:13:36 +0200
committerFranziskus Kiefer <franziskuskiefer@gmail.com>2016-05-03 15:13:36 +0200
commitf64dfd51ce4625c1a8465d3dcbd53671da2bc44e (patch)
tree25ca57b21a44a86c7a5b28542d56f868eab76109
parentc0392078bd28ebf0c955f4826a6dcee5964494c5 (diff)
downloadnss-hg-f64dfd51ce4625c1a8465d3dcbd53671da2bc44e.tar.gz
Bug 1242565 - refactor gtests, r=mt
-rw-r--r--.travis.yml2
-rw-r--r--circle.yml4
-rw-r--r--external_tests/common/gtest.mk2
-rw-r--r--external_tests/common/gtests.cc (renamed from external_tests/der_gtest/der_gtest.cc)1
-rw-r--r--external_tests/der_gtest/manifest.mn2
-rw-r--r--external_tests/manifest.mn6
-rw-r--r--external_tests/pk11_gtest/manifest.mn2
-rw-r--r--external_tests/pk11_gtest/pk11_gtest.cc21
-rw-r--r--external_tests/util_gtest/manifest.mn2
-rw-r--r--external_tests/util_gtest/util_gtest.cc9
-rwxr-xr-xtests/all.sh11
-rw-r--r--tests/common/init.sh8
-rwxr-xr-xtests/der_gtests/der_gtests.sh84
-rwxr-xr-xtests/gtests/gtests.sh79
-rwxr-xr-xtests/pk11_gtests/pk11_gtests.sh84
-rwxr-xr-xtests/util_gtests/util_gtests.sh82
16 files changed, 96 insertions, 303 deletions
diff --git a/.travis.yml b/.travis.yml
index 8226b3639..3c72090e2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -64,7 +64,7 @@ before_script:
script:
- if [ -n "$CLANG_FORMAT" ]; then automation/travis/validate-formatting.sh lib/ssl; exit $?; fi
- make nss_build_all
- - cd tests; NSS_TESTS="ssl_gtests pk11_gtests der_gtests util_gtests" NSS_CYCLES=standard ./all.sh
+ - cd tests; NSS_TESTS="ssl_gtests gtests" NSS_CYCLES=standard ./all.sh
notifications:
irc:
diff --git a/circle.yml b/circle.yml
index 2938297f3..a7a28134a 100644
--- a/circle.yml
+++ b/circle.yml
@@ -5,9 +5,9 @@ checkout:
test:
override:
- make nss_build_all
- - cd tests; NSS_TESTS="ssl_gtests pk11_gtests der_gtests util_gtests" NSS_CYCLES=standard ./all.sh
+ - cd tests; NSS_TESTS="ssl_gtests gtests" NSS_CYCLES=standard ./all.sh
- BUILD_OPT=1 make nss_build_all
- - cd tests; BUILD_OPT=1 NSS_TESTS="ssl_gtests pk11_gtests der_gtests util_gtests" NSS_CYCLES=standard ./all.sh
+ - cd tests; BUILD_OPT=1 NSS_TESTS="ssl_gtests gtests" NSS_CYCLES=standard ./all.sh
machine:
environment:
diff --git a/external_tests/common/gtest.mk b/external_tests/common/gtest.mk
index 9d402cd4a..ecb324e67 100644
--- a/external_tests/common/gtest.mk
+++ b/external_tests/common/gtest.mk
@@ -4,7 +4,7 @@
# 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/.
-include ../../cmd/platlibs.mk
+include $(CORE_DEPTH)/cmd/platlibs.mk
MKPROG = $(CCC)
MKSHLIB = $(CCC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS)
diff --git a/external_tests/der_gtest/der_gtest.cc b/external_tests/common/gtests.cc
index 1bbfabb1f..8a42f2323 100644
--- a/external_tests/der_gtest/der_gtest.cc
+++ b/external_tests/common/gtests.cc
@@ -8,7 +8,6 @@
#include "gtest/gtest.h"
int main(int argc, char **argv) {
- // Start the tests
::testing::InitGoogleTest(&argc, argv);
NSS_NoDB_Init(nullptr);
diff --git a/external_tests/der_gtest/manifest.mn b/external_tests/der_gtest/manifest.mn
index 623f6199c..a7ff3f161 100644
--- a/external_tests/der_gtest/manifest.mn
+++ b/external_tests/der_gtest/manifest.mn
@@ -8,7 +8,7 @@ MODULE = nss
CPPSRCS = \
der_getint_unittest.cc \
- der_gtest.cc \
+ ../common/gtests.cc \
$(NULL)
INCLUDES += -I$(CORE_DEPTH)/external_tests/google_test/gtest/include \
diff --git a/external_tests/manifest.mn b/external_tests/manifest.mn
index c5a97dc3f..2dac9166b 100644
--- a/external_tests/manifest.mn
+++ b/external_tests/manifest.mn
@@ -7,8 +7,8 @@ DEPTH = ..
DIRS = \
google_test \
- der_gtest \
+ der_gtest \
util_gtest \
- pk11_gtest \
- ssl_gtest \
+ pk11_gtest \
+ ssl_gtest \
$(NULL)
diff --git a/external_tests/pk11_gtest/manifest.mn b/external_tests/pk11_gtest/manifest.mn
index 781785939..269621c49 100644
--- a/external_tests/pk11_gtest/manifest.mn
+++ b/external_tests/pk11_gtest/manifest.mn
@@ -11,7 +11,7 @@ CPPSRCS = \
pk11_pbkdf2_unittest.cc \
pk11_prf_unittest.cc \
pk11_rsapss_unittest.cc \
- pk11_gtest.cc \
+ ../common/gtests.cc \
$(NULL)
INCLUDES += -I$(CORE_DEPTH)/external_tests/google_test/gtest/include \
diff --git a/external_tests/pk11_gtest/pk11_gtest.cc b/external_tests/pk11_gtest/pk11_gtest.cc
deleted file mode 100644
index 1bbfabb1f..000000000
--- a/external_tests/pk11_gtest/pk11_gtest.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "nspr.h"
-#include "nss.h"
-#include "ssl.h"
-
-#include <cstdlib>
-
-#define GTEST_HAS_RTTI 0
-#include "gtest/gtest.h"
-
-int main(int argc, char **argv) {
- // Start the tests
- ::testing::InitGoogleTest(&argc, argv);
-
- NSS_NoDB_Init(nullptr);
- NSS_SetDomesticPolicy();
- int rv = RUN_ALL_TESTS();
-
- NSS_Shutdown();
-
- return rv;
-}
diff --git a/external_tests/util_gtest/manifest.mn b/external_tests/util_gtest/manifest.mn
index 9eb1ff704..9c09da434 100644
--- a/external_tests/util_gtest/manifest.mn
+++ b/external_tests/util_gtest/manifest.mn
@@ -7,7 +7,7 @@ DEPTH = ../..
MODULE = nss
CPPSRCS = \
- util_gtest.cc \
+ ../common/gtests.cc \
util_utf8_unittest.cc \
$(NULL)
diff --git a/external_tests/util_gtest/util_gtest.cc b/external_tests/util_gtest/util_gtest.cc
deleted file mode 100644
index 46b1664f3..000000000
--- a/external_tests/util_gtest/util_gtest.cc
+++ /dev/null
@@ -1,9 +0,0 @@
-#define GTEST_HAS_RTTI 0
-#include "gtest/gtest.h"
-
-int main(int argc, char **argv) {
- // Start the tests
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/tests/all.sh b/tests/all.sh
index ac34bf658..5f77b862c 100755
--- a/tests/all.sh
+++ b/tests/all.sh
@@ -36,8 +36,7 @@
# only in upgrade test cycle)
# memleak.sh - memory leak testing (optional)
# ssl_gtests.sh- Gtest based unit tests for ssl
-# pk11_gtests.sh- Gtest based unit tests for PKCS#11
-# der_gtests.sh- Gtest
+# gtests.sh - Gtest based unit tests for everything else
#
# NSS testing is now devided to 4 cycles:
# ---------------------------------------
@@ -162,7 +161,7 @@ run_cycle_pkix()
export NSS_ENABLE_PKIX_VERIFY
TESTS="${ALL_TESTS}"
- TESTS_SKIP="cipher dbtests sdr crmf smime merge multinit util_gtests"
+ TESTS_SKIP="cipher dbtests sdr crmf smime merge multinit"
echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
RET=$?
@@ -208,7 +207,7 @@ run_cycle_upgrade_db()
# run the subset of tests with the upgraded database
TESTS="${ALL_TESTS}"
- TESTS_SKIP="cipher libpkix cert dbtests sdr ocsp pkits chains ssl_gtests pk11_gtests der_gtests util_gtests"
+ TESTS_SKIP="cipher libpkix cert dbtests sdr ocsp pkits chains"
echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
RET=$?
@@ -239,7 +238,7 @@ run_cycle_shared_db()
# run the tests for native sharedb support
TESTS="${ALL_TESTS}"
- TESTS_SKIP="cipher libpkix dbupgrade sdr ocsp pkits ssl_gtests pk11_gtests der_gtests util_gtests"
+ TESTS_SKIP="cipher libpkix dbupgrade sdr ocsp pkits"
echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
RET=$?
@@ -280,7 +279,7 @@ run_cycles()
cycles="standard pkix upgradedb sharedb"
CYCLES=${NSS_CYCLES:-$cycles}
-tests="cipher lowhash libpkix cert dbtests tools fips sdr crmf smime ssl ocsp merge pkits chains ec ssl_gtests pk11_gtests der_gtests util_gtests"
+tests="cipher lowhash libpkix cert dbtests tools fips sdr crmf smime ssl ocsp merge pkits chains ec gtests ssl_gtests"
TESTS=${NSS_TESTS:-$tests}
ALL_TESTS=${TESTS}
diff --git a/tests/common/init.sh b/tests/common/init.sh
index 8f9ed0ec0..3cc2385a6 100644
--- a/tests/common/init.sh
+++ b/tests/common/init.sh
@@ -81,9 +81,7 @@ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
CERT_EXTENSIONS_DIR=${HOSTDIR}/cert_extensions
STAPLINGDIR=${HOSTDIR}/stapling
SSLGTESTDIR=${HOSTDIR}/ssl_gtests
- PK11GTESTDIR=${HOSTDIR}/pk11_gtests
- DERGTESTDIR=${HOSTDIR}/der_gtests
- UTILGTESTDIR=${HOSTDIR}/util_gtests
+ GTESTDIR=${HOSTDIR}/gtests
PWFILE=${HOSTDIR}/tests.pw
NOISE_FILE=${HOSTDIR}/tests_noise
@@ -547,9 +545,7 @@ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
R_CERT_EXT=../cert_extensions
R_STAPLINGDIR=../stapling
R_SSLGTESTDIR=../ssl_gtests
- R_PK11GTESTDIR=../pk11_gtests
- R_DERGTESTDIR=../der_gtests
- R_UTILGTESTDIR=../util_gtests
+ R_GTESTDIR=../gtests
#
# profiles are either paths or domains depending on the setting of
diff --git a/tests/der_gtests/der_gtests.sh b/tests/der_gtests/der_gtests.sh
deleted file mode 100755
index 9dba425c2..000000000
--- a/tests/der_gtests/der_gtests.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /bin/bash
-#
-# 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/.
-
-########################################################################
-#
-# tests/der_gtests/der_gtests.sh
-#
-# Script to drive the DER unit gtests
-#
-# needs to work on all Unix and Windows platforms
-#
-# special strings
-# ---------------
-# FIXME ... known problems, search for this string
-# NOTE .... unexpected behavior
-#
-########################################################################
-
-############################## der_gtest_init ##########################
-# local shell function to initialize this script
-########################################################################
-der_gtest_init()
-{
- SCRIPTNAME=der_gtest.sh # sourced - $0 would point to all.sh
-
- if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
- CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
- fi
- if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
- cd ../common
- . ./init.sh
- fi
-
- SCRIPTNAME=der_gtest.sh
- html_head DER Gtests
-
- if [ ! -d "${DERGTESTDIR}" ]; then
- mkdir -p "${DERGTESTDIR}"
- fi
-
- cd "${DERGTESTDIR}"
-}
-
-########################## der_gtest_start #########################
-# Local function to actually start the test
-####################################################################
-der_gtest_start()
-{
- if [ ! -f ${BINDIR}/der_gtest ]; then
- html_unknown "Skipping der_gtest (not built)"
- return
- fi
-
- # Temporarily disable asserts for PKCS#11 slot leakage (Bug 1168425)
- unset NSS_STRICT_SHUTDOWN
- DERGTESTREPORT="${DERGTESTDIR}/report.xml"
- ${BINDIR}/der_gtest -d "${DERGTESTDIR}" --gtest_output=xml:"${DERGTESTREPORT}"
- html_msg $? 0 "der_gtest run successfully"
- sed -f ${COMMON}/parsegtestreport.sed "${DERGTESTREPORT}" | \
- while read result name; do
- if [ "$result" = "notrun" ]; then
- echo "$name" SKIPPED
- elif [ "$result" = "run" ]; then
- html_passed "$name" > /dev/null
- else
- html_failed "$name"
- fi
- done
-}
-
-der_gtest_cleanup()
-{
- cd ${QADIR}
- . common/cleanup.sh
-}
-
-################## main #################################################
-cd "$(dirname "$0")"
-der_gtest_init
-der_gtest_start
-der_gtest_cleanup
diff --git a/tests/gtests/gtests.sh b/tests/gtests/gtests.sh
new file mode 100755
index 000000000..278537e41
--- /dev/null
+++ b/tests/gtests/gtests.sh
@@ -0,0 +1,79 @@
+#! /bin/bash
+#
+# 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/.
+
+########################################################################
+#
+# similar to all.sh this file runs drives gtests.
+#
+# needs to work on all Unix and Windows platforms
+#
+# special strings
+# ---------------
+# FIXME ... known problems, search for this string
+# NOTE .... unexpected behavior
+#
+########################################################################
+
+############################## gtest_init ##############################
+# local shell function to initialize this script
+########################################################################
+gtest_init()
+{
+ cd "$(dirname "$1")"
+ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
+ cd common
+ . ./init.sh
+ fi
+
+ SCRIPTNAME=gtests.sh
+
+ if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
+ CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
+ fi
+}
+
+########################## gtest_start #############################
+# Local function to actually start the test
+####################################################################
+gtest_start()
+{
+ echo "gtests: ${GTESTS}"
+ for i in ${GTESTS}; do
+ GTESTDIR="${HOSTDIR}/$i"
+ html_head "$i"
+ if [ ! -d "$GTESTDIR" ]; then
+ mkdir -p "$GTESTDIR"
+ fi
+ cd "$GTESTDIR"
+ GTESTREPORT="$GTESTDIR/report.xml"
+ ${BINDIR}/$i -d "$GTESTDIR" --gtest_output=xml:"${GTESTREPORT}"
+ echo "test output dir: ${GTESTREPORT}"
+ html_msg $? 0 "$i run successfully"
+ sed -f ${COMMON}/parsegtestreport.sed "${GTESTREPORT}" | \
+ while read result name; do
+ if [ "$result" = "notrun" ]; then
+ echo "$name" SKIPPED
+ elif [ "$result" = "run" ]; then
+ html_passed "$name" > /dev/null
+ else
+ html_failed "$name"
+ fi
+ done
+ done
+}
+
+gtest_cleanup()
+{
+ html "</TABLE><BR>"
+ cd ${QADIR}
+ . common/cleanup.sh
+}
+
+################## main #################################################
+GTESTS="der_gtest pk11_gtest util_gtest"
+gtest_init $0
+gtest_start
+gtest_cleanup
diff --git a/tests/pk11_gtests/pk11_gtests.sh b/tests/pk11_gtests/pk11_gtests.sh
deleted file mode 100755
index 2eabd4aeb..000000000
--- a/tests/pk11_gtests/pk11_gtests.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /bin/bash
-#
-# 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/.
-
-########################################################################
-#
-# tests/pk11_gtests/pk11_gtests.sh
-#
-# Script to drive the PKCS#11 gtest unit tests
-#
-# needs to work on all Unix and Windows platforms
-#
-# special strings
-# ---------------
-# FIXME ... known problems, search for this string
-# NOTE .... unexpected behavior
-#
-########################################################################
-
-############################## pk11_gtest_init ##########################
-# local shell function to initialize this script
-########################################################################
-pk11_gtest_init()
-{
- SCRIPTNAME=pk11_gtest.sh # sourced - $0 would point to all.sh
-
- if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
- CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
- fi
- if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
- cd ../common
- . ./init.sh
- fi
-
- SCRIPTNAME=pk11_gtest.sh
- html_head PKCS\#11 Gtests
-
- if [ ! -d "${PK11GTESTDIR}" ]; then
- mkdir -p "${PK11GTESTDIR}"
- fi
-
- cd "${PK11GTESTDIR}"
-}
-
-########################## pk11_gtest_start #########################
-# Local function to actually start the test
-####################################################################
-pk11_gtest_start()
-{
- if [ ! -f ${BINDIR}/pk11_gtest ]; then
- html_unknown "Skipping pk11_gtest (not built)"
- return
- fi
-
- # Temporarily disable asserts for PKCS#11 slot leakage (Bug 1168425)
- unset NSS_STRICT_SHUTDOWN
- PK11GTESTREPORT="${PK11GTESTDIR}/report.xml"
- ${BINDIR}/pk11_gtest -d "${PK11GTESTDIR}" --gtest_output=xml:"${PK11GTESTREPORT}"
- html_msg $? 0 "pk11_gtest run successfully"
- sed -f ${COMMON}/parsegtestreport.sed "${PK11GTESTREPORT}" | \
- while read result name; do
- if [ "$result" = "notrun" ]; then
- echo "$name" SKIPPED
- elif [ "$result" = "run" ]; then
- html_passed "$name" > /dev/null
- else
- html_failed "$name"
- fi
- done
-}
-
-pk11_gtest_cleanup()
-{
- cd ${QADIR}
- . common/cleanup.sh
-}
-
-################## main #################################################
-cd "$(dirname "$0")"
-pk11_gtest_init
-pk11_gtest_start
-pk11_gtest_cleanup
diff --git a/tests/util_gtests/util_gtests.sh b/tests/util_gtests/util_gtests.sh
deleted file mode 100755
index c6fd2ea79..000000000
--- a/tests/util_gtests/util_gtests.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#! /bin/bash
-#
-# 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/.
-
-########################################################################
-#
-# tests/util_gtests/util_gtests.sh
-#
-# Script to drive the libnssutil gtest unit tests
-#
-# needs to work on all Unix and Windows platforms
-#
-# special strings
-# ---------------
-# FIXME ... known problems, search for this string
-# NOTE .... unexpected behavior
-#
-########################################################################
-
-############################## util_gtest_init ##########################
-# local shell function to initialize this script
-########################################################################
-util_gtest_init()
-{
- SCRIPTNAME=util_gtest.sh # sourced - $0 would point to all.sh
-
- if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
- CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
- fi
- if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
- cd ../common
- . ./init.sh
- fi
-
- SCRIPTNAME=util_gtest.sh
- html_head libnssutil Gtests
-
- if [ ! -d "${UTILGTESTDIR}" ]; then
- mkdir -p "${UTILGTESTDIR}"
- fi
-
- cd "${UTILGTESTDIR}"
-}
-
-########################## util_gtest_start #########################
-# Local function to actually start the test
-####################################################################
-util_gtest_start()
-{
- if [ ! -f ${BINDIR}/util_gtest ]; then
- html_unknown "Skipping util_gtest (not built)"
- return
- fi
-
- UTILGTESTREPORT="${UTILGTESTDIR}/report.xml"
- ${BINDIR}/util_gtest -d "${UTILGTESTDIR}" --gtest_output=xml:"${UTILGTESTREPORT}"
- html_msg $? 0 "util_gtest run successfully"
- sed -f ${COMMON}/parsegtestreport.sed "${UTILGTESTREPORT}" | \
- while read result name; do
- if [ "$result" = "notrun" ]; then
- echo "$name" SKIPPED
- elif [ "$result" = "run" ]; then
- html_passed "$name" > /dev/null
- else
- html_failed "$name"
- fi
- done
-}
-
-util_gtest_cleanup()
-{
- cd ${QADIR}
- . common/cleanup.sh
-}
-
-################## main #################################################
-cd "$(dirname "$0")"
-util_gtest_init
-util_gtest_start
-util_gtest_cleanup