tests: Make local variables local
[renesas/vsp-tests.git] / tests / vsp-unit-test-0012.sh
1 #!/bin/sh
2
3 #
4 # Test runtime modification of horizontal and vertical flipping on WPF.0.
5 #
6
7 source vsp-lib.sh
8
9 features="rpf.0 wpf.0 wpf.0[control:'Vertical+Flip']"
10 optional_features="wpf.0[control:'Horizontal+Flip']"
11
12 directions="horizontal vertical"
13 dir_horizontal_control="Horizontal+Flip"
14 dir_horizontal_label="hflip"
15 dir_vertical_control="Vertical+Flip"
16 dir_vertical_label="vflip"
17
18 format="RGB24"
19
20 get_var() {
21         echo $(eval echo \$dir_$1_$2)
22 }
23
24 flip_control() {
25         local direction=$1
26         local value=$2
27         local control=$(get_var $direction control)
28
29         vsp1_set_control wpf.0 "$control" $value
30 }
31
32 reset_controls() {
33         # Reset all controls to their default value
34         local direction
35
36         for direction in $* ; do
37                 flip_control $direction 0
38         done
39 }
40
41 test_flipping() {
42         local direction=$1
43         local label="$(get_var $direction label)"
44
45         test_start "$label"
46
47         pipe_configure rpf-wpf 0 0
48         format_configure rpf-wpf 0 0 $format 1024x768 $format
49
50         vsp_runner rpf.0 --count=6 &
51         vsp_runner wpf.0 --count=6 --skip=0 --buffers=1 --pause=3 &
52
53         vsp_runner_wait wpf.0
54         local result=$(compare_frames $label=0)
55
56         [ $result = fail ] && {
57                 test_complete $result ;
58                 return
59         }
60
61         flip_control $direction 1
62
63         vsp_runner_resume wpf.0
64         wait
65
66         result=$(compare_frames $label=1)
67
68         test_complete $result
69 }
70
71 test_main() {
72         # Check the supported directions and reset the associated controls
73         local supported_directions
74         local direction
75
76         for direction in $directions ; do
77                 $(vsp1_has_feature "wpf.0[control:'$(get_var $direction control)']") && {
78                         supported_directions="$supported_directions $direction" ;
79                         flip_control $direction 0
80                 }
81         done
82
83         # Reset the rotation control to avoid interfering with the test
84         $(vsp1_has_feature "wpf.0[control:'Rotate']") && {
85                 vsp1_set_control wpf.0 Rotate 0
86         }
87
88         local directions=$supported_directions
89
90         for direction in $directions ; do
91                 reset_controls $directions
92                 test_flipping $direction
93         done
94 }
95
96 test_init $0 "$features" "$optional_features"
97 test_run