xref: /freebsd/usr.bin/posixmqcontrol/posixmqcontroltest8qs.sh (revision ba7b7f94c239ce43343d7af403734fdc941b7664)
1#!/bin/sh
2# testing create, info, and send operations applied to multiple queue names at once.
3# recv accepts a single queue name so draining is done one queue at a time.
4subject='posixmqcontrol'
5prefix='/posixmqcontroltest'
6
7list=
8for i in 1 2 3 4 5 6 7 8
9do
10  topic="${prefix}${i}"
11  ${subject} info -q "${topic}" 2>/dev/null
12  if [ $? == 0 ]; then
13    echo "sorry, $topic exists."
14    exit 1
15  fi
16  list="${list} -q ${topic}"
17done
18
19${subject} create -d 2 -s 64 ${list}
20if [ $? != 0 ]; then
21  exit 1
22fi
23
24ignore=$( ${subject} info ${list} )
25if [ $? != 0 ]; then
26  exit 1
27fi
28
29${subject} send -c 'this message sent to all listed queues.' ${list}
30if [ $? != 0 ]; then
31  exit 1
32fi
33
34# we can only drain one message at a time.
35for i in 1 2 3 4 5 6 7 8
36do
37  topic="${prefix}${i}"
38  ignore=$( ${subject} recv -q "${topic}" )
39  if [ $? != 0 ]; then
40    exit 1
41  fi
42done
43
44${subject} rm ${list}
45if [ $? == 0 ]; then
46  echo "Pass!"
47  exit 0
48fi
49
50exit 1
51