Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[ARM/CI] Add ARM testing using Docker
Browse files Browse the repository at this point in the history
Signed-off-by: Hyung-Kyu Choi <hk0110.choi@samsung.com>
  • Loading branch information
hqueue committed Mar 10, 2017
1 parent 6287b0c commit 964fb7a
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 38 deletions.
44 changes: 44 additions & 0 deletions cross/armel/tizen/tizen-dotnet.ks
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
lang en_US.UTF-8
keyboard us
timezone --utc Asia/Seoul

part / --fstype="ext4" --size=3500 --ondisk=mmcblk0 --label rootfs --fsoptions=defaults,noatime

repo --name=mobile --baseurl=http://download.tizen.org/snapshots/tizen/mobile/latest/repos/arm-wayland/packages/ --ssl_verify=no
repo --name=base --baseurl=http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/packages/ --ssl_verify=no

%packages
tar
gzip

sed
grep
gawk
perl

binutils
findutils
util-linux
procps-ng
tzdata
ca-certificates

### Core FX
libicu
libuuid
libunwind
iputils
zlib
krb5
libcurl
libopenssl

%end

%post
### Update /tmp privilege
chmod 777 /tmp
####################################
%end
2 changes: 1 addition & 1 deletion netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
buildCommands += "mkdir ./bin/CoreFxBinDir"
buildCommands += "tar -xf ./bin/build.tar.gz -C ./bin/CoreFxBinDir"

