Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1242565 - refactor gtests, r=mt
  • Loading branch information
franziskuskiefer committed May 3, 2016
1 parent 798ea48 commit 418e67f
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion external_tests/common/gtest.mk
Expand Up @@ -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)
Expand Down
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion external_tests/der_gtest/manifest.mn
Expand Up @@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions external_tests/manifest.mn
Expand Up @@ -7,8 +7,8 @@ DEPTH = ..

DIRS = \
google_test \
der_gtest \
der_gtest \
util_gtest \
pk11_gtest \
ssl_gtest \
pk11_gtest \
ssl_gtest \
$(NULL)
2 changes: 1 addition & 1 deletion external_tests/pk11_gtest/manifest.mn
Expand Up @@ -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 \
Expand Down
21 changes: 0 additions & 21 deletions external_tests/pk11_gtest/pk11_gtest.cc

This file was deleted.

2 changes: 1 addition & 1 deletion external_tests/util_gtest/manifest.mn
Expand Up @@ -7,7 +7,7 @@ DEPTH = ../..
MODULE = nss

CPPSRCS = \
util_gtest.cc \
../common/gtests.cc \
util_utf8_unittest.cc \
$(NULL)

Expand Down
9 changes: 0 additions & 9 deletions external_tests/util_gtest/util_gtest.cc

This file was deleted.

11 changes: 5 additions & 6 deletions tests/all.sh
Expand Up @@ -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:
# ---------------------------------------
Expand Down Expand Up @@ -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=$?
Expand Down Expand Up @@ -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=$?
Expand Down Expand Up @@ -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=$?
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 2 additions & 6 deletions tests/common/init.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
84 changes: 0 additions & 84 deletions tests/der_gtests/der_gtests.sh

This file was deleted.

79 changes: 79 additions & 0 deletions 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

0 comments on commit 418e67f

Please sign in to comment.