Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / buildbot / buildbot_pnacl.sh
index 155fa52..1b97221 100755 (executable)
@@ -29,6 +29,8 @@ RETCODE=0
 readonly SCONS_EVERYTHING=""
 readonly SCONS_S_M="small_tests medium_tests"
 readonly SCONS_S_M_IRT="small_tests_irt medium_tests_irt"
+# TODO(mseaborn): Enable more tests for Non-SFI Mode when they pass.
+readonly SCONS_NONSFI="nonsfi_nacl=1 run_hello_world_test_irt"
 # subset of tests used on toolchain builders
 readonly SCONS_TC_TESTS="small_tests medium_tests"
 
@@ -52,15 +54,16 @@ setup-goma() {
 }
 
 tc-clobber() {
-  local label=$1
-  local clobber_translators=$2
+  local toolchain_dir=$1
+  local toolchain_name=$2
+  local clobber_translators=$3
 
   echo @@@BUILD_STEP tc_clobber@@@
-  rm -rf toolchain/${label}
-  rm -rf toolchain/test-log
+  rm -rf ${toolchain_dir}/${toolchain_name}
+  rm -rf ${toolchain_dir}/test-log
   rm -rf pnacl*.tgz pnacl/pnacl*.tgz
   if ${clobber_translators} ; then
-      rm -rf toolchain/pnacl_translator
+      rm -rf ${toolchain_dir}/pnacl_translator
   fi
 }
 
