summaryrefslogtreecommitdiff
path: root/57-run-CTS-soraka.sh
blob: d315cc5578ea74bc84da4fe4916175c2ba64dca2 (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
#!/bin/bash

# SPDX-License-Identifier: GPL-2.0-or-later
#
# CTS Test runner
#
# This is a highly specific test to compile CTS in a pre-prepared CrOS-SDK with
# a pre-installed soraka-libcamera target.

CROS=/home/kbingham/iob/libcamera/chromeos
CROS_CTS=$CROS/CTS/libcamera-cts
CROS_CTS_RESULTS=$CROS_CTS/results/
CROS_LIBCAMERA=$CROS/src/third_party/libcamera

source ./common.sh

if [ ! -d $CROS_CTS ] ;
then
	echo " [CTS] This test is highly customised to run on Kieran's Build Server"
	echo " [CTS] Feel free to adapt if possible but otherwise this will skip..."
	exit 0
fi

echo "Commencing CTS run" > $logfile

kill_target() {
	TARGET="$1"

	ssh $TARGET -C \
		"stop cros-camera; \
		 killall cros_camera_service; \
		 killall provider@2.4-service"
}

prepare_target() {
	TARGET="$1"

	# HACK: Clear space on our target.
	# Cros deploy's don't clear up after themselves,
	# so we'll do it here.
	ssh $TARGET -C "rm -rf /usr/local/tmp/cros-deploy/tmp.*"
	echo "Cleaned up cros deploy"

	echo "Killing targets"
	kill_target "$TARGET"

	echo "Restarting cros-camera-service remotely..."
	sleep 1;
	ssh $TARGET -n -C \
		"ulimit -c unlimited; \
		 killall -9 cros_camera_service; \
		 cros_camera_service" 2>&1 >> $logfile &
	sleep 1;	
}

run_cts() {
	pushd $CROS_CTS

	echo "Waiting before saving prior crash results"
	sleep 10;

	echo "Saving any prior crash results"

	## Clear out any previous crash results
	./save-crash-reports.sh ./results/crash/

	echo "Prior crash reports saved: About to run CTS in docker"
	sleep 10;

	./run-in-docker libcamera-cts ./run-cts.sh
	#./run-in-docker libcamera-cts ./run-cts.sh "android.hardware.camera2.cts.NativeStillCaptureTest#testStillCapture"
	#./run-in-docker libcamera-cts ./run-cts.sh android.hardware.cts.CameraTest
	pass_fail $? "Run cts"

	./save-cts-results.sh
	#//rsync fails? Check me // pass_fail $? "Save CTS Results"

	popd
}


## Reset logging
echo "" > $logfile

echo "Preparing target..."
prepare_target soraka >> $logfile
echo "Target prepared"

## Something /after/ here causes a SIGSTOP
echo "Launching CTS..."
( run_cts ) >> $logfile

echo "Cleaning up after CTS..."
# cleanup and close for logfiles after completion of CTS
kill_target soraka >> $logfile

## Let everything settle after that...
sleep 1;

# Save our current log file to the results
VERSION=$(libcamera_version "$CROS_LIBCAMERA")
LATEST=$(basename $(readlink -f $CROS_CTS_RESULTS/$VERSION/latest))

if [ -d $CROS_CTS_RESULTS/$VERSION/ ];
then
	cp $logfile $CROS_CTS_RESULTS/$VERSION/
	cp $logfile $CROS_CTS_RESULTS/$VERSION/$LATEST/
fi

sync

report_results() {
	grep "ModuleListener: .* fail:" $logfile
	grep "Invocation finished" $logfile
	echo "Results at https://results.uk.libcamera.org/$VERSION/$LATEST"
}

report_results
#report_results | ./notify.sh

RESULT_LINE=`grep "Invocation finished" $logfile`
./notify.sh "$RESULT_LINE \n\n Results at https://results.uk.libcamera.org/$VERSION/$LATEST"

## Validate there are no failures in the log
## This is not ... complete ;-)
grep ", FAILED: 0, MODULES" $logfile
pass_fail $? "Verify there are no failures"