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 Feb 24, 2017
1 parent bd38965 commit 878c812
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 25 deletions.
5 changes: 3 additions & 2 deletions netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2164,9 +2164,10 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0"

// Unpack the corefx binaries
buildCommands += "tar -xf ./bin/build.tar.gz"
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
71 changes: 48 additions & 23 deletions tests/scripts/arm32_ci_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,39 @@ function run_tests {
EOF
}

function run_tests_using_docker {

# Configure docker
if [ "$__buildArch" == "arm" ]; then
case $__linuxCodeName in
trusty)
__dockerImage=" chcosta/dotnetcore:ubuntu1404_cross_prereqs_v1"
;;
xenial)
__dockerImage=" chcosta/dotnetcore:ubuntu1604_cross_prereqs_v1"
;;
*)
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_v2"
;;
*)
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"
__testCmd="./tests/scripts/arm32_ci_test.sh --abi=${__buildARch} --buildConfig=${__buildConfig}"

$__dockerCmd $__testCmd
}

#Define script variables
__ciMode="docker"
__ARMEmulRootfs=/mnt/arm-emulator-rootfs
Expand All @@ -370,7 +403,7 @@ __coreFxBinDir=
__testDirFile=
__verboseFlag=
__buildOS="Linux"
__buildArch="armel"
__buildArch="arm"
__linuxCodeName="tizen"
__skipRootFS=0
__buildDirName=
Expand Down Expand Up @@ -535,32 +568,24 @@ if [ $__skipTests == 1 ]; then
exit 0
fi

## 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
run_tests_using_docker
else
## Tests are going to be performed in an emulated environment

#Enter the emulated mode and run the tests
(set +x; echo 'Running tests...')
run_tests
#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

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

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

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


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 "--abit 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
DOCKER_HOME_DIR=/home/coreclr
__ROOTFS_DIR=${CORECLR_DIR}/cross/rootfs/${__abi}


# Mount
mkdir -p ${__ROOTFS_DIR}${DOCKER_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}${DOCKER_HOME_DIR}

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

echo "Done!"

0 comments on commit 878c812

Please sign in to comment.