|
1 #! gmake |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 ####################################################################### |
|
8 # (1) Include initial platform-independent assignments (MANDATORY). # |
|
9 ####################################################################### |
|
10 |
|
11 include manifest.mn |
|
12 |
|
13 ####################################################################### |
|
14 # (2) Include "global" configuration information. (OPTIONAL) # |
|
15 ####################################################################### |
|
16 |
|
17 include $(CORE_DEPTH)/coreconf/config.mk |
|
18 |
|
19 ####################################################################### |
|
20 # (3) Include "component" configuration information. (OPTIONAL) # |
|
21 ####################################################################### |
|
22 |
|
23 |
|
24 |
|
25 ####################################################################### |
|
26 # (4) Include "local" platform-dependent assignments (OPTIONAL). # |
|
27 ####################################################################### |
|
28 |
|
29 |
|
30 |
|
31 ####################################################################### |
|
32 # (5) Execute "global" rules. (OPTIONAL) # |
|
33 ####################################################################### |
|
34 |
|
35 include $(CORE_DEPTH)/coreconf/rules.mk |
|
36 |
|
37 ####################################################################### |
|
38 # (6) Execute "component" rules. (OPTIONAL) # |
|
39 ####################################################################### |
|
40 |
|
41 |
|
42 |
|
43 ####################################################################### |
|
44 # (7) Execute "local" rules. (OPTIONAL). # |
|
45 ####################################################################### |
|
46 |
|
47 TESTPACKAGE="nss-$(OS_TARGET)$(CPU_TAG).tgz" |
|
48 RTSH=$(DIST)/../../runtests.sh |
|
49 PCFG=$(DIST)/platform.cfg |
|
50 |
|
51 |
|
52 #Hint: In order to test the Makefiles without running the tests, use: |
|
53 # make NSS_CYCLES="standard" NSS_TESTS="dummy" |
|
54 |
|
55 ifeq ($(OS_TARGET),Android) |
|
56 TEST_SHELL?=$$HOME/bin/sh |
|
57 ANDROID_PORT?="2222" |
|
58 #Define the subset of tests that is known to work on Android |
|
59 NSS_CYCLES?="standard pkix upgradedb sharedb" |
|
60 NSS_TESTS?="cipher lowhash libpkix cert dbtests tools sdr crmf smime ssl ocsp merge pkits chains" |
|
61 NSS_SSL_TESTS?="crl normal_normal iopr" |
|
62 NSS_SSL_RUN?="cov auth stress" |
|
63 else |
|
64 TEST_SHELL?="/bin/sh" |
|
65 endif |
|
66 |
|
67 # Create a package for test execution on a separate system. |
|
68 package_for_testing: |
|
69 echo "export OBJDIR=$(OBJDIR_NAME)" > $(PCFG) |
|
70 echo "export OS_ARCH=$(OS_ARCH)" >> $(PCFG) |
|
71 echo "export OS_TARGET=$(OS_TARGET)" >> $(PCFG) |
|
72 echo "export DLL_PREFIX=$(DLL_PREFIX)" >> $(PCFG) |
|
73 echo "export DLL_SUFFIX=$(DLL_SUFFIX)" >> $(PCFG) |
|
74 echo 'echo "set HOST and DOMSUF if your system is not registered in DNS"' > $(RTSH) |
|
75 cat $(PCFG) >> $(RTSH) |
|
76 echo 'export NSS_TESTS=$(NSS_TESTS)' >> $(RTSH) |
|
77 echo 'export NSS_SSL_TESTS=$(NSS_SSL_TESTS)' >> $(RTSH) |
|
78 echo 'export NSS_SSL_RUN=$(NSS_SSL_RUN)' >> $(RTSH) |
|
79 echo 'export NSS_CYCLES=$(NSS_CYCLES)' >> $(RTSH) |
|
80 echo 'export USE_64=$(USE_64)' >> $(RTSH) |
|
81 echo 'export BUILD_OPT=$(BUILD_OPT)' >> $(RTSH) |
|
82 echo 'export PKITS_DATA=$(PKITS_DATA)' >> $(RTSH) |
|
83 echo 'export NSS_DISABLE_ECC=$(NSS_DISABLE_ECC)' >> $(RTSH) |
|
84 echo 'export NSS_ECC_MORE_THAN_SUITE_B=$(NSS_ECC_MORE_THAN_SUITE_B)' >> $(RTSH) |
|
85 echo 'export NSPR_LOG_MODULES=$(NSPR_LOG_MODULES)' >> $(RTSH) |
|
86 ifeq ($(OS_TARGET),Android) |
|
87 # Android doesn't support FIPS tests, because |
|
88 # dladdr does not return a full path for implicitly loaded libraries |
|
89 echo "export NSS_TEST_DISABLE_FIPS=1" >> $(DIST)/platform.cfg |
|
90 endif |
|
91 ifeq ($(CROSS_COMPILE),1) |
|
92 # execute signing on test system |
|
93 echo 'export DIST=$${HOME}/nsstest/dist/' >> $(RTSH) |
|
94 echo 'export NSPR_LIB_DIR=$${DIST}/$${OBJDIR}/lib/' >> $(RTSH) |
|
95 echo 'echo "signing"' >> $(RTSH) |
|
96 # work around a bug in Android ash that has a corrupted work directory after login |
|
97 echo 'cd $${HOME}/nsstest' >> $(RTSH) |
|
98 echo 'cd nss/cmd/shlibsign' >> $(RTSH) |
|
99 echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}freebl3.$${DLL_SUFFIX}' >> $(RTSH) |
|
100 echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}softokn3.$${DLL_SUFFIX}' >> $(RTSH) |
|
101 echo '$(TEST_SHELL) ./sign.sh $${DIST}/$${OBJDIR}/ $${DIST}/$${OBJDIR}/bin $${OS_TARGET} $${NSPR_LIB_DIR} $${NSPR_LIB_DIR}$${DLL_PREFIX}nssdbm3.$${DLL_SUFFIX}' >> $(RTSH) |
|
102 ifneq ($(OS_TARGET),Android) |
|
103 # Android's ash doesn't support "export -n" yet |
|
104 echo 'export -n DIST' >> $(RTSH) |
|
105 echo 'export -n NSPR_LIB_DIR' >> $(RTSH) |
|
106 endif |
|
107 echo 'cd ../../../' >> $(RTSH) |
|
108 endif |
|
109 echo 'rm -rf tests_results' >> $(RTSH) |
|
110 echo 'echo "running tests"' >> $(RTSH) |
|
111 echo 'cd nss/tests' >> $(RTSH) |
|
112 # We require progress indication on stdout while running the tests (to avoid timeouts). |
|
113 set -o pipefail |
|
114 echo '$(TEST_SHELL) ./all.sh | tee ../../logfile 2>&1 |grep ": #"' >> $(RTSH) |
|
115 RETVAL=$? |
|
116 echo 'cd ../../' >> $(RTSH) |
|
117 # dump test summary from end of logfile |
|
118 echo 'echo "=========="; tail -100 logfile' >> $(RTSH) |
|
119 echo 'tar czf tests_results.tgz tests_results' >> $(RTSH) |
|
120 echo 'echo "created tests_results.tgz"' >> $(RTSH) |
|
121 echo 'echo "results are in directory: "`ls -1d tests_results/security/*.1`' >> $(RTSH) |
|
122 echo 'echo exit status: $${RETVAL}' >> $(RTSH) |
|
123 echo 'exit $${RETVAL}' >> $(RTSH) |
|
124 rm -f $(TESTPACKAGE) |
|
125 (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)" ) |
|
126 |
|
127 android_run_tests: |
|
128 ssh -p $(ANDROID_PORT) -o CheckHostIP=no $(ANDROID_ADDR) 'pwd; cd; pwd; cd nsstest; export PATH=$$HOME/bin:$$PATH ; $(TEST_SHELL) runtests.sh' |
|
129 |
|
130 android_install: |
|
131 rm -f $(DIST)/android.sftp |
|
132 echo '-mkdir nsstest' > $(DIST)/android.sftp |
|
133 echo '-rm nsstest/$(TESTPACKAGE)' >> $(DIST)/android.sftp |
|
134 echo 'progress' >> $(DIST)/android.sftp |
|
135 echo 'put $(DIST)/../$(TESTPACKAGE) nsstest' >> $(DIST)/android.sftp |
|
136 sftp -o Port=$(ANDROID_PORT) -o CheckHostIP=no -b $(DIST)/android.sftp $(ANDROID_ADDR) |
|
137 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)' |
|
138 |
|
139 WORKDIR="$(DIST)/../../" |
|
140 RESULTSPACKAGE=tests_results.tgz |
|
141 android_get_result: |
|
142 rm -f $(WORKDIR)/result.sftp $(WORKDIR)/$(RESULTSPACKAGE) |
|
143 echo "progress" > $(WORKDIR)/result.sftp |
|
144 echo 'get nsstest/$(RESULTSPACKAGE) $(WORKDIR)' >> $(WORKDIR)/result.sftp |
|
145 sftp -o Port=$(ANDROID_PORT) -o CheckHostIP=no -b $(WORKDIR)/result.sftp $(ANDROID_ADDR) |
|
146 (cd $(WORKDIR); tar xzf $(RESULTSPACKAGE); rm -f result.sftp $(RESULTSPACKAGE) ) |
|
147 |
|
148 # Android testing assumes having built with: OS_TARGET=Android CROSS_COMPILE=1 |
|
149 # Connectivity tested with Android app: SSHDroid |
|
150 # Provide appropriate ANDROID_ADDR variable, e.g.: |
|
151 # make test_android ANDROID_ADDR=root@192.168.4.5 |
|
152 # See also: https://wiki.mozilla.org/NSS:Android |
|
153 |
|
154 test_android: package_for_testing android_install android_run_tests android_get_result |