// Call the ARM emulator build script to cross build and test using the ARM emulator rootfs
// Call the ARM CI script to cross build and test using Docker or ARM emulator
buildCommands += """./tests/scripts/arm32_ci_script.sh \\
--armel \\
--linuxCodeName=tizen \\
Expand Down
109 changes: 72 additions & 37 deletions tests/scripts/arm32_ci_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ function handle_exit {

echo 'The script is exited. Cleaning environment..'

clean_env
if [ "$__ciMode" == "emulator" ]; then
clean_env
fi
}
trap handle_exit EXIT

Expand Down Expand Up @@ -239,15 +241,20 @@ function cross_build_coreclr_with_docker {
__currentWorkingDirectory=`pwd`

# Check build configuration and choose Docker image
__dockerEnvironmentVariables=""
if [ "$__buildArch" == "arm" ]; then
# TODO: For arm, we are going to embed RootFS inside Docker image.
case $__linuxCodeName in
trusty)
__dockerImage=" chcosta/dotnetcore:ubuntu1404_cross_prereqs_v1"
__dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1404_cross_prereqs_v3"
__skipRootFS=1
__dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/arm"
__runtimeOS="ubuntu.14.04"
;;
xenial)
__dockerImage=" chcosta/dotnetcore:ubuntu1604_cross_prereqs_v1"
__dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1604_cross_prereqs_v3"
__skipRootFS=1
__dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/arm"
__runtimeOS="ubuntu.16.04"
;;
*)
Expand All @@ -258,7 +265,7 @@ function cross_build_coreclr_with_docker {
# For armel Tizen, we are going to construct RootFS on the fly.
case $__linuxCodeName in
tizen)
__dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v2"
__dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v3"
__runtimeOS="tizen.4.0.0"
;;
*)
Expand All @@ -269,7 +276,7 @@ function cross_build_coreclr_with_docker {
else
exit_with_error "ERROR: unknown buildArch $__buildArch" false
fi
__dockerCmd="sudo docker run --privileged -i --rm -v $__currentWorkingDirectory:/opt/code -w /opt/code $__dockerImage"
__dockerCmd="sudo docker run ${__dockerEnvironmentVariables} --privileged -i --rm -v $__currentWorkingDirectory:/opt/code -w /opt/code $__dockerImage"

if [ $__skipRootFS == 0 ]; then
# Build rootfs
Expand Down Expand Up @@ -355,14 +362,53 @@ function run_tests {
EOF
}

function run_tests_using_docker {
__currentWorkingDirectory=`pwd`

# Configure docker
__dockerEnvironmentVariables=""
if [ "$__buildArch" == "arm" ]; then
case $__linuxCodeName in
trusty)
__dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1404_cross_prereqs_v3"
__skipRootFS=1
__dockerEnvironmentVariables=" -e ROOTFS_DIR=/crossrootfs/arm"
;;
xenial)
__dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1604_cross_prereqs_v3"
__skipRootFS=1
__dockerEnvironmentVariables=" -e ROOTFS_DIR=/crossrootfs/arm"
;;
*)
exit_with_error "ERROR: $__linuxCodeName is not a supported linux name for $__buildArch" false
;;
esac
elif [ "$__buildArch" == "armel" ]; then
case $__linuxCodeName in
tizen)
__dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v3"
;;
*)
exit_with_error "ERROR: $__linuxCodeName is not a supported linux name for $__buildArch" false
;;
esac
else
exit_with_error "ERROR: unknown buildArch $__buildArch" false
fi
__dockerCmd="sudo docker run ${__dockerEnvironmentVariables} --privileged -i --rm -v $__currentWorkingDirectory:/opt/code -w /opt/code $__dockerImage"
__testCmd="./tests/scripts/arm32_ci_test.sh --abi=${__buildArch} --buildConfig=${__buildConfig}"

$__dockerCmd $__testCmd
}

#Define script variables
__ciMode="docker"
__ARMEmulRootfs=/mnt/arm-emulator-rootfs
__ARMEmulPath=
__ARMRootfsMountPath=
__buildConfig=
# TODO: Currently test is not working correctly for a month. This will be fixed with new arm CI soon.
__skipTests=1
__skipTests=0
__skipMscorlib=
__testRootDir=
__mscorlibDir=
Expand Down Expand Up @@ -458,20 +504,14 @@ if [ "$__ciMode" == "emulator" ]; then
exit_if_path_absent "$__ARMEmulPath/platform/rootfs-t30.ext4" "Path specified in --emulatorPath does not have the rootfs" false
fi

__coreFxBinDir="./bin/CoreFxBinDir" # TODO-clenup: Just for testing....
#Check if the optional arguments are present in the case that testing is to be done
if [ $__skipTests == 0 ]; then
exit_if_empty "$__testRootDir" "Testing requested, but --testRootDir not provided" true
exit_if_path_absent "$__testRootDir" "Path specified in --testRootDir does not exist" false

exit_if_empty "$__coreFxNativeBinDir" "Testing requested but --coreFxNativeBinDir not provided" true
exit_if_path_absent "$__coreFxNativeBinDir" "Path specified in --coreFxNativeBinDir does not exist" false

exit_if_empty "$__coreFxBinDir" "Testing requested, but --coreFxBinDir not provided" true
while IFS=';' read -ra coreFxBinDirectories; do
for currDir in "${coreFxBinDirectories[@]}"; do
exit_if_path_absent "$currDir" "Path specified in --coreFxBinDir, $currDir does not exist" false
done
done <<< "$__coreFxBinDir"
exit_if_path_absent "$__coreFxBinDir" "Path specified in --coreFxBinDir does not exist" false

exit_if_empty "$__testDirFile" "Testing requested, but --testDirFile not provided" true
exit_if_path_absent "$__testDirFile" "Path specified in --testDirFile does not exist" false
Expand Down Expand Up @@ -536,32 +576,27 @@ if [ $__skipTests == 1 ]; then
exit 0
fi

__unittestResult=0
## Begin CoreCLR test
if [ "$__ciMode" == "docker" ]; then
# Prepare emulator for test

#Mount the emulator
(set +x; echo 'Mounting emulator...')
mount_emulator

#Clean the emulator
(set +x; echo 'Cleaning emulator...')
clean_emulator
fi

## Tests are going to be performed in an emulated environment

#Copy the needed files to the emulator before entering the emulated environment
(set +x; echo 'Setting up emulator to run tests...')
copy_to_emulator

#Enter the emulated mode and run the tests
(set +x; echo 'Running tests...')
run_tests
run_tests_using_docker
__unittestResult=$?
else
## Tests are going to be performed in an emulated environment

#Copy the needed files to the emulator before entering the emulated environment
(set +x; echo 'Setting up emulator to run tests...')
copy_to_emulator

#Clean the environment
(set +x; echo 'Cleaning environment...')
clean_env
#Enter the emulated mode and run the tests
(set +x; echo 'Running tests...')
run_tests
__unittestResult=$?

#Clean the environment
(set +x; echo 'Cleaning environment...')
clean_env
fi

(set +x; echo 'Build and test complete')
exit $__unittestResult
123 changes: 123 additions & 0 deletions tests/scripts/arm32_ci_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash

set -x

function usage {
echo 'ARM Test Script'
echo '$ ./tests/scripts/arm32_ci_test.sh'
echo ' --abi=arm'
echo ' --buildConfig=Release'
echo 'Required Arguments:'
echo ' --abi=<abi> : arm (default) or armel'
echo ' --buildConfig=<config> : Release (default) or Debug'
}

# Display error message and exit
function exit_with_error {
set +x

local errorMessage="$1"
local printUsage=$2

echo "ERROR: $errorMessage"
if [ "$printUsage" == "true" ]; then
echo ''
usage
fi
exit 1
}

# Exit if the input path does not exist
function exit_if_path_absent {
local path="$1"
local errorMessage="$2"
local printUsage=$3

if [ ! -f "$path" -a ! -d "$path" ]; then
exit_with_error "$errorMessage" $printUsage
fi
}

__abi="arm"
__buildConfig="Release"

# Parse command line arguments
for arg in "$@"
do
case $arg in
--abi=*)
__abi=${arg#*=}
if [[ "$__abi" != "arm" && "$__abi" != "armel" ]]; then
exit_with_error "--abi can be either arm or armel" true
fi
;;
--buildConfig=*)
__buildConfig=${arg#*=}
if [[ "$__buildConfig" != "Debug" && "$__buildConfig" != "Release" ]]; then
exit_with_error "--buildConfig can be either Debug or Release" true
fi
;;
-v|--verbose)
__verboseFlag="verbose"
;;
-h|--help)
usage
exit 0
;;
*)
exit_with_error "$arg not a recognized argument" true
;;
esac
done
__buildDirName="Linux.${__abi}.${__buildConfig}"

CORECLR_DIR=/opt/code
ARM_CHROOT_HOME_DIR=/home/coreclr

if [ -z "${ROOTFS_DIR}" ]; then
__ROOTFS_DIR=${CORECLR_DIR}/cross/rootfs/${__abi}
else
__ROOTFS_DIR=${ROOTFS_DIR}
fi

if [ "$__abi" == "armel" ]; then
# TODO: Make use of a single Tizen rootfs for build and test

# TODO-cleanup: the latest docker image already has mic installed.
# Prepare Tizen (armel) environment
#echo "deb http://download.tizen.org/tools/latest-release/Ubuntu_14.04 /" >> /etc/apt/sources.list
#apt-get update
#apt-get -y -qq --force-yes install mic

pushd ${CORECLR_DIR}/cross/armel/tizen
mic --non-interactive create fs --pack-to=tizen.tar.gz tizen-dotnet.ks
if [ -d ${__ROOTFS_DIR} ]; then
mv ${__ROOTFS_DIR} ${__ROOTFS_DIR}_build
fi
mkdir -p ${__ROOTFS_DIR}
tar -zxf mic-output/tizen.tar.gz -C ${__ROOTFS_DIR}
#apt-get -y -qq --force-yes install --reinstall qemu binfmt-support qemu-user-static
__qemuARM=$(which qemu-arm-static)
cp $__qemuARM ${CORECLR_DIR}/cross/rootfs/armel/usr/bin/
cp $__qemuARM ${__ROOTFS_DIR}/usr/bin/
popd
fi

# Mount
mkdir -p ${__ROOTFS_DIR}${ARM_CHROOT_HOME_DIR}
mount -t proc /proc ${__ROOTFS_DIR}/proc
mount -o bind /dev ${__ROOTFS_DIR}/dev
mount -o bind /dev/pts ${__ROOTFS_DIR}/dev/pts
mount -o bind /sys ${__ROOTFS_DIR}/sys
mount -o bind ${CORECLR_DIR} ${__ROOTFS_DIR}${ARM_CHROOT_HOME_DIR}

chroot ${__ROOTFS_DIR} /bin/bash -x <<EOF
cd ${ARM_CHROOT_HOME_DIR}
./tests/runtest.sh --sequential\
--coreClrBinDir=${ARM_CHROOT_HOME_DIR}/bin/Product/${__buildDirName} \
--mscorlibDir=${ARM_CHROOT_HOME_DIR}/bin/Product/${__buildDirName} \
--testNativeBinDir=${ARM_CHROOT_HOME_DIR}/bin/obj/${__buildDirName}/tests \
--coreFxBinDir=${ARM_CHROOT_HOME_DIR}/bin/CoreFxBinDir \
--testRootDir=${ARM_CHROOT_HOME_DIR}/bin/tests/Windows_NT.x64.${__buildConfig} \
--testDirFile=${ARM_CHROOT_HOME_DIR}/tests/testsRunningInsideARM.txt
EOF

0 comments on commit 964fb7a

Please sign in to comment.