aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-agl-run-test-prepare.sh
blob: 4ab5fd08e67c803614c5964a66630a46bd7bbb7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# (c) 2016 Jan-Simon Moeller dl9pf(at)gmx.de
# License GPLv2

################################################################################
## Run SHORT CI test
################################################################################
#set -x

cd $REPODIR

# clone repo for templates and related utils, add to $PATH for later use
if [ ! -e releng-scripts ]; then
    git clone --branch $TARGETBRANCH https://git.automotivelinux.org/AGL/releng-scripts
else
    (cd releng-scripts; git remote update; git checkout -f origin/$TARGETBRANCH)
fi

if [ -e releng-scripts/utils ]; then
    export PATH=$PATH:$PWD/releng-scripts/utils
    RELENG=$PWD/releng-scripts
fi

#gen board info in $BOARDOUT
gen_info() {
	if [ -z "${lava_device}" -o -z "${releng_device}" ]; then
		echo "Board not supported: $MACHINE"
		return 1
	fi

	CREATE_ARGS=""
	CREATE_ARGS+="--machine ${releng_device} "

	if [[ $TARGETBRANCH ]] && [[ x"master" != x"$TARGETBRANCH" ]] ; then
		CREATE_ARGS+="--branch $TARGETBRANCH "
	fi

	# If it's a release build
	if [[ $RELEASE_BRANCH ]] && [[ $RELEASE_VERSION ]]; then
		CREATE_ARGS+="--build-type release $RELEASE_BRANCH $RELEASE_VERSION "
	fi
	# If it's a CI build
	if [[ $GERRIT_CHANGE_NUMBER ]] && [[ $GERRIT_PATCHSET_NUMBER ]]; then
		CREATE_ARGS+="--build-type ci $GERRIT_CHANGE_NUMBER $GERRIT_PATCHSET_NUMBER "
	fi

	$RELENG/utils/job-prereq.py ${CREATE_ARGS}
	if [ $? -ne 0 ]; then
		echo "Board not supported by releng-scripts: job-prereq.py"
		return 1
	fi
	# First call to job-prereq suceeded, other should suceed as they use the same args.
	export DEVICE_DTB=`$RELENG/utils/job-prereq.py ${CREATE_ARGS} --dtb`
	export DEVICE_KERNEL=`$RELENG/utils/job-prereq.py ${CREATE_ARGS} --kernel`
	export DEVICE_INITRAMFS=`$RELENG/utils/job-prereq.py ${CREATE_ARGS} --initrd`
	export DEVICE_NBDROOT=`$RELENG/utils/job-prereq.py ${CREATE_ARGS} --nbdroot`
	# thoses variables (DEVICE_DTB DEVICE_KERNEL DEVICE_INITRAMFS DEVICE_NBDROOT) are only used for copying artifacts later

	# We use both lava_device and releng_device for handling name collision (like qemu)
	BDIRNAME="$lava_device-$releng_device"
	mkdir -p $BOARDOUT/$BDIRNAME

	echo "DEVICE_DTB=$DEVICE_DTB" > $BOARDOUT/$BDIRNAME/info
	echo "DEVICE_KERNEL=$DEVICE_KERNEL" >> $BOARDOUT/$BDIRNAME/info
	echo "DEVICE_INITRAMFS=$DEVICE_INITRAMFS" >> $BOARDOUT/$BDIRNAME/info
	echo "DEVICE_NBDROOT=$DEVICE_NBDROOT" >> $BOARDOUT/$BDIRNAME/info
	# thoses two variable are only for debugging
	echo "x_releng_device=$releng_device" >> $BOARDOUT/$BDIRNAME/info
	echo "x_lava_device=$lava_device" >> $BOARDOUT/$BDIRNAME/info
	return 0
}

# WARNING: we need gen_info in last, the device of the current JENKINS CIBT
# example: for x86, the JENKINS CIBT job is for "qemu" and produce artifacts for all x86 boards.
# so we need to gen_info for qemux86 and upsquare, this content will be used to copy artifacts just after.
# but the LAVA job need to be generated only for qemu. So we need to have lava_device and releng_device for it.
export BOARDOUT=$(mktemp --directory)
case $MACHINE in
qemux86-64)
	lava_device=upsquare
	releng_device=upsquare
	gen_info || exit 0
	# qemu-x86-64 must be the latest
	lava_device=qemu
	releng_device=qemux86-64
	gen_info || exit 0
;;
raspberrypi4)
	lava_device=bcm2711-rpi-4-b
	releng_device=raspberrypi4
	gen_info || exit 0
;;
qemuarm)
	lava_device=qemu
	releng_device=qemuarm
	gen_info || exit 0
;;
qemuarm64)
	lava_device=qemu
	releng_device=qemuarm64
	gen_info || exit 0
;;
h3ulcb-nogfx)
	if test x"master" = x"${TARGETBRANCH}" ; then
	lava_device=r8a7795-agl-refhw
	releng_device=r8a7795-agl-refhw
	gen_info || exit 0
	fi
	# h3ulcf-kf must be the latest
	lava_device=r8a7795-h3ulcb-kf
	releng_device=h3ulcb-kf
	gen_info || exit 0
;;
r8a7795-agl-refhw)
	lava_device=r8a7795-agl-refhw
	releng_device=r8a7795-agl-refhw
	gen_info || exit 0
;;
upsquare)
	lava_device=upsquare
	releng_device=upsquare
	# NO gen_info since, we use artifacts of the qemux86_64 CIBT
;;
*)
	echo "ERROR: unknown machine $MACHINE"
	exit 0
;;
esac

# echo NEXT is rsync
#exit 0