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

Commit

Permalink
[WIP] ARM CI 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 Feb 22, 2017
1 parent d4ad328 commit bd38965
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 13 deletions.
2 changes: 2 additions & 0 deletions netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,8 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR

// Call the ARM emulator build script to cross build and test using the ARM emulator rootfs
buildCommands += """./tests/scripts/arm32_ci_script.sh \\
--armel \\
--linuxCodeName=tizen \\
--emulatorPath=${armemul_path} \\
--mountPath=${armrootfs_mountpath} \\
--buildConfig=${lowerConfiguration} \\
Expand Down
123 changes: 110 additions & 13 deletions tests/scripts/arm32_ci_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function usage {
echo ' --buildConfig=<config> : The value of config should be either Debug or Release'
echo ' Any other value is not accepted'
echo 'Optional Arguments:'
echo ' --mode=<mode> : docker (default) or emulator'
echo ' --arm : Build using hard ABI'
echo ' --armel : Build using softfp ABI (default)'
echo ' --linuxCodeName=<name> : Code name for Linux: For arm, trusty (default) and xenial. For armel, tizen'
echo ' --skipRootFS : Skip building rootfs'
echo ' --skipTests : Presenting this option skips testing the generated binaries'
echo ' If this option is not presented, then tests are run by default'
echo ' using the other test related options'
Expand Down Expand Up @@ -229,6 +234,59 @@ function cross_build_coreclr {
fi
}

#Cross builds coreclr using Docker
function cross_build_coreclr_with_docker {
__currentWorkingDirectory=`pwd`

# Check build configuration and choose Docker image
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"
__runtimeOS="ubuntu.14.04"
;;
xenial)
__dockerImage=" chcosta/dotnetcore:ubuntu1604_cross_prereqs_v1"
__runtimeOS="ubuntu.16.04"
;;
*)
exit_with_error "ERROR: $__linuxCodeName is not a supported linux name for $__buildArch" false
;;
esac
elif [ "$__buildArch" == "armel" ]; then
# For armel Tizen, we are going to construct RootFS on the fly.
case $__linuxCodeName in
tizen)
__dockerImage=" t2wish/dotnetcore:ubuntu1404_cross_prereqs_v2"
__runtimeOS="tizen.4.0.0"
;;
*)
echo "ERROR: $__linuxCodeName is not a supported linux name for $__buildArch"
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 --privileged -i --rm -v $__currentWorkingDirectory:/opt/code -w /opt/code $__dockerImage"

if [ $__skipRootFS == 0 ]; then
# Build rootfs
__buildRootfsCmd="./cross/build-rootfs.sh $__buildArch $__linuxCodeName --skipunmount"

(set +x; echo "Build RootFS for $__buildArch $__linuxCodeName")
$__dockerCmd $__buildRootfsCmd
sudo chown -R $(id -u -n) cross/rootfs
fi

# Cross building coreclr with rootfs in Docker
(set +x; echo "Start cross build coreclr for $__buildArch $__linuxCodeName")
__buildCmd="./build.sh $__buildArch cross $__verboseFlag $__skipMscorlib $__buildConfig -rebuild"
$__dockerCmd $__buildCmd
sudo chown -R $(id -u -n) ./bin
}

#Copy the needed files to the emulator to run tests
function copy_to_emulator {

Expand Down Expand Up @@ -298,6 +356,7 @@ EOF
}

#Define script variables
__ciMode="docker"
__ARMEmulRootfs=/mnt/arm-emulator-rootfs
__ARMEmulPath=
__ARMRootfsMountPath=
Expand All @@ -312,6 +371,8 @@ __testDirFile=
__verboseFlag=
__buildOS="Linux"
__buildArch="armel"
__linuxCodeName="tizen"
__skipRootFS=0
__buildDirName=
__initialGitHead=`git rev-parse --verify HEAD`

Expand All @@ -331,6 +392,9 @@ do
exit_with_error "--buildConfig can be only Debug or Release" true
fi
;;
--mode=*)
__ciMode=${arg#*=}
;;
--skipTests)
__skipTests=1
;;
Expand All @@ -355,6 +419,19 @@ do
--testDirFile=*)
__testDirFile=${arg#*=}
;;
--arm)
__buildArch="arm"
;;
--armel)
__buildArch="armel"
__linuxCodeName="tizen"
;;
--linuxCodeName=*)
__linuxCodeName=${arg#*=}
;;
--skipRootFS)
__skipRootFS=1
;;
-h|--help)
usage
;;
Expand All @@ -372,11 +449,13 @@ if [[ $(git status -s) != "" ]]; then
exit 1
fi

#Check if the compulsory arguments have been presented to the script and if the input paths exist
exit_if_empty "$__ARMEmulPath" "--emulatorPath is a mandatory argument, not provided" true
exit_if_empty "$__ARMRootfsMountPath" "--mountPath is a mandatory argument, not provided" true
exit_if_empty "$__buildConfig" "--buildConfig is a mandatory argument, not provided" true
exit_if_path_absent "$__ARMEmulPath/platform/rootfs-t30.ext4" "Path specified in --emulatorPath does not have the rootfs" false
if [ "$__ciMode" == "emulator" ]; then
#Check if the compulsory arguments have been presented to the script and if the input paths exist
exit_if_empty "$__ARMEmulPath" "--emulatorPath is a mandatory argument, not provided" true
exit_if_empty "$__ARMRootfsMountPath" "--mountPath is a mandatory argument, not provided" true
exit_if_path_absent "$__ARMEmulPath/platform/rootfs-t30.ext4" "Path specified in --emulatorPath does not have the rootfs" false
fi

#Check if the optional arguments are present in the case that testing is to be done
if [ $__skipTests == 0 ]; then
Expand Down Expand Up @@ -433,23 +512,41 @@ set -e
## Begin cross build
(set +x; echo "Git HEAD @ $__initialGitHead")

#Mount the emulator
(set +x; echo 'Mounting emulator...')
mount_emulator
if [ "$__ciMode" == "docker" ]; then
# Complete the cross build using Docker
(set +x; echo 'Building coreclr...')
cross_build_coreclr_with_docker
else
#Mount the emulator
(set +x; echo 'Mounting emulator...')
mount_emulator

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

#Complete the cross build
(set +x; echo 'Building coreclr...')
cross_build_coreclr
#Complete the cross build
(set +x; echo 'Building coreclr...')
cross_build_coreclr
fi

#If tests are to be skipped end the script here, else continue
if [ $__skipTests == 1 ]; then
exit 0
fi

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
Expand Down

0 comments on commit bd38965

Please sign in to comment.