unit-tests.sh 17.2 KB
Newer Older
1 2
#!/bin/bash
# Display commands and their arguments as they are executed.
Dafna Hirschfeld's avatar
fixes  
Dafna Hirschfeld committed
3
# set -x
4 5 6 7 8 9

# we set all links to be enabled and immutable
# therefore, when streaming we should make sure that
# so, if trying to stream the sensor capture, we should
# still make sure that also the formats in all other links match

10 11
source ./functions.sh

12 13 14 15 16 17 18
VIDSCA=/dev/video2
VIDSEN=/dev/video1
VIDDEB=/dev/video0
STRM_CNT=10
# generates the v4l-ctl streaming output "<<<<<<" ...
STRM_OUT=$(printf '<%.0s' `seq $STRM_CNT`)

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
19
echo 15 > /proc/sys/kernel/printk
20 21

test_idx=1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
22

23 24 25 26
function stream_should_not_success {
	v4l2-ctl --stream-mmap --stream-count=$1 -d $2
	out=$(v4l2-ctl --stream-mmap --stream-count=$1 -d $2 2>&1)
	out="${out//[^<]}"
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
27
	if [ "$out" == $STRM_OUT ]; then echo "streaming DID NOT fail (it should have)"; exit; fi
28 29 30 31 32 33 34 35 36
}