@@ -102,15 +105,14 @@ tc-compile-toolchain() {
 }
 
 tc-untar-toolchain() {
-  local label=$1
+  local toolchain_dir=$1
+  local toolchain_name=$2
   echo @@@BUILD_STEP untar_toolchain@@@
   # Untar to ensure we can and to place the toolchain where the main build
   # expects it to be.
-  rm -rf toolchain/${label}
-  mkdir -p toolchain/${label}
-  pushd toolchain/${label}
-  tar xfz ../../pnacl-toolchain.tgz
-  popd
+  rm -rf ${toolchain_dir}/${toolchain_name}
+  mkdir -p ${toolchain_dir}/${toolchain_name}
+  tar xfz pnacl-toolchain.tgz -C "${toolchain_dir}/${toolchain_name}"
 }
 
 tc-build-translator() {
@@ -124,15 +126,15 @@ tc-archive() {
   echo @@@BUILD_STEP archive_toolchain@@@
   ${UP_DOWN_LOAD} UploadToolchainTarball ${BUILDBOT_GOT_REVISION} \
     ${label} pnacl-toolchain.tgz
-}
 
-tc-archive-translator-pexes() {
-  echo @@@BUILD_STEP archive_translator_pexe@@@
-  # NOTE: the build script needs an absolute pathname
-  local tarball="$(pwd)/pnacl-translator-pexe.tar.bz2"
-  ${PNACL_BUILD} translator-archive-pexes ${tarball}
-  ${UP_DOWN_LOAD} UploadArchivedPexesTranslator \
-      ${BUILDBOT_GOT_REVISION} ${tarball}
+  echo @@@BUILD_STEP upload_pnacl_toolchain_package_info@@@
+  ${NATIVE_PYTHON} build/package_version/package_version.py archive \
+      --archive-package=pnacl_newlib \
+      pnacl-toolchain.tgz@https://storage.googleapis.com/nativeclient-archive2/toolchain/${BUILDBOT_GOT_REVISION}/naclsdk_${label}.tgz
+
+   ${NATIVE_PYTHON} build/package_version/package_version.py --annotate \
+     --cloud-bucket nativeclient-archive2/pnacl_buildsh upload \
+     --upload-package=pnacl_newlib --revision=${BUILDBOT_GOT_REVISION}
 }
 
 tc-prune-translator-pexes() {
@@ -145,12 +147,22 @@ tc-archive-translator() {
   ${PNACL_BUILD} translator-tarball pnacl-translator.tgz
   ${UP_DOWN_LOAD} UploadToolchainTarball ${BUILDBOT_GOT_REVISION} \
       pnacl_translator pnacl-translator.tgz
+
+  echo @@@BUILD_STEP upload_translator_package_info@@@
+  ${NATIVE_PYTHON} build/package_version/package_version.py archive \
+      --archive-package=pnacl_translator \
+      pnacl-translator.tgz@https://storage.googleapis.com/nativeclient-archive2/toolchain/${BUILDBOT_GOT_REVISION}/naclsdk_pnacl_translator.tgz
+
+  ${NATIVE_PYTHON} build/package_version/package_version.py --annotate upload \
+      --upload-package=pnacl_translator --revision=${BUILDBOT_GOT_REVISION}
 }
 
 tc-build-all() {
-  local label=$1
-  local is_try=$2
-  local build_translator=$3
+  local toolchain_dir=$1
+  local toolchain_name=$2
+  local label=$3
+  local is_try=$4
+  local build_translator=$5
 
   # Tell build.sh and test.sh that we're a bot.
   export PNACL_BUILDBOT=true
@@ -158,18 +170,18 @@ tc-build-all() {
   export PNACL_PRUNE=true
 
   clobber
-  tc-clobber ${label} ${build_translator}
+  tc-clobber ${toolchain_dir} ${toolchain_name} ${build_translator}
 
   # Run checkdeps so that the PNaCl toolchain trybots catch mistakes
   # that would cause the normal NaCl bots to fail.
   echo "@@@BUILD_STEP checkdeps @@@"
-  python tools/checkdeps/checkdeps.py
+  ${NATIVE_PYTHON} tools/checkdeps/checkdeps.py
 
   tc-show-config
   # For now only linux64 (which also builds the translator) builds a fat
   # toolchain, so just use build_translator to control fat toolchain build
   tc-compile-toolchain ${build_translator}
-  tc-untar-toolchain ${label}
+  tc-untar-toolchain ${toolchain_dir} ${toolchain_name}
   if ! ${is_try} ; then
     tc-archive ${label}
   fi
@@ -178,7 +190,6 @@ tc-build-all() {
   if ${build_translator} ; then
     tc-build-translator
     if ! ${is_try} ; then
-      tc-archive-translator-pexes
       tc-prune-translator-pexes
       tc-archive-translator
     fi
@@ -298,7 +309,7 @@ gyp-arm-build() {
   if [ "${BUILD_MODE_HOST}" = "DEBUG" ] ; then
       gypmode="Debug"
   fi
-  local toolchain_dir=native_client/toolchain/linux_arm-trusted
+  local toolchain_dir=native_client/toolchain/linux_x86/arm_trusted
   local extra="-isystem ${toolchain_dir}/usr/include \
                -Wl,-rpath-link=${toolchain_dir}/lib/arm-linux-gnueabi \
                -L${toolchain_dir}/lib \
@@ -309,9 +320,9 @@ gyp-arm-build() {
 
   export AR=arm-linux-gnueabi-ar
   export AS=arm-linux-gnueabi-as
-  export CC="arm-linux-gnueabi-gcc-4.5 ${extra} "
-  export CXX="arm-linux-gnueabi-g++-4.5 ${extra} "
-  export LD="arm-linux-gnueabi-g++-4.5 ${extra} "
+  export CC="arm-linux-gnueabi-gcc ${extra} "
+  export CXX="arm-linux-gnueabi-g++ ${extra} "
+  export LD="arm-linux-gnueabi-g++ ${extra} "
   export RANLIB=arm-linux-gnueabi-ranlib
   export SYSROOT
   export GYP_DEFINES="target_arch=arm \
@@ -418,6 +429,9 @@ mode-buildbot-arm() {
     "${qemuflags} use_sandboxed_translator=1 translate_fast=1 \
        translate_in_build_step=0" \
     "toolchain_tests"
+
+  # Test Non-SFI Mode.
+  scons-stage-irt "arm" "${qemuflags}" "${SCONS_NONSFI}"
 }
 
 mode-buildbot-arm-hw() {
@@ -439,6 +453,9 @@ mode-buildbot-arm-hw() {
     "${hwflags} use_sandboxed_translator=1 translate_fast=1 \
        translate_in_build_step=0" \
     "toolchain_tests"
+
+  # Test Non-SFI Mode.
+  scons-stage-irt "arm" "${hwflags}" "${SCONS_NONSFI}"
 }
 
 mode-trybot-qemu() {
@@ -459,6 +476,9 @@ mode-trybot-qemu() {
 
   # non-pexe tests
   scons-stage-noirt "arm" "${qemuflags} pnacl_generate_pexe=0" "nonpexe_tests"
+
+  # Test Non-SFI Mode.
+  scons-stage-irt "arm" "${qemuflags}" "${SCONS_NONSFI}"
 }
 
 mode-buildbot-arm-dbg() {
@@ -499,7 +519,7 @@ mode-buildbot-arm-hw-try() {
 tc-tests-all() {
   local is_try=$1
 
-  local label="pnaclsdk_mode=custom:toolchain/${PNACL_TOOLCHAIN_LABEL}"
+  local label="pnacl_newlib_dir=toolchain/${PNACL_TOOLCHAIN_DIR}"
   local scons_flags="-k skip_trusted_tests=1 -j8 ${label}"
 
   llvm-regression
@@ -532,12 +552,20 @@ tc-tests-all() {
     "${scons_flags} use_sandboxed_translator=1 translate_fast=1" \
     "run_hello_world_test"
 
+  # Test Non-SFI Mode.
+  scons-stage-irt "x86-32" "${scons_flags}" "${SCONS_NONSFI}"
+  scons-stage-irt "arm" "${scons_flags}" "${SCONS_NONSFI}"
+
   # Run the GCC torture tests just for x86-32.  Testing a single
   # architecture gives good coverage without taking too long.  We
   # don't test x86-64 here because some of the torture tests fail on
   # the x86-64 toolchain trybot (though not the buildbots, apparently
   # due to a hardware difference:
   # https://code.google.com/p/nativeclient/issues/detail?id=3697).
+  # Build the SDK libs first so that linking will succeed.
+  echo "@@@BUILD_STEP sdk libs @@@"
+  ${PNACL_BUILD} sdk
+
   echo "@@@BUILD_STEP torture_tests x86-32 @@@"
   tools/toolchain_tester/torture_test.py pnacl x86-32 --verbose \
       --concurrency=8 || handle-error
@@ -561,35 +589,22 @@ mode-buildbot-tc-x8664-linux() {
   setup-goma
   local is_try=$1
   FAIL_FAST=false
+  export PNACL_TOOLCHAIN_DIR=linux_x86/pnacl_newlib
   export PNACL_TOOLCHAIN_LABEL=pnacl_linux_x86
-  tc-build-all ${PNACL_TOOLCHAIN_LABEL} ${is_try} true
+  tc-build-all toolchain/linux_x86 pnacl_newlib \
+      ${PNACL_TOOLCHAIN_LABEL} ${is_try} true
   HOST_ARCH=x86_64 tc-tests-all ${is_try}
 }
 
-test-nonsfi-mode() {
-  echo "@@@BUILD_STEP test translating for nonsfi mode@@@"
-  # Test that translation produces an executable without giving an
-  # error.  We can't run the resulting Non-SFI Mode nexe yet because
-  # there is no standalone loader for such nexes that is available in
-  # the NaCl build.
-  # TODO(mseaborn): Move some of Chromium's
-  # components/nacl/loader/nonsfi/ to the NaCl repo so that we can
-  # test this here.
-  local out_dir=scons-out/nacl_irt_test-x86-32-pnacl-pexe-clang
-  local pexe_path=${out_dir}/obj/tests/hello_world/hello_world.final.pexe
-  ./scons -j8 bitcode=1 --mode=nacl,nacl_irt_test ${pexe_path}
-  toolchain/pnacl_linux_x86/bin/pnacl-translate -arch x86-32-nonsfi \
-      ${pexe_path} -o /tmp/hellow.nexe
-  rm /tmp/hellow.nexe
-}
-
 mode-buildbot-tc-x8632-linux() {
   setup-goma
   local is_try=$1
   FAIL_FAST=false
+  export PNACL_TOOLCHAIN_DIR=linux_x86/pnacl_newlib
   export PNACL_TOOLCHAIN_LABEL=pnacl_linux_x86
   # For now, just use this bot to test a pure 32 bit build but don't upload
-  tc-build-all ${PNACL_TOOLCHAIN_LABEL} true false
+  tc-build-all toolchain/linux_x86 pnacl_newlib \
+      ${PNACL_TOOLCHAIN_LABEL} true false
   HOST_ARCH=x86_32 tc-tests-fast "x86-32"
 
   echo "@@@BUILD_STEP test unsandboxed mode@@@"
@@ -604,27 +619,40 @@ mode-buildbot-tc-x8632-linux() {
     run_malloc_realloc_calloc_free_test_irt \
     run_dup_test_irt \
     run_cond_timedwait_test_irt \
-    run_syscall_test_irt
+    run_syscall_test_irt \
+    run_getpid_test_irt
 
-  test-nonsfi-mode
+  # Test Non-SFI Mode.
+  scons-stage-irt "x86-32" "-j8 -k" "${SCONS_NONSFI}"
 }
 
 mode-buildbot-tc-x8632-mac() {
   local is_try=$1
   FAIL_FAST=false
+  export PNACL_TOOLCHAIN_DIR=mac_x86/pnacl_newlib
   export PNACL_TOOLCHAIN_LABEL=pnacl_mac_x86
+  tc-build-all toolchain/mac_x86 pnacl_newlib \
+      ${PNACL_TOOLCHAIN_LABEL} ${is_try} false
   # We can't test ARM because we do not have QEMU for Mac.
-  # We can't test X86-64 because NaCl X86-64 Mac support is not in good shape.
-  tc-build-all ${PNACL_TOOLCHAIN_LABEL} ${is_try} false
-  HOST_ARCH=x86_32 tc-tests-fast "x86-32"
+  HOST_ARCH=x86_64 tc-tests-fast "x86-32"
+  HOST_ARCH=x86_64 tc-tests-fast "x86-64"
+
+  echo "@@@BUILD_STEP test unsandboxed mode@@@"
+  # Test translation to an unsandboxed executable.
+  # TODO(mseaborn): Use the same test list as on Linux when the
+  # threading tests pass for Mac.
+  ./scons bitcode=1 pnacl_unsandboxed=1 \
+    --mode=nacl_irt_test platform=x86-32 -j8 run_hello_world_test_irt
 }
 
 mode-buildbot-tc-x8664-win() {
   local is_try=$1
   FAIL_FAST=false
   # NOTE: this is a 64bit bot but the TC generated is 32bit
+  export PNACL_TOOLCHAIN_DIR=win_x86_pnacl/pnacl_newlib
   export PNACL_TOOLCHAIN_LABEL=pnacl_win_x86
-  tc-build-all ${PNACL_TOOLCHAIN_LABEL} ${is_try} false
+  tc-build-all toolchain/win_x86_pnacl pnacl_newlib \
+      ${PNACL_TOOLCHAIN_LABEL} ${is_try} false
 
   # We can't test ARM because we do not have QEMU for Win.
   HOST_ARCH=x86_32 tc-tests-fast "x86-64"
@@ -632,66 +660,6 @@ mode-buildbot-tc-x8664-win() {
 
 
 
-mode-test-all() {
-  test-all-newlib "$@"
-  test-all-glibc "$@"
-}
-
-# NOTE: clobber and toolchain setup to be done manually, since this is for
-# testing a locally built toolchain.
-# This runs tests concurrently, so may be more difficult to parse logs.
-test-all-newlib() {
-  local concur=$1
-
-  # turn verbose mode off
-  set +o xtrace
-
-  llvm-regression
-  ${DRIVER_TESTS} --platform=x86-32
-  ${DRIVER_TESTS} --platform=x86-64
-  ${DRIVER_TESTS} --platform=arm
-
-  # At least clobber scons-out before building and running the tests though.
-  echo "@@@BUILD_STEP clobber@@@"
-  rm -rf scons-out
-
-  # First build everything.
-  echo "@@@BUILD_STEP scons build @@@"
-  local scons_flags="skip_trusted_tests=1 -j${concur}"
-  scons-stage-noirt "arm"    "${scons_flags}" "${SCONS_EVERYTHING}"
-  scons-stage-noirt "x86-32" "${scons_flags}" "${SCONS_EVERYTHING}"
-  scons-stage-noirt "x86-64" "${scons_flags}" "${SCONS_EVERYTHING}"
-  # Then run the tests. smoke_tests can be run in parallel but not large_tests
-  echo "@@@BUILD_STEP scons smoke_tests @@@"
-  scons-stage-noirt "arm"    "${scons_flags}" "smoke_tests"
-  scons-stage-noirt "arm"    "${scons_flags} -j1" "large_tests"
-  scons-stage-noirt "x86-32" "${scons_flags}" "smoke_tests"
-  scons-stage-noirt "x86-32"    "${scons_flags} -j1" "large_tests"
-  scons-stage-noirt "x86-64" "${scons_flags}" "smoke_tests"
-  scons-stage-noirt "x86-64"    "${scons_flags} -j1" "large_tests"
-  # Do some sandboxed translator tests as well.
-  scons-stage-irt "x86-32" "${scons_flags} use_sandboxed_translator=1" \
-    "toolchain_tests"
-  scons-stage-irt "x86-32" \
-    "${scons_flags} use_sandboxed_translator=1 translate_fast=1" \
-    "toolchain_tests"
-  scons-stage-irt "x86-64" "${scons_flags} use_sandboxed_translator=1" \
-    "toolchain_tests"
-  scons-stage-irt "x86-64" \
-    "${scons_flags} use_sandboxed_translator=1 translate_fast=1" \
-    "toolchain_tests"
-  # Smaller set of sbtc tests for ARM because qemu is flaky.
-  scons-stage-irt "arm" "${scons_flags} use_sandboxed_translator=1" \
-    "run_hello_world_test"
-  scons-stage-irt "arm" \
-    "${scons_flags} use_sandboxed_translator=1 translate_fast=1" \
-    "run_hello_world_test"
-}
-
-test-all-glibc() {
-  echo "TODO(pdox): Add GlibC tests"
-}
-
 ######################################################################
 # On Windows, this script is invoked from a batch file.
 # The inherited PWD environmental variable is a Windows-style path.