Bug 1385061 - Build NSPR tests with NSS make; Add gyp parameters to build/run NSPR tests. r=jcj
authorKai Engert <kaie@kuix.de>
Fri, 13 Sep 2019 00:30:37 +0200
changeset 15289 8b4a226f7d23c8499e58d890b5c3c9001e4366c8
parent 15288 1fe61aadaf5795a3bb09f2a444484108f158dc78
child 15290 f28f3d7b7cf01fc63cf0a4c5f32a84b78cd524b0
push id3496
push userkaie@kuix.de
push dateThu, 12 Sep 2019 22:30:44 +0000
reviewersjcj
bugs1385061
Bug 1385061 - Build NSPR tests with NSS make; Add gyp parameters to build/run NSPR tests. r=jcj
Makefile
build.sh
coreconf/nspr.sh
help.txt
--- a/Makefile
+++ b/Makefile
@@ -130,16 +130,17 @@ else
 	cd $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) ; \
 	$(NSPR_CONFIGURE_ENV) sh ../configure \
 	$(NSPR_CONFIGURE_OPTS) \
 	--prefix='$(NSS_GYP_PREFIX)'
 endif
 
 build_nspr: $(NSPR_CONFIG_STATUS)
 	$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)
+	$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)/pr/tests
 
 install_nspr: build_nspr
 	$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) install
 
 clobber_nspr: $(NSPR_CONFIG_STATUS)
 	$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) clobber
 
 build_docs:
--- a/build.sh
+++ b/build.sh
@@ -49,16 +49,19 @@ if [ -n "$CCC" ] && [ -z "$CXX" ]; then
     export CXX="$CCC"
 fi
 
 opt_build=0
 build_64=0
 clean=0
 rebuild_gyp=0
 rebuild_nspr=0
+build_nspr_tests=0
+run_nspr_tests=0
+exit_after_nspr=0
 target=Debug
 verbose=0
 fuzz=0
 fuzz_tls=0
 fuzz_oss=0
 no_local_nspr=0
 sslkeylogfile=1
 
@@ -112,16 +115,19 @@ while [ $# -gt 0 ]; do
         --fuzz=tls) fuzz=1; fuzz_tls=1 ;;
         --sancov) enable_sancov ;;
         --sancov=?*) enable_sancov "${1#*=}" ;;
         --emit-llvm) gyp_params+=(-Demit_llvm=1 -Dsign_libs=0) ;;
         --no-zdefs) gyp_params+=(-Dno_zdefs=1) ;;
         --static) gyp_params+=(-Dstatic_libs=1) ;;
         --ct-verif) gyp_params+=(-Dct_verif=1) ;;
         --nspr) nspr_clean; rebuild_nspr=1 ;;
+        --nspr-test-build) build_nspr_tests=1 ;;
+        --nspr-test-run) run_nspr_tests=1 ;;
+        --nspr-only) exit_after_nspr=1 ;;
         --with-nspr=?*) set_nspr_path "${1#*=}"; no_local_nspr=1 ;;
         --system-nspr) set_nspr_path "/usr/include/nspr/:"; no_local_nspr=1 ;;
         --system-sqlite) gyp_params+=(-Duse_system_sqlite=1) ;;
         --enable-fips) gyp_params+=(-Ddisable_fips=0) ;;
         --enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;;
         --mozpkix-only) gyp_params+=(-Dmozpkix_only=1 -Ddisable_tests=1 -Dsign_libs=0) ;;
         --disable-keylog) sslkeylogfile=0 ;;
         -D*) gyp_params+=("$1") ;;
@@ -220,16 +226,21 @@ for i in "${all_args[@]}"; do echo "$i";
 
 # Build.
 # NSPR.
 if [[ "$rebuild_nspr" = 1 && "$no_local_nspr" = 0 ]]; then
     nspr_clean
     nspr_build
     mv -f "$nspr_config.new" "$nspr_config"
 fi
+
+if [ "$exit_after_nspr" = 1 ]; then
+  exit 0
+fi
+
 # gyp.
 if [ "$rebuild_gyp" = 1 ]; then
     if ! hash "$GYP" 2> /dev/null; then
         echo "Building NSS requires an installation of gyp: https://gyp.gsrc.io/" 1>&2
         exit 3
     fi
     # These extra arguments aren't used in determining whether to rebuild.
     obj_dir="$dist_dir/$target"
--- a/coreconf/nspr.sh
+++ b/coreconf/nspr.sh
@@ -31,25 +31,40 @@ nspr_build()
     extra_params=(--prefix="$dist_dir"/$target)
     if [ "$opt_build" = 1 ]; then
         extra_params+=(--disable-debug --enable-optimize)
     fi
     if [ "$target_arch" = "x64" ]; then
         extra_params+=(--enable-64bit)
     fi
 
-    echo "NSPR [1/3] configure ..."
+    echo "NSPR [1/5] configure ..."
     pushd "$nspr_dir" >/dev/null
     CFLAGS="$nspr_cflags" CXXFLAGS="$nspr_cxxflags" \
           LDFLAGS="$nspr_ldflags" CC="$CC" CXX="$CCC" \
           run_verbose ../configure "${extra_params[@]}" "$@"
     popd >/dev/null
-    echo "NSPR [2/3] make ..."
+    echo "NSPR [2/5] make ..."
     run_verbose make -C "$nspr_dir"
-    echo "NSPR [3/3] install ..."
+
+    if [ "$build_nspr_tests" = 1 ]; then
+      echo "NSPR [3/5] build tests ..."
+      run_verbose make -C "$nspr_dir/pr/tests"
+    else
+        echo "NSPR [3/5] NOT building tests"
+    fi
+
+    if [[ "$build_nspr_tests" = 1 && "$run_nspr_tests" = 1 ]]; then
+      echo "NSPR [4/5] run tests ..."
+      run_verbose make -C "$nspr_dir/pr/tests" runtests
+    else
+        echo "NSPR [4/5] NOT running tests"
+    fi
+
+    echo "NSPR [5/5] install ..."
     run_verbose make -C "$nspr_dir" install
 }
 
 nspr_clean()
 {
     rm -rf "$cwd"/../nspr/$target
 }
 
--- a/help.txt
+++ b/help.txt
@@ -38,16 +38,19 @@ NSS build tool options:
     --sancov         do sanitize coverage builds
                      --sancov=func sets coverage to function level for example
     --emit-llvm      emit LLVM bitcode while building
                      (requires the gold linker, use clang-3.8 for SAW)
     --no-zdefs       don't set -Wl,-z,defs
     --static         create static libraries and use static linking
     --ct-verif       build with valgrind for ct-verif
     --nspr           force a rebuild of NSPR
+    --nspr-test-build when building NSPR also build its tests
+    --nspr-test-run  when building NSPR tests also run its tests
+    --nspr-only      exit after building NSPR
     --with-nspr      use the NSPR build at the given locations
                      --with-nspr=<include>:<lib> sets include and lib paths
     --system-nspr    attempt to use system nspr
                      shorthand for --with-nspr=/usr/include/nspr:
     --system-sqlite  use system sqlite
     --enable-fips    enable FIPS checks
     --enable-libpkix make libpkix part of the build
     --mozpkix-only   build only static mozpkix and mozpkix-test libraries