michael@0: #! gmake michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ####################################################################### michael@0: # (1) Include initial platform-independent assignments (MANDATORY). # michael@0: ####################################################################### michael@0: michael@0: include manifest.mn michael@0: michael@0: ####################################################################### michael@0: # (2) Include "global" configuration information. (OPTIONAL) # michael@0: ####################################################################### michael@0: michael@0: include $(CORE_DEPTH)/coreconf/config.mk michael@0: michael@0: ####################################################################### michael@0: # (3) Include "component" configuration information. (OPTIONAL) # michael@0: ####################################################################### michael@0: michael@0: michael@0: michael@0: ####################################################################### michael@0: # (4) Include "local" platform-dependent assignments (OPTIONAL). # michael@0: ####################################################################### michael@0: michael@0: michael@0: michael@0: ####################################################################### michael@0: # (5) Execute "global" rules. (OPTIONAL) # michael@0: ####################################################################### michael@0: michael@0: include $(CORE_DEPTH)/coreconf/rules.mk michael@0: michael@0: ####################################################################### michael@0: # (6) Execute "component" rules. (OPTIONAL) # michael@0: ####################################################################### michael@0: michael@0: michael@0: michael@0: ####################################################################### michael@0: # (7) Execute "local" rules. (OPTIONAL). # michael@0: ####################################################################### michael@0: michael@0: TESTPACKAGE="nss-$(OS_TARGET)$(CPU_TAG).tgz" michael@0: RTSH=$(DIST)/../../runtests.sh michael@0: PCFG=$(DIST)/platform.cfg michael@0: michael@0: michael@0: #Hint: In order to test the Makefiles without running the tests, use: michael@0: # make NSS_CYCLES="standard" NSS_TESTS="dummy" michael@0: michael@0: ifeq ($(OS_TARGET),Android) michael@0: TEST_SHELL?=$$HOME/bin/sh michael@0: ANDROID_PORT?="2222" michael@0: #Define the subset of tests that is known to work on Android michael@0: NSS_CYCLES?="standard pkix upgradedb sharedb" michael@0: NSS_TESTS?="cipher lowhash libpkix cert dbtests tools sdr crmf smime ssl ocsp merge pkits chains" michael@0: NSS_SSL_TESTS?="crl normal_normal iopr" michael@0: NSS_SSL_RUN?="cov auth stress" michael@0: else michael@0: TEST_SHELL?="/bin/sh" michael@0: endif michael@0: michael@0: # Create a package for test execution on a separate system. michael@0: package_for_testing: michael@0: echo "export OBJDIR=$(OBJDIR_NAME)" > $(PCFG) michael@0: echo "export OS_ARCH=$(OS_ARCH)" >> $(PCFG) michael@0: echo "export OS_TARGET=$(OS_TARGET)" >> $(PCFG) michael@0: echo "export DLL_PREFIX=$(DLL_PREFIX)" >> $(PCFG) michael@0: echo "export DLL_SUFFIX=$(DLL_SUFFIX)" >> $(PCFG) michael@0: echo 'echo "set HOST and DOMSUF if your system is not registered in DNS"' > $(RTSH) michael@0: cat $(PCFG) >> $(RTSH) michael@0: echo 'export NSS_TESTS=$(NSS_TESTS)' >> $(RTSH) michael@0: echo 'export NSS_SSL_TESTS=$(NSS_SSL_TESTS)' >> $(RTSH) michael@0: echo 'export NSS_SSL_RUN=$(NSS_SSL_RUN)' >> $(RTSH) michael@0: echo 'export NSS_CYCLES=$(NSS_CYCLES)' >> $(RTSH) michael@0: echo 'export USE_64=$(USE_64)' >> $(RTSH) michael@0: echo 'export BUILD_OPT=$(BUILD_OPT)' >> $(RTSH) michael@0: echo 'export PKITS_DATA=$(PKITS_DATA)' >> $(RTSH) michael@0: echo 'export NSS_DISABLE_ECC=$(NSS_DISABLE_ECC)' >> $(RTSH) michael@0: echo 'export NSS_ECC_MORE_THAN_SUITE_B=$(NSS_ECC_MORE_THAN_SUITE_B)' >> $(RTSH) michael@0: echo 'export NSPR_LOG_MODULES=$(NSPR_LOG_MODULES)' >> $(RTSH) michael@0: ifeq ($(OS_TARGET),Android) michael@0: # Android doesn't support FIPS tests, because michael@0: # dladdr does not return a full path for implicitly loaded libraries michael@0: echo "export NSS_TEST_DISABLE_FIPS=1" >> $(DIST)/platform.cfg michael@0: endif michael@0: ifeq ($(CROSS_COMPILE),1) michael@0: # execute signing on test system michael@0: echo 'export DIST=$${HOME}/nsstest/dist/' >> $(RTSH) michael@0: echo 'export NSPR_LIB_DIR=$${DIST}/$${OBJDIR}/lib/' >> $(RTSH) michael@0: echo 'echo "signing"' >> $(RTSH) michael@0: # work around a bug in Android ash that has a corrupted work directory after login michael@0: echo 'cd $${HOME}/nsstest' >> $(RTSH) michael@0: echo 'cd nss/cmd/shlibsign' >> $(RTSH) michael@0: echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}freebl3.$${DLL_SUFFIX}' >> $(RTSH) michael@0: echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}softokn3.$${DLL_SUFFIX}' >> $(RTSH) michael@0: echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}nssdbm3.$${DLL_SUFFIX}' >> $(RTSH) michael@0: ifneq ($(OS_TARGET),Android) michael@0: # Android's ash doesn't support "export -n" yet michael@0: echo 'export -n DIST' >> $(RTSH) michael@0: echo 'export -n NSPR_LIB_DIR' >> $(RTSH) michael@0: endif michael@0: echo 'cd ../../../' >> $(RTSH) michael@0: endif michael@0: echo 'rm -rf tests_results' >> $(RTSH) michael@0: echo 'echo "running tests"' >> $(RTSH) michael@0: echo 'cd nss/tests' >> $(RTSH) michael@0: # We require progress indication on stdout while running the tests (to avoid timeouts). michael@0: set -o pipefail michael@0: echo '$(TEST_SHELL) ./all.sh | tee ../../logfile 2>&1 |grep ": #"' >> $(RTSH) michael@0: RETVAL=$? michael@0: echo 'cd ../../' >> $(RTSH) michael@0: # dump test summary from end of logfile michael@0: echo 'echo "=========="; tail -100 logfile' >> $(RTSH) michael@0: echo 'tar czf tests_results.tgz tests_results' >> $(RTSH) michael@0: echo 'echo "created tests_results.tgz"' >> $(RTSH) michael@0: echo 'echo "results are in directory: "`ls -1d tests_results/security/*.1`' >> $(RTSH) michael@0: echo 'echo exit status: $${RETVAL}' >> $(RTSH) michael@0: echo 'exit $${RETVAL}' >> $(RTSH) michael@0: rm -f $(TESTPACKAGE) michael@0: (cd $(DIST)/../.. ; tar czhf dist/$(TESTPACKAGE) runtests.sh dist/$(OBJDIR_NAME) dist/public nss/tests nss/cmd/bltest/tests nss/cmd/pk11gcmtest/tests nss/cmd/shlibsign; echo "created "`pwd`"/dist/$(TESTPACKAGE)" ) michael@0: michael@0: android_run_tests: michael@0: ssh -p $(ANDROID_PORT) -o CheckHostIP=no $(ANDROID_ADDR) 'pwd; cd; pwd; cd nsstest; export PATH=$$HOME/bin:$$PATH ; $(TEST_SHELL) runtests.sh' michael@0: michael@0: android_install: michael@0: rm -f $(DIST)/android.sftp michael@0: echo '-mkdir nsstest' > $(DIST)/android.sftp michael@0: echo '-rm nsstest/$(TESTPACKAGE)' >> $(DIST)/android.sftp michael@0: echo 'progress' >> $(DIST)/android.sftp michael@0: echo 'put $(DIST)/../$(TESTPACKAGE) nsstest' >> $(DIST)/android.sftp michael@0: sftp -o Port=$(ANDROID_PORT) -o CheckHostIP=no -b $(DIST)/android.sftp $(ANDROID_ADDR) michael@0: ssh -p $(ANDROID_PORT) -o CheckHostIP=no $(ANDROID_ADDR) 'cd nsstest ; $$HOME/bin/rm -rf logfile runtests.sh dist security tests_results tests_results.tgz; $$HOME/bin/tar xzf $(TESTPACKAGE)' michael@0: michael@0: WORKDIR="$(DIST)/../../" michael@0: RESULTSPACKAGE=tests_results.tgz michael@0: android_get_result: michael@0: rm -f $(WORKDIR)/result.sftp $(WORKDIR)/$(RESULTSPACKAGE) michael@0: echo "progress" > $(WORKDIR)/result.sftp michael@0: echo 'get nsstest/$(RESULTSPACKAGE) $(WORKDIR)' >> $(WORKDIR)/result.sftp michael@0: sftp -o Port=$(ANDROID_PORT) -o CheckHostIP=no -b $(WORKDIR)/result.sftp $(ANDROID_ADDR) michael@0: (cd $(WORKDIR); tar xzf $(RESULTSPACKAGE); rm -f result.sftp $(RESULTSPACKAGE) ) michael@0: michael@0: # Android testing assumes having built with: OS_TARGET=Android CROSS_COMPILE=1 michael@0: # Connectivity tested with Android app: SSHDroid michael@0: # Provide appropriate ANDROID_ADDR variable, e.g.: michael@0: # make test_android ANDROID_ADDR=root@192.168.4.5 michael@0: # See also: https://wiki.mozilla.org/NSS:Android michael@0: michael@0: test_android: package_for_testing android_install android_run_tests android_get_result