Skip to content

Commit

Permalink
Changes for using Orin zipped images
Browse files Browse the repository at this point in the history
Changes for using zipped Orin images to flash
HW test device.

Signed-off-by: Ville-Pekka Juntunen <[email protected]>
  • Loading branch information
vjuntunen committed Oct 10, 2023
1 parent e75a366 commit aaa349d
Showing 1 changed file with 140 additions and 125 deletions.
265 changes: 140 additions & 125 deletions Jenkinsfiles/hw_test_set
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bootJob = ''
batJob = ''
resultsDirectory = ''
configPath = ''
zipImagePath = ''
bootSuite = 'boot_test.robot'
batSuite = './'
deviceName = ''
Expand All @@ -19,141 +20,155 @@ usbDrive = 'PSSD'
pipeline {
agent { label "${params.label}" }
stages {
stage('Set variables') {
steps {
script {
resultsDirectory = "${params.device}_test_results"
def splitted = "${JOB_NAME}".split('/')
bootJob = "${splitted[0]}/Testing/boot_test"
batJob = "${splitted[0]}/Testing/smoke_tests"
configPath = "/home/${params.label}/Jenkins-agent/workspace/${splitted[0]}/Testing/test_config.json"
stage('Set variables') {
steps {
script {
resultsDirectory = "${params.device}_test_results"
def splitted = "${JOB_NAME}".split('/')
bootJob = "${splitted[0]}/Testing/boot_test"
batJob = "${splitted[0]}/Testing/smoke_tests"
configPath = "/home/${params.label}/Jenkins-agent/workspace/${splitted[0]}/Testing/test_config.json"

// Check for which agent and which target device
if ("${params.label}" == "tc-agent02"){
if (params.device == "orin-agx"){
deviceName = 'OrinAGX1'
} else if (params.device == "nuc"){
deviceName = 'NUC1'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX1'
}
} else if ("${params.label}" == "tc-agent03"){
if (params.device == "orin-agx"){
deviceName = 'OrinAGX2'
} else if (params.device == "nuc"){
deviceName = 'NUC2'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX2'
}
}
echo "DEVICE: ${deviceName}"
// Check for which agent and which target device
if ("${params.label}" == "tc-agent02"){
if (params.device == "orin-agx"){
deviceName = 'OrinAGX1'
} else if (params.device == "nuc"){
deviceName = 'NUC1'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX1'
}
} else if ("${params.label}" == "tc-agent03"){
if (params.device == "orin-agx"){
deviceName = 'OrinAGX2'
} else if (params.device == "nuc"){
deviceName = 'NUC2'
} else if (params.device == "orin-nx"){
deviceName = 'OrinNX2'
}
}
echo "DEVICE: ${deviceName}"

// Set pipeline description
currentBuild.description = "${params.server} ${params.device} BuildID: ${params.buildID}"
// Set pipeline description
currentBuild.description = "${params.server} ${params.device} BuildID: ${params.buildID}"

// Read test devices configfile and set usbHub serial to use right device
def deviceData = readJSON file: "${configPath}"
usbHubSerial = "${deviceData['addresses']["${deviceName}"]['usbhub_serial']}"
println("USB HUB serial: ${usbHubSerial}")
// Read test devices configfile and set usbHub serial to use right device
def deviceData = readJSON file: "${configPath}"
usbHubSerial = "${deviceData['addresses']["${deviceName}"]['usbhub_serial']}"
println("USB HUB serial: ${usbHubSerial}")

}
}
}
stage('Change USB HUB host to PC') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s ${usbHubSerial}"
if (params.device == "orin-nx" || params.device == "orin-agx") {
// Read zipped image file path from buildID.json to flash usb drive for Orin device
def buildData = readJSON file: "/home/${params.label}/Jenkins-agent/workspace/${splitted[0]}/hydra_copy/${params.buildID}.json"
zipImagePath = "${buildData['Image']}"
println("zipped path: ${zipImagePath}")
}
}
}
}
stage('Change USB HUB host to PC') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 0 -s ${usbHubSerial}"

// wait that USB drive is mounted
sh 'sleep 10'
def output = sh (
// Check for usb drive that is connected to target test device
script: "lsblk -o model,name |grep ${usbDrive}",
returnStdout: true
).trim()
def list = output.split(' ')
// wait that USB drive is mounted
sh 'sleep 10'
def output = sh (
// Check for usb drive that is connected to target test device
script: "lsblk -o model,name |grep ${usbDrive}",
returnStdout: true
).trim()
def list = output.split(' ')

// Take last element which is the target USB device
USBDEVICE = list[-1]
println("USB device: ${USBDEVICE}")
}
}
}
stage('Write OS image to USB disk') {
steps {
script{
println("${params.image}")
sh "sudo dd if=${params.image} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync"
}
}
}
stage('Change USB HUB host back to test device') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s ${usbHubSerial}"
}
}
}
stage('Boot Test') {
steps {
script{
// Make directory for test results
sh "mkdir -p ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot"
build = build(
job: "${bootJob}", propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${bootSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"]
]
)
// Take last element which is the target USB device
USBDEVICE = list[-1]
println("USB device: ${USBDEVICE}")
}
}
}
stage('Write OS image to USB disk') {
steps {
script{
println("${params.image}")
if (params.device == "orin-nx" || params.device == "orin-agx") {
// unzip zipped image, remove .zst ending from path and use that for flashing usb drive. Remove unzipped image after flashing.
sh "sudo zstd -d ${zipImagePath}"
unzippedPath = zipImagePath.minus(".zst")
sh "sudo dd if=${unzippedPath} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync"
sh "sudo rm -rf ${unzippedPath}"
} else {
sh "sudo dd if=${params.image} of=/dev/${USBDEVICE} bs=1M status=progress conv=fsync"
}
}
}
}
stage('Change USB HUB host back to test device') {
steps {
script{
sh "./BrainStem_dev_kit/bin/AcronameHubCLI -u 1 -s ${usbHubSerial}"
}
}
}
stage('Boot Test') {
steps {
script{
// Make directory for test results
sh "mkdir -p ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot"
build = build(
job: "${bootJob}", propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${bootSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"]
]
)

// copy report and log
sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/report.html"
sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/log.html"
if(build.result == "SUCCESS") {
buildResults."boot" = "SUCCESS"
echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD"
} else {
catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){
error("Boot build failed")
// copy report and log
sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/report.html"
sh "cp ~/Jenkins-agent/workspace/${bootJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/boot/log.html"
if(build.result == "SUCCESS") {
buildResults."boot" = "SUCCESS"
echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD"
} else {
catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){
error("Boot build failed")
}
}
}
}
}
}
}
stage('BAT tests') {
when {
expression {
buildResults.boot == 'SUCCESS'
}
stage('BAT tests') {
when {
expression {
buildResults.boot == 'SUCCESS'
}
}
}
steps {
script{
// Make directory for test results
sh "mkdir ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat"
build = build(
job: "${batJob}", propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${batSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"],
[$class: 'StringParameterValue', name: 'INCLD_TAG', value: "${params.device}"]
]
)
// copy report and log
sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/report.html"
sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/log.html"
if(build.result == "SUCCESS") {
buildResults."bat" = "SUCCESS"
echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD"
} else {
catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){
error("BAT build failed")
steps {
script{
// Make directory for test results
sh "mkdir ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat"
build = build(
job: "${batJob}", propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${batSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"],
[$class: 'StringParameterValue', name: 'INCLD_TAG', value: "${params.device}"]
]
)
// copy report and log
sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/report.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/report.html"
sh "cp ~/Jenkins-agent/workspace/${batJob}/Robot-Framework/test-suites/log.html ${params.resultsPath}/${params.buildID}/${resultsDirectory}/bat/log.html"
if(build.result == "SUCCESS") {
buildResults."bat" = "SUCCESS"
echo "BUILD NUMBER: ${build.number} SUCCESSFULLY BUILD"
} else {
catchError(stageResult: 'FAILURE', buildResult: 'FAILURE'){
error("BAT build failed")
}
}
}
}
}
}
}
}
}
}
}

0 comments on commit aaa349d

Please sign in to comment.