1#!/bin/bash
2# test_hub_mode_server_and_client.sh
3# bash script for automatic testing of jacktrip in hub mode , Chris Chafe
4# connects a hub client to a hub server (started with with -p1) on the same host
5# prints avg audio RTT after 8 sec, or -1 if fail
6# ./test_hub_mode_server_and_client.sh <path-to-executable> <FPP>
7# requires 3 helper scripts
8# -- startJacktripHubServer.sh
9# -- startJacktripHubClient.sh
10# -- art.sh
11# requires jackd be available on the host
12# uses the "dummy" interface, so no audio interface needed
13# first does some jackd cleanup
14# takes approx. 20 sec to complete
15
16# a passing test prints to the console
17# [cc@localhost sh]$ ./test.sh /home/cc/jacktrip/builddir/jacktrip 32
18# starting /home/cc/jacktrip/builddir/jacktrip hub mode test at 32 FPP
19# starting hub client for server localhost
20# calculate audio round trip
21# 4
22
23# a failed test prints to the console
24# [cc@localhost functionTests]$ ./test.sh ~/jacktrip/builddir/jacktrip 32
25# starting /home/cc/jacktrip/builddir/jacktrip hub mode test at 32 FPP
26# starting /home/cc/jacktrip/builddir/jacktrip server
27# starting hub client of server running on localhost
28# calculate audio round trip
29# ERROR ..1:send_1 not a valid port
30# ERROR ..1:send_2 not a valid port
31# ERROR ..1:send_1 not a valid port
32# ERROR ..1:receive_1 not a valid port
33# jacktrip: no process found
34# -1
35
36
37JACKTRIP=$1
38
39if [ -z "$2" ]
40  then
41    FPP=128
42  else
43    FPP=$2
44fi
45
46# killall jackd
47if [ "$(ps -aux | grep -c jackd)" != 1 ]; then killall jackd; fi;
48# if jackd is or has been running with another driver
49# much experimenation shows it literally takes this long
50sleep 17
51# to flush old connections before starting the dummy driver
52
53# start jack with dummy driver, or change to an audio interface by switching these lines
54$( /usr/bin/jackd  -ddummy -r48000 -p$FPP > /dev/null 2>&1 & )
55# $( /usr/bin/jackd  -dalsa -dhw:A96 -r48000 -p$FPP -n2  > /dev/null 2>&1 & )
56# $( /usr/bin/jackd  -dalsa -dhw:PCH -r48000 -p$FPP -n2  > /dev/null 2>&1 & )
57
58sleep 1
59
60echo starting $JACKTRIP hub mode test at $FPP FPP
61
62$PWD/startJacktripHubServer.sh $JACKTRIP
63sleep 1
64$PWD/startJacktripHubClient.sh $JACKTRIP
65
66sleep 1
67
68# start measuring audio RTT
69$PWD/art.sh
70
71