3 ###########################################################################
4 # Copyright (C) 2017, 2018 IoT.bzh
6 # Author: Romain Forlot <romain.forlot@iot.bzh>
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 ###########################################################################
24 [ ! "${VERBSELECTED}" ] && VERBSELECTED="*"
26 # Research the Api name used
27 CFGFILE=$(find ${AFM_APP_INSTALL_DIR} -name "*json" -print | head -n1)
28 API=$(grep '\"api\"' ${CFGFILE} | cut -d'"' -f4)
30 AFBCLIENTIN=$(mktemp -u)
31 AFBCLIENTOUT=$(mktemp -u)
37 if [[ $(jq -r '.testVerb|type' $CFGFILE) == "array" ]]
39 testVerbLength=$(jq '.testVerb|length' $CFGFILE)
40 if [ "$VERBSELECTED" = "*" ]
42 # Get all the verbs of the test api
43 for (( idx=0; idx<testVerbLength; idx++ )) do
44 testVerb[$idx]=$(jq -r ".testVerb[$idx].uid" ${CFGFILE})
47 # You search for a exact matching verb so there should be only one match
48 for (( idx=0; idx<testVerbLength; idx++ )) do
49 [ "$(jq -r ".testVerb[$idx].uid" ${CFGFILE})" = "$VERBSELECTED" ] && \
50 testVerb[0]=$(jq -r ".testVerb[$idx].uid" ${CFGFILE})
54 if [ "$VERBSELECTED" = "*" ]
56 testVerb[0]=$(jq -r ".testVerb.uid" ${CFGFILE})
58 [ "$(jq -r ".testVerb[0].uid" ${CFGFILE})" = "$VERBSELECTED" ] && \
59 testVerb[0]=$(jq -r ".testVerb[$idx].uid" ${CFGFILE})
63 testVerbLength=${#testVerb[@]}
64 for (( idx=0; idx<testVerbLength; idx++ )) do
65 echo "Launching ${testVerb[$idx]}"
66 afb-client-demo -s ws://localhost:${PORT}/api?token=${TOKEN} "$API" "${testVerb[$idx]}" "${VERBARGS}"
69 afb-client-demo ws://localhost:${PORT}/api?token=${TOKEN} "$API" "exit"