function stream_should_success {
	v4l2-ctl --stream-mmap --stream-count=$1 -d $2
	out=$(v4l2-ctl --stream-mmap --stream-count=$1 -d $2 2>&1)
	out="${out//[^<]}"
	if [ "$out" != $STRM_OUT ]; then echo "streaming sen failed $out"; exit; fi
}

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
37 38
function test1 {

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
39
reinstall_vimc
40
simple_topo mdev || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
41

42
echo "===================================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
43
echo "Test 1: make sure that the deivce can be plugged and all captures can stream"
44 45 46
echo "===================================================================================="
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
47 48
media-ctl -d0 --print-dot > vmpath/simple.dot
media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple.ps
49 50

configure_all_formats
51 52 53
stream_should_success $STRM_CNT $VIDSEN
stream_should_success $STRM_CNT $VIDDEB
stream_should_success $STRM_CNT $VIDSCA
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
54
}
55

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
56
function test2 {
57 58 59
reinstall_vimc
simple_topo mdev || exit 1
echo "==============================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
60
echo "Test 2: make sure setting the type works"
61 62 63
echo "==============================================================================="
((test_idx++))
#should not succeed
64 65
echo off > "/configfs/vimc/mdev/vimc-debayer:deb/sink:0/sen-to-deb/type" || exit 1
if [ 'd' != $(head -c 1 "/configfs/vimc/mdev/vimc-debayer:deb/sink:0/sen-to-deb/type") ]; then exit; fi;
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
66 67
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
68
media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple-test${test_idx}-d.ps
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
69
configure_all_formats
70
stream_should_not_success $STRM_CNT $VIDSCA
71

72 73
echo on > "/configfs/vimc/mdev/vimc-debayer:deb/sink:0/sen-to-deb/type" || exit 1
if [ 'e' != $(head -c 1 "/configfs/vimc/mdev/vimc-debayer:deb/sink:0/sen-to-deb/type") ]; then exit; fi;
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
74 75
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
76
media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple-test${test_idx}-e.ps
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
77
configure_all_formats
78
stream_should_success $STRM_CNT $VIDDEB
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
79
}
80

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
81
function test3 {
82 83 84
reinstall_vimc
simple_topo mdev || exit 1
echo "=========================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
85
echo "Test 3: make sure no two entities with the same name is allowed"
86 87 88 89 90 91
echo "=========================================================================="
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
mkdir "/configfs/vimc/mdev/vimc-scaler:sen" && exit 1
mkdir "/configfs/vimc/mdev/vimc-capture:deb" && exit 1
mkdir "/configfs/vimc/mdev/vimc-sensor:cap-sen" && exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
92
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
93
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
94 95
}
function test4 () {
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
96
reinstall_vimc
97
simple_topo mdev || exit 1
98
echo "=========================================================================="
99
echo "Test 4: make sure it is impossible to remove the scaler and the sensor (since they are linked)"
100 101 102
echo "=========================================================================="
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
103
rmdir "/configfs/vimc/mdev/vimc-scaler:sca" && exit 1
104
rmdir "/configfs/vimc/mdev/vimc-sensor:sen" && exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
105
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
106
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
107 108
}
function test5 {
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
109
reinstall_vimc
110
simple_topo mdev || exit 1
111
echo "=========================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
112
echo "Test 5: remove the two links [debayer -> scaler],[scaler->vimc-cpature] and the scaler"
113 114 115 116
echo "and make sure that the cap-sca can't be streamed and that the the other captures can"
echo "=========================================================================="
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
117 118 119
rm /configfs/vimc/mdev/vimc-debayer:deb/source:1/deb-to-sca || exit 1
rm /configfs/vimc/mdev/vimc-scaler:sca/source:1/sca-to-cap || exit 1
rmdir /configfs/vimc/mdev/vimc-scaler:sca/sink:0/* || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
120
rmdir "/configfs/vimc/mdev/vimc-scaler:sca" || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
121
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
122 123
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
configure_all_formats
124 125 126
stream_should_success $STRM_CNT $VIDDEB
stream_should_success $STRM_CNT $VIDSEN
stream_should_not_success $STRM_CNT $VIDSCA
127

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
128 129
}
function test6 {
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
130
reinstall_vimc
131
simple_topo mdev || exit 1
132
echo "=========================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
133
echo "Test 6: remove the scaler and its links and create it again and make"
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
134
echo "sure the device can be plugged and stream"
135 136 137
echo "=========================================================================="
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
138 139 140 141
rm /configfs/vimc/mdev/vimc-debayer:deb/source:1/deb-to-sca || exit 1
rm /configfs/vimc/mdev/vimc-scaler:sca/source:1/sca-to-cap || exit 1
rmdir /configfs/vimc/mdev/vimc-scaler:sca/sink:0/* || exit 1
rmdir "/configfs/vimc/mdev/vimc-scaler:sca" || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
142

143 144 145 146
mkdir /configfs/vimc/mdev/vimc-scaler:sca/
mkdir /configfs/vimc/mdev/vimc-scaler:sca/sink:0/deb-to-sca || exit 1
ln -s /configfs/vimc/mdev/vimc-scaler:sca/sink:0/deb-to-sca /configfs/vimc/mdev/vimc-debayer:deb/source:1/deb-to-sca
echo on > /configfs/vimc/mdev/vimc-scaler:sca/sink:0/deb-to-sca/type
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
147

148 149
ln -s /configfs/vimc/mdev/vimc-capture:cap-sca/sink:0/sca-to-cap /configfs/vimc/mdev/vimc-scaler:sca/source:1/sca-to-cap
echo on > /configfs/vimc/mdev/vimc-capture:cap-sca/sink:0/sca-to-cap/type
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
150

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
151
echo 0 > /configfs/vimc/mdev/hotplug || exit 1
152 153
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
configure_all_formats
154 155 156
stream_should_success $STRM_CNT $VIDSEN
stream_should_success $STRM_CNT $VIDDEB
stream_should_success $STRM_CNT $VIDSCA
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
157
}
158

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
159
function test7 {
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
160
reinstall_vimc
161
simple_topo mdev || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
162
echo "==============================================================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
163
echo "Test 7: create two simple devices and make sure that they can both be loaded and upstreamed together"
164
echo "and also that it is impossible to link entities between them."
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
165
echo "==============================================================================="
166 167
((test_idx++))
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
168
simpler_topo mdev2 || exit 1
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
169
echo 1 > /configfs/vimc/mdev2/hotplug || exit 1
170
configure_all_formats
171
configure_all_formats_simpler
172 173 174 175 176 177
media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple0-test${test_idx}.ps
media-ctl -d1 --print-dot | dot -Tps -o vmpath/simple1-test${test_idx}.ps
stream_should_success $STRM_CNT $VIDSEN
stream_should_success $STRM_CNT $VIDDEB
stream_should_success $STRM_CNT $VIDSCA
stream_should_success $STRM_CNT /dev/video3
178 179 180 181 182
mkdir /configfs/vimc/mdev2/vimc-capture:cap/sink:0/deb-from-mdev
ln -s /configfs/vimc/mdev2/vimc-capture:cap/sink:0/deb-from-mdev /configfs/vimc/mdev/vimc-debayer:deb/source:1/ && exit 1
mkdir /configfs/vimc/mdev/vimc-capture:cap-sen/sink:0/sen-from-mdev2
ln -s /configfs/vimc/mdev/vimc-capture:cap-sen/sink:0/sen-from-mdev2 /configfs/vimc/mdev2/vimc-sensor:sen/source:0/ && exit 1

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
183 184 185 186 187 188 189 190 191
}

function test8 {
reinstall_vimc
simple_topo mdev || exit 1
echo "============================================="
echo "Test 8: unregister the device while streaming"
echo "============================================="
echo 1 > /configfs/vimc/mdev/hotplug || exit 1
192 193
media-ctl -d0 --print-dot > vmpath/simple.dot
media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple.ps
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
194 195 196

configure_all_formats
v4l2-ctl --stream-mmap --stream-count=1000 -d $VIDSEN &
197
sleep 2
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
198 199 200
echo 0 > /configfs/vimc/mdev/hotplug
}

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

function test9 {
	reinstall_vimc
	simple_topo mdev || exit 1
	echo "============================================="
	echo " change the device while streaming"
	echo "============================================="
	echo 1 > /configfs/vimc/mdev/hotplug || exit 1
	media-ctl -d0 --print-dot > vmpath/simple.dot
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/simple.ps

	configure_all_formats
	v4l2-ctl --stream-mmap --stream-count=1000 -d $VIDSEN &
	sleep 2
	mkdir "/configfs/vimc/mdev/vimc-sensor:new-sen" || exit 1
	mkdir "/configfs/vimc/$DEV/vimc-debayer:deb/sink:0/new-sen-to-deb"
	echo off > "/configfs/vimc/$DEV/vimc-debayer:deb/sink:0/sen-to-deb/type"
	ln -s "/configfs/vimc/$DEV/vimc-debayer:deb/sink:0/new-sen-to-deb" "/configfs/vimc/$DEV/vimc-sensor:new-sen/source:0"
	echo 0 > /configfs/vimc/mdev/hotplug
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot > vmpath/test9.dot
	rm  vmpath/test9.ps
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test9.ps
}

226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
function test10 {
	reinstall_vimc
	simple_topo mdev || exit 1
	echo "============================================="
	echo "connect two debayers"
	echo "============================================="
	mkdir "/configfs/vimc/mdev/vimc-debayer:new-deb" || exit 1
	mkdir "/configfs/vimc/$DEV/vimc-debayer:new-deb/sink:0/deb-to-new-deb"
	echo on > "/configfs/vimc/$DEV/vimc-debayer:new-deb/sink:0/deb-to-new-deb/type"
	ln -s "/configfs/vimc/$DEV/vimc-debayer:new-deb/sink:0/deb-to-new-deb" "/configfs/vimc/$DEV/vimc-debayer:deb/source:1"
	mkdir "/configfs/vimc/$DEV/vimc-capture:cap-deb/sink:0/new-deb-to-cap"
	ln -s "/configfs/vimc/$DEV/vimc-capture:cap-deb/sink:0/new-deb-to-cap" "/configfs/vimc/$DEV/vimc-debayer:new-deb/source:1"
	echo off > "/configfs/vimc/$DEV/vimc-capture:cap-deb/sink:0/deb-to-cap/type"
	echo on > "/configfs/vimc/$DEV/vimc-capture:cap-deb/sink:0/new-deb-to-cap/type"
	rm  vmpath/test10.ps
	find /configfs -name "*sca*" -type l -delete
	find /configfs -name "*sca*" -type d -delete
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test10.ps
	configure_all_formats
}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
247

248 249 250 251 252 253 254 255 256
function link {
	from=$1
	ftype=$2
	fpad=$3
	to=$4
	ttype=$5
	tpad=$6
	ltype=$7
	mkdir "/configfs/vimc/$DEV/${ttype}:${to}/sink:${tpad}/${from}-to-${to}"
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
257
	echo $ltype > "/configfs/vimc/$DEV/${ttype}:${to}/sink:${tpad}/${from}-to-${to}/type"
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
	ln -s "/configfs/vimc/$DEV/${ttype}:${to}/sink:${tpad}/${from}-to-${to}" "/configfs/vimc/$DEV/${ftype}:${from}/source:${fpad}"
}
function test11 {
	reinstall_vimc
	#simpler_topo mdev || exit 1
	echo "============================================="
	echo "connenct two scalers"
	echo "============================================="

	DEV=mdev
	mkdir "/configfs/vimc/$DEV" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-sensor:sen" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-debayer:deb" || exit 1
	link sen vimc-sensor 0 deb vimc-debayer 0 on

	mkdir "/configfs/vimc/mdev/vimc-scaler:sca1" || exit 1
	link deb vimc-debayer 1 sca1 vimc-scaler 0 on

	mkdir "/configfs/vimc/mdev/vimc-scaler:sca2" || exit 1
	link sca1 vimc-scaler 1 sca2 vimc-scaler 0 on

	mkdir "/configfs/vimc/mdev/vimc-capture:cap" || exit 1
	link sca2 vimc-scaler 1 cap vimc-capture 0 on
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test11.ps
	W=20
	H=20
	W3=60
	H3=60
	W9=180
	H9=180
	SEN_0="\"sen\":0[fmt:SBGGR8_1X8/${W}x${H}]"
	DEB_0="\"deb\":0[fmt:SBGGR8_1X8/${W}x${H}]"
	DEB_1="\"deb\":1[fmt:RGB888_1X24/${W}x${H}]"
	SCA1_0="\"sca1\":0[fmt:SBGGR8_1X8/${W}x${H}]"
	#SCA1_1=""sca1":1[fmt:SBGGR8_1X8/${W}x${H}]"
	SCA2_0="\"sca2\":0[fmt:SBGGR8_1X8/${W3}x${H3}]"
	#SCA2_1='"sca2":1[fmt:SBGGR8_1X8/${W}x${H}]"

	media-ctl -d platform:vimc-000 -V "${SEN_0},${DEB_0},${DEB_1},${SCA1_0},${SCA2_0}"
	#v4l2-ctl -z platform:vimc-000 -d "cap-sen" -v pixelformat=BA81
	#v4l2-ctl -z platform:vimc-000 -d "cap-deb" -v pixelformat=RGB3
	v4l2-ctl -z platform:vimc-000 -d "cap" -v pixelformat=RGB3,width=${W9},height=${H9}
}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
302 303 304 305 306
function test12 {
	reinstall_vimc
	modprobe -r vimc
	modprobe -v vimc sca_mult=1
	echo "============================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
307
	echo "add pipeline longer than VIMC_STREAMER_PIPELINE_MAX_SIZE 16"
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
	echo "============================================="
	
	DEV=mdev
	mkdir "/configfs/vimc/$DEV" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-sensor:sen" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-debayer:deb" || exit 1
	link sen vimc-sensor 0 deb vimc-debayer 0 on

	mkdir "/configfs/vimc/mdev/vimc-scaler:sca1" || exit 1
	link deb vimc-debayer 1 sca1 vimc-scaler 0 on

	for ((i=2;i<=16;i++));
	do
		j=$(($i - 1))
		mkdir "/configfs/vimc/mdev/vimc-scaler:sca${i}" || exit 1
		link sca$j vimc-scaler 1 sca$i vimc-scaler 0 on
	done

	mkdir "/configfs/vimc/mdev/vimc-capture:cap" || exit 1
	link sca16 vimc-scaler 1 cap vimc-capture 0 on
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test12.ps
	W=180
	H=180
	SEN_0="\"sen\":0[fmt:SBGGR8_1X8/${W}x${H}]"
	DEB_0="\"deb\":0[fmt:SBGGR8_1X8/${W}x${H}]"
	DEB_1="\"deb\":1[fmt:RGB888_1X24/${W}x${H}]"
	media-ctl -d platform:vimc-000 -V "${SEN_0},${DEB_0},${DEB_1}"
	for ((i=1;i<=16;i++));
	do
		media-ctl -d platform:vimc-000 -V "\"sca${i}\":0[fmt:RGB888_1X24/${W}x${H}]"
	done
	v4l2-ctl -z platform:vimc-000 -d "cap" -v pixelformat=RGB3,width=${W},height=${H}
	v4l2-ctl --stream-mmap --stream-count=$1 -d0
}

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
function test13 {
	reinstall_vimc
	echo "============================================="
	echo "stream for several pipelines from several devices"
	echo "create 10 sensors connected to a debayer connected to a scaler"
	echo "and try to stream from all sensors and from the scaler"
	echo "============================================="
	DEV=mdev

	mkdir /configfs/vimc/$DEV/
	mkdir /configfs/vimc/$DEV/vimc-scaler:sca
	for ((i=1;i<=16;i++));
	do
		j=$(($i - 1))
		mkdir "/configfs/vimc/mdev/vimc-sensor:sen${i}" || exit 1
		mkdir "/configfs/vimc/mdev/vimc-capture:cap${i}" || exit 1
		link sen$i vimc-sensor 0 sca vimc-scaler 0 off
		link sen$i vimc-sensor 0 cap$i vimc-capture 0 on
	done
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test13.ps
	media-ctl -d platform:vimc-000 -V "\"sca\":0[fmt:RGB888_1X24/300x300]"
	for ((i=1;i<=16;i++));
	do
		echo "==$i=="
		media-ctl -d platform:vimc-000 -V "\"sen${i}\":0[fmt:RGB888_1X24/100x100]"
		v4l2-ctl -z platform:vimc-000 -d "cap${i}" -v pixelformat=RGB3,width=100,height=100
	done
	for ((i=1;i<=16;i++));
	do
		echo "==$i=="
		v4l2-ctl -z platform:vimc-000 -d "cap${i}" --stream-mmap --stream-count=50 &
	done
	sleep 1
	echo 0 > /configfs/vimc/mdev/hotplug
}

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
381 382 383
#- test concurency
#echo "============================================="
#}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
384

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
function test14 {
	reinstall_vimc
	echo "============================================="
	echo "create more than 64 devices and make sure it is not possible"
	echo "then, remove a random device and add a device and make sure it is possible"
	echo "============================================="
	for ((i=1;i<=65;i++));
	do
		echo "==$i=="
		mkdir "/configfs/vimc/mdev${i}/" || exit 1
		mkdir "/configfs/vimc/mdev${i}/vimc-sensor:sen" || exit 1
		mkdir "/configfs/vimc/mdev${i}/vimc-capture:cap" || exit 1
		echo 1 > "/configfs/vimc/mdev$i/hotplug"
		#link sen$i vimc-sensor 0 sca vimc-scaler 0 off
		#link sen$i vimc-sensor 0 cap$i vimc-capture 0 on
	done
	j=65
	echo 0 > "/configfs/vimc/mdev65/hotplug"
	for ((i=1;i<=64;i++));
	do
		echo "==$i=="
		echo 0 > "/configfs/vimc/mdev$i/hotplug"
		echo 1 > "/configfs/vimc/mdev$j/hotplug"
		j=$(($i))
		#link sen$i vimc-sensor 0 sca vimc-scaler 0 off
		#link sen$i vimc-sensor 0 cap$i vimc-capture 0 on
	done
	echo 1 > "/configfs/vimc/mdev64/hotplug"

}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
415 416 417 418 419 420 421 422
function test15 {
	reinstall_vimc
	modprobe -r vimc
	modprobe -v vimc sca_mult=1
	echo "============================================="
	echo "create a device with a circle"
	echo "then, remove a random device and add a device and make sure it is possible"
	echo "============================================="
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
423

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
424 425 426 427 428 429 430 431 432 433 434 435 436 437
	DEV=mdev
	mkdir "/configfs/vimc/mdev/" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-scaler:sca1" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-scaler:sca2" || exit 1
	mkdir "/configfs/vimc/mdev/vimc-capture:cap" || exit 1
	link sca1 vimc-scaler 1 sca2 vimc-scaler 0 on
	link sca2 vimc-scaler 1 sca1 vimc-scaler 0 on
	link sca2 vimc-scaler 1 cap vimc-capture 0 on
	echo 1 > /configfs/vimc/mdev/hotplug
	media-ctl -d0 --print-dot | dot -Tps -o vmpath/test15.ps
	media-ctl -d platform:vimc-000 -V "\"sca1\":0[fmt:RGB888_1X24/100x100]"
	media-ctl -d platform:vimc-000 -V "\"sca2\":0[fmt:RGB888_1X24/100x100]"
	v4l2-ctl -z platform:vimc-000 -d "cap" -v pixelformat=RGB3,width=100,height=100
	v4l2-ctl -z platform:vimc-000 -d "cap" --stream-mmap --stream-count=10
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
438

Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
439
}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
440

441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
function test16 {
	reinstall_vimc
		modprobe -r vimc
		modprobe -v vimc sca_mult=1
		echo "============================================="
		echo "make sure it is impossible to create a link from an entity to itself"
		echo "============================================="

		DEV=mdev
		mkdir "/configfs/vimc/mdev/" || exit 1
		mkdir "/configfs/vimc/mdev/vimc-scaler:sca1" || exit 1
		link sca1 vimc-scaler 1 sca1 vimc-scaler 0 on && echo "Failure: connecting a scaler to itself should not be allowed" && exit 1

}


Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
457
if [ $# == 0 ]; then
458
	for test_idx in {1..16}
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
459 460 461 462 463 464 465 466
	do

		test$test_idx
	done
else
	test${1}
fi
exit
Dafna Hirschfeld's avatar
Dafna Hirschfeld committed
467