jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
4.4KB

  1. #!/bin/bash
  2. #test jack_property client
  3. #//tb/1902
  4. #this test needs:
  5. # -a running jack server
  6. # -client programs
  7. # -jack_property
  8. # -jack_metro
  9. # -jack_lsp
  10. #uninstall jack, setup jack1, make sure /dev/shm/ is clean, start jackd -ddummy in new terminal, run this script in new terminal
  11. # time ./jack_property_test.sh > /tmp/jack_property_test_jack1_out.txt 2>&1
  12. #uninstall jack, setup jack2, make sure /dev/shm/ is clean, start jackd -ddummy in new terminal, run this script in new terminal
  13. # time ./jack_property_test.sh > /tmp/jack_property_test_jack2_out.txt 2>&1
  14. #for stress test: while true; do ./jack_property_test.sh; sleep 1; done
  15. #to inspect running script: start with bash -x ./jack_property_test.sh
  16. set -o pipefail
  17. #any failed test will set this to 1 (error)
  18. FINAL_RETURN_VALUE=0
  19. function expect()
  20. {
  21. if [ "$1" = "$2" ];
  22. then
  23. echo " OK: $2"
  24. return 0
  25. fi
  26. echo "** FAILED: $1"
  27. echo "** EXP EQ: $2"
  28. FINAL_RETURN_VALUE=1
  29. return 1
  30. }
  31. function expect_not()
  32. {
  33. if [ "$1" != "$2" ];
  34. then
  35. echo " OK: $2"
  36. return 0
  37. fi
  38. echo "** FAILED: $1"
  39. echo "** EXP NE: $2"
  40. FINAL_RETURN_VALUE=1
  41. return 1
  42. }
  43. function expect_ok_empty()
  44. {
  45. expect "$1" 0
  46. expect "$2" ""
  47. }
  48. TESTPREFIX=""
  49. function tell()
  50. {
  51. echo "test ${TESTPREFIX}$1: $2"
  52. }
  53. #test using -c, --client
  54. function client_test()
  55. {
  56. client="$1"
  57. cmd="jack_property -D"
  58. tell c1 "$cmd"
  59. res="`$cmd 2>&1`"
  60. expect $? 0
  61. expect "$res" "JACK metadata successfully deleted"
  62. cmd="jack_property -l"
  63. tell c2 "$cmd"
  64. res="`$cmd 2>&1`"
  65. expect_ok_empty $? "$res"
  66. cmd="jack_property -c -l $client"
  67. tell c3 "$cmd"
  68. res="`$cmd 2>&1`"
  69. expect_ok_empty $? "$res"
  70. cmd="jack_property -c -s $client client_key client_value"
  71. tell c4 "$cmd"
  72. res="`$cmd 2>&1`"
  73. expect_ok_empty $? "$res"
  74. cmd="jack_property -c -l $client"
  75. tell c5 "$cmd"
  76. res="`$cmd 2>&1`"
  77. expect $? 0
  78. expect "$res" "key: client_key value: client_value"
  79. cmd="jack_property -c -l $client client_key"
  80. tell c6 "$cmd"
  81. res="`$cmd 2>&1`"
  82. expect $? 0
  83. expect "$res" "client_value"
  84. cmd="jack_property -l" # |tail -1"
  85. tell c7 "$cmd"
  86. res="`$cmd 2>&1 |tail -1`"
  87. #18446744073709551615
  88. #key: client_key value: client_value
  89. expect $? 0
  90. expect "$res" "key: client_key value: client_value"
  91. cmd="jack_property -p -l ${client}:non"
  92. tell c8 "$cmd"
  93. res="`$cmd 2>&1`"
  94. expect_not $? 0
  95. expect "$res" "cannot find port name ${client}:non"
  96. }
  97. #test using -p, --port
  98. function port_test()
  99. {
  100. port="$1"
  101. cmd="jack_property -D"
  102. tell p1 "$cmd"
  103. res="`$cmd 2>&1`"
  104. expect $? 0
  105. expect "$res" "JACK metadata successfully deleted"
  106. cmd="jack_property -l"
  107. tell p2 "$cmd"
  108. res="`$cmd 2>&1`"
  109. expect_ok_empty $? "$res"
  110. cmd="jack_property -p -l $port"
  111. tell p3 "$cmd"
  112. res="`$cmd 2>&1`"
  113. expect_ok_empty $? "$res"
  114. cmd="jack_property -p -s $port port_key port_value"
  115. tell p4 "$cmd"
  116. res="`$cmd 2>&1`"
  117. expect_ok_empty $? "$res"
  118. cmd="jack_property -p -l $port"
  119. tell p5 "$cmd"
  120. res="`$cmd 2>&1`"
  121. expect $? 0
  122. expect "$res" "key: port_key value: port_value"
  123. cmd="jack_property -p -l $port port_key"
  124. tell p6 "$cmd"
  125. res="`$cmd 2>&1`"
  126. expect $? 0
  127. expect "$res" "port_value"
  128. cmd="jack_property -p -d $port port_key"
  129. tell p7 "$cmd"
  130. res="`$cmd 2>&1`"
  131. expect_ok_empty $? "$res"
  132. cmd="jack_property -p -l $port port_key"
  133. tell p8 "$cmd"
  134. res="`$cmd 2>&1`"
  135. expect_not $? 0
  136. expect "$res" "Value not found for port_key of $port"
  137. cmd="jack_property -p -d $port port_key"
  138. tell p9 "$cmd"
  139. res="`$cmd 2>&1 |tail -1`"
  140. #Cannot delete key port_key (BDB0073 DB_NOTFOUND: No matching key/data pair found)
  141. #"port_key" property not removed for system:playback_1
  142. expect_not $? 0
  143. expect "$res" "\"port_key\" property not removed for $port"
  144. cmd="jack_property -p -l $port"
  145. tell p10 "$cmd"
  146. res="`$cmd 2>&1`"
  147. expect_ok_empty $? "$res"
  148. cmd="jack_property -p -l $port non"
  149. tell p11 "$cmd"
  150. res="`$cmd 2>&1`"
  151. expect_not $? 0
  152. expect "$res" "Value not found for non of $port"
  153. cmd="jack_property -c -l non"
  154. tell p12 "$cmd"
  155. res="`$cmd 2>&1`"
  156. expect_not $? 0
  157. expect "$res" "cannot get UUID for client named non"
  158. }
  159. TESTPREFIX="system_"
  160. client_test system
  161. port_test system:playback_1
  162. #test with any jack client
  163. jack_metro -b120 &
  164. metro_pid=$!
  165. sleep 0.1
  166. jack_lsp|grep metro
  167. #metro:120_bpm
  168. TESTPREFIX="metro_"
  169. client_test metro
  170. port_test metro:120_bpm
  171. jack_property -D
  172. #JACK metadata successfully deleted
  173. jack_property -l
  174. kill -HUP $metro_pid
  175. sleep 0.5
  176. echo "done, exit status is $FINAL_RETURN_VALUE"
  177. ###TO DO:
  178. #test short keys, values
  179. #test long keys, values
  180. #test many
  181. exit $FINAL_RETURN_VALUE
  182. #EOF