Skip to content

Commit 33d159a

Browse files
committed
add script to monitor test-images directory for new test images
When new test images are added to the directory, jobs are automatically submitted to LAVA using the template corresponding to the device type. The templates are stored under 'job-templates/lava_<device-type>.job. Usage: ./monitor-images.sh <your LAVA identity> The script is automatically run when running 'make all'. Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
1 parent e326f75 commit 33d159a

File tree

7 files changed

+142
-1
lines changed

7 files changed

+142
-1
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ LAVA_IDENTITY = dispatcher
88

99

1010
all:
11+
contrib/monitor-images.sh $(LAVA_IDENTITY) &
1112
sudo contrib/udev-forward.py -i lava-dispatcher &
1213
docker-compose up
1314

1415
stop:
16+
pkill -f monitor-images.sh
1517
-sudo pkill udev-forward.py
1618
docker-compose stop
1719

1820
clean:
21+
pkill -f monitor-images.sh
1922
-sudo pkill udev-forward.py
2023
docker-compose rm -vsf
2124
docker volume rm -f lava-server-pgdata lava-server-joboutput lava-server-devices lava-server-health-checks

contrib/monitor-images.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Usage: ./monitor-images.sh <your LAVA identity>
4+
#
5+
# This script monitors the 'test-images' directory for any file that is
6+
# dropped into it. It assumes the directory layout is
7+
# test-images/<device-type>, and upon detecting a new file, uses the
8+
# corresponding job template in job-templates/lava_<device-type>.job
9+
# to submit the job with the provided LAVA identity.
10+
#
11+
# '<test_image>' in the template is automatically substituted with the
12+
# actual path to the test image.
13+
14+
contrib_dir=`dirname $0`
15+
dir=test-images
16+
template_dir=job-templates
17+
18+
cd $contrib_dir/..
19+
20+
inotifywait -r -m "$dir" -e close_write --format '%w%f' |
21+
while IFS=' ' read -r fname
22+
do
23+
IFS='/'
24+
read -ra path <<< "$fname"
25+
template="$template_dir"/lava_"${path[1]}".job
26+
if [ ! -f "$template" ]
27+
then
28+
#if no template found for the device-type, do nothing
29+
continue
30+
fi
31+
32+
echo "Using template for device type ${path[1]}:"
33+
echo " $template"
34+
35+
# Replace <test_image> with actual path to test image
36+
sed_cmd=s/\<test_image\>/"file:\/\/\/${fname//\//\\\/}"/g
37+
38+
tmp_file=$(mktemp)
39+
echo "Submitting job for $fname"
40+
[ -f "$fname" ] && sed "$sed_cmd" "$template" > "$tmp_file" && lavacli -i $1 jobs submit "$tmp_file" && rm "$tmp_file"
41+
done

example/lava.job

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ actions:
2121
to: tmpfs
2222
images:
2323
zephyr:
24-
url: 'file:///test-images/frdm_k64f/logging.log_list/zephyr.bin'
24+
url: 'file:///test-images/frdm-k64f/logging.log_list/zephyr.bin'
2525

2626
- boot:
2727
method: cmsis-dap

job-templates/lava_cc3220SF.job

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Standard job template for zephyr tests on cc3220sf_launchxl
2+
device_type: 'cc3220SF'
3+
job_name: 'zephyr-upstream tests-zephyr-cc3220SF'
4+
5+
timeouts:
6+
job:
7+
minutes: 3
8+
action:
9+
minutes: 3
10+
actions:
11+
wait-usb-device:
12+
seconds: 40
13+
14+
priority: medium
15+
visibility: public
16+
17+
actions:
18+
- deploy:
19+
timeout:
20+
minutes: 3
21+
to: tmpfs
22+
images:
23+
binary:
24+
url: <test_image>
25+
26+
- boot:
27+
method: openocd
28+
timeout:
29+
minutes: 1
30+
31+
- test:
32+
timeout:
33+
minutes: 2
34+
monitors:
35+
- name: 'tests-zephyr-cc3220SF'
36+
start: (tc_start\(\)|starting .*test|BOOTING ZEPHYR OS)
37+
end: PROJECT EXECUTION
38+
pattern: (?P<result>(PASS|FAIL))\s-\s(?P<test_case_id>\w+)\r\n
39+
fixupdict:
40+
PASS: pass
41+
FAIL: fail
42+
43+
metadata:
44+
zephyr-gcc-variant: zephyr
45+
platform: cc3220sf_launchxl
46+
git-url: https://git.linaro.org/zephyrproject-org/zephyr.git
47+

job-templates/lava_frdm-k64f.job

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Zephyr JOB definition for frdm-k64f
2+
device_type: 'frdm-k64f'
3+
job_name: 'zephyr-upstream tests-subsys-logging-log_list-logging-log_list-zephyr'
4+
5+
timeouts:
6+
job:
7+
minutes: 3
8+
action:
9+
minutes: 3
10+
actions:
11+
wait-usb-device:
12+
seconds: 40
13+
14+
priority: medium
15+
visibility: public
16+
17+
actions:
18+
- deploy:
19+
timeout:
20+
minutes: 3
21+
to: tmpfs
22+
images:
23+
zephyr:
24+
url: <test_image>
25+
26+
- boot:
27+
method: cmsis-dap
28+
timeout:
29+
minutes: 1
30+
31+
- test:
32+
timeout:
33+
minutes: 2
34+
monitors:
35+
- name: 'tests-subsys-logging-log_list-logging-log_list-zephyr'
36+
start: (tc_start\(\)|starting .*test|BOOTING ZEPHYR OS)
37+
end: PROJECT EXECUTION
38+
pattern: (?P<result>(PASS|FAIL))\s-\s(?P<test_case_id>\w+)\r\n
39+
fixupdict:
40+
PASS: pass
41+
FAIL: fail
42+
43+
metadata:
44+
build-url: https://ci.linaro.org/job/zephyr-upstream/PLATFORM=frdm_k64f,ZEPHYR_TOOLCHAIN_VARIANT=zephyr,label=docker-xenial-amd64-13/3708/
45+
build-log: https://ci.linaro.org/job/zephyr-upstream/PLATFORM=frdm_k64f,ZEPHYR_TOOLCHAIN_VARIANT=zephyr,label=docker-xenial-amd64-13/3708//consoleText
46+
zephyr-gcc-variant: zephyr
47+
platform: frdm_k64f
48+
git-url: https://git.linaro.org/zephyrproject-org/zephyr.git
49+
git-commit: 193fb971
50+
559 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)