Merge branch 'master' into develop
[jack2.git] / tests / jack_property_test.sh
blob35d3ebe7b5be254afbb735c0fae2a08dbddd0008
1 #!/bin/bash
3 #test jack_property client
4 #//tb/1902
6 #this test needs:
7 # -a running jack server
8 # -client programs
9 # -jack_property
10 # -jack_metro
11 # -jack_lsp
13 #uninstall jack, setup jack1, make sure /dev/shm/ is clean, start jackd -ddummy in new terminal, run this script in new terminal
14 # time ./jack_property_test.sh > /tmp/jack_property_test_jack1_out.txt 2>&1
16 #uninstall jack, setup jack2, make sure /dev/shm/ is clean, start jackd -ddummy in new terminal, run this script in new terminal
17 # time ./jack_property_test.sh > /tmp/jack_property_test_jack2_out.txt 2>&1
19 #for stress test: while true; do ./jack_property_test.sh; sleep 1; done
20 #to inspect running script: start with bash -x ./jack_property_test.sh
22 set -o pipefail
24 #any failed test will set this to 1 (error)
25 FINAL_RETURN_VALUE=0
27 function expect()
29 if [ "$1" = "$2" ];
30 then
31 echo " OK: $2"
32 return 0
34 echo "** FAILED: $1"
35 echo "** EXP EQ: $2"
36 FINAL_RETURN_VALUE=1
37 return 1
40 function expect_not()
42 if [ "$1" != "$2" ];
43 then
44 echo " OK: $2"
45 return 0
47 echo "** FAILED: $1"
48 echo "** EXP NE: $2"
49 FINAL_RETURN_VALUE=1
50 return 1
53 function expect_ok_empty()
55 expect "$1" 0
56 expect "$2" ""
59 TESTPREFIX=""
60 function tell()
62 echo "test ${TESTPREFIX}$1: $2"
65 #test using -c, --client
66 function client_test()
68 client="$1"
70 cmd="jack_property -D"
71 tell c1 "$cmd"
72 res="`$cmd 2>&1`"
73 expect $? 0
74 expect "$res" "JACK metadata successfully deleted"
76 cmd="jack_property -l"
77 tell c2 "$cmd"
78 res="`$cmd 2>&1`"
79 expect_ok_empty $? "$res"
81 cmd="jack_property -c -l $client"
82 tell c3 "$cmd"
83 res="`$cmd 2>&1`"
84 expect_ok_empty $? "$res"
86 cmd="jack_property -c -s $client client_key client_value"
87 tell c4 "$cmd"
88 res="`$cmd 2>&1`"
89 expect_ok_empty $? "$res"
91 cmd="jack_property -c -l $client"
92 tell c5 "$cmd"
93 res="`$cmd 2>&1`"
94 expect $? 0
95 expect "$res" "key: client_key value: client_value"
97 cmd="jack_property -c -l $client client_key"
98 tell c6 "$cmd"
99 res="`$cmd 2>&1`"
100 expect $? 0
101 expect "$res" "client_value"
103 cmd="jack_property -l" # |tail -1"
104 tell c7 "$cmd"
105 res="`$cmd 2>&1 |tail -1`"
106 #18446744073709551615
107 #key: client_key value: client_value
108 expect $? 0
109 expect "$res" "key: client_key value: client_value"
111 cmd="jack_property -p -l ${client}:non"
112 tell c8 "$cmd"
113 res="`$cmd 2>&1`"
114 expect_not $? 0
115 expect "$res" "cannot find port name ${client}:non"
118 #test using -p, --port
119 function port_test()
121 port="$1"
123 cmd="jack_property -D"
124 tell p1 "$cmd"
125 res="`$cmd 2>&1`"
126 expect $? 0
127 expect "$res" "JACK metadata successfully deleted"
129 cmd="jack_property -l"
130 tell p2 "$cmd"
131 res="`$cmd 2>&1`"
132 expect_ok_empty $? "$res"
134 cmd="jack_property -p -l $port"
135 tell p3 "$cmd"
136 res="`$cmd 2>&1`"
137 expect_ok_empty $? "$res"
139 cmd="jack_property -p -s $port port_key port_value"
140 tell p4 "$cmd"
141 res="`$cmd 2>&1`"
142 expect_ok_empty $? "$res"
144 cmd="jack_property -p -l $port"
145 tell p5 "$cmd"
146 res="`$cmd 2>&1`"
147 expect $? 0
148 expect "$res" "key: port_key value: port_value"
150 cmd="jack_property -p -l $port port_key"
151 tell p6 "$cmd"
152 res="`$cmd 2>&1`"
153 expect $? 0
154 expect "$res" "port_value"
156 cmd="jack_property -p -d $port port_key"
157 tell p7 "$cmd"
158 res="`$cmd 2>&1`"
159 expect_ok_empty $? "$res"
161 cmd="jack_property -p -l $port port_key"
162 tell p8 "$cmd"
163 res="`$cmd 2>&1`"
164 expect_not $? 0
165 expect "$res" "Value not found for port_key of $port"
167 cmd="jack_property -p -d $port port_key"
168 tell p9 "$cmd"
169 res="`$cmd 2>&1 |tail -1`"
170 #Cannot delete key port_key (BDB0073 DB_NOTFOUND: No matching key/data pair found)
171 #"port_key" property not removed for system:playback_1
172 expect_not $? 0
173 expect "$res" "\"port_key\" property not removed for $port"
175 cmd="jack_property -p -l $port"
176 tell p10 "$cmd"
177 res="`$cmd 2>&1`"
178 expect_ok_empty $? "$res"
180 cmd="jack_property -p -l $port non"
181 tell p11 "$cmd"
182 res="`$cmd 2>&1`"
183 expect_not $? 0
184 expect "$res" "Value not found for non of $port"
186 cmd="jack_property -c -l non"
187 tell p12 "$cmd"
188 res="`$cmd 2>&1`"
189 expect_not $? 0
190 expect "$res" "cannot get UUID for client named non"
194 TESTPREFIX="system_"
195 client_test system
196 port_test system:playback_1
198 #test with any jack client
199 jack_metro -b120 &
200 metro_pid=$!
202 sleep 0.1
203 jack_lsp|grep metro
204 #metro:120_bpm
206 TESTPREFIX="metro_"
207 client_test metro
208 port_test metro:120_bpm
210 jack_property -D
211 #JACK metadata successfully deleted
212 jack_property -l
214 kill -HUP $metro_pid
215 sleep 0.5
216 echo "done, exit status is $FINAL_RETURN_VALUE"
218 ###TO DO:
219 #test short keys, values
220 #test long keys, values
221 #test many
223 exit $FINAL_RETURN_VALUE
224 #EOF