aboutsummaryrefslogtreecommitdiffstats
path: root/tst/psmq-progs.sh
blob: 87765dbbce83764bbf694602729b338eebb02e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
#!/bin/sh
## ==========================================================================
#   Licensed under BSD 2clause license See LICENSE file for more information
#   Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
## ==========================================================================

. ./mtest.sh

broker_name="/tpsmqd"
psmqs_name="/s"
psmqp_name="/p"

psmqd_pid=
psmqs_pid=

psmqs_stdout="tpsmqs.stdout"
psmqs_stderr="tpsmqs.stderr"
psmqp_stdout="tpsmqp.stdout"
psmqp_stderr="tpsmqp.stderr"
psmqd_stderr="tpsmqd.stderr"
psmqd_stdout="tpsmqd.stdout"
psmqd_log="tpsmqd.log"

psmqd_bin="../src/psmqd"
psmqs_bin="../src/psmq-sub"
psmqp_bin="../src/psmq-pub"




## ==========================================================================
#                  _                __           ____
#    ____   _____ (_)_   __ ____ _ / /_ ___     / __/__  __ ____   _____ _____
#   / __ \ / ___// /| | / // __ `// __// _ \   / /_ / / / // __ \ / ___// ___/
#  / /_/ // /   / / | |/ // /_/ // /_ /  __/  / __// /_/ // / / // /__ (__  )
# / .___//_/   /_/  |___/ \__,_/ \__/ \___/  /_/   \__,_//_/ /_/ \___//____/
#/_/
## ==========================================================================


## ==========================================================================
#   Generate random string.
#
#   $1 - number of characters to generate
## ==========================================================================


randstr()
{
    cat /dev/urandom | tr -dc 'a-zA-Z0-9' | tr -d '\0' | fold -w ${1} \
        | head -n 1 | tr -d '\n'
}


## ==========================================================================
## ==========================================================================


psmq_grep()
{
    string="${1}"
    file="${2}"
    i=0

    while true
    do
        if grep "${string}" "${file}" >/dev/null
        then
            # found
            return 0
        fi

        # not found yet
        sleep 0.1

        i=$((i + 1))
        if [ ${i} -eq 600 ]
        then
            # not found for specified ammount of time
            return 1
        fi
    done
}


## ==========================================================================
## ==========================================================================


start_psmqd()
{
    echo -n > ${psmqd_log}
    ${psmqd_bin} -l7 -p${psmqd_log} -r -b${broker_name} -m10 &
    psmqd_pid=${!}

    # wait for broker to startup

    while true
    do
        if grep "starting psmqd broker main loop" "${psmqd_log}" >/dev/null 2>&1
        then
            break
        fi
        sleep 0.1
    done

    # wait for last option to appear in the log file before
    # grepping for values

    psmq_grep "n/created" ${psmqd_log}

    psmq_msg_max=$(cat ${psmqd_log} | grep PSMQ_MSG_MAX \
        | cut -f3 -d] | cut -f3 -d\ )
}


## ==========================================================================
## ==========================================================================


start_psmqs()
{
    echo -n > "${psmqs_stdout}"
    ${psmqs_bin} -n${psmqs_name} -b${broker_name} -t/1 -t/2 -o${psmqs_stdout} \
        2> ${psmqs_stderr} &
    psmqs_pid=${!}

    # wait for psmq-sub to start

    while true
    do
        if grep "start receiving data" "${psmqs_stderr}" >/dev/null 2>&1
        then
            break
        fi
        sleep 0.1
    done
}


## ==========================================================================
## ==========================================================================


stop_psmqs()
{
    kill ${psmqs_pid}
    counter=0

    while true
    do
        if ! kill -s 0 ${psmqs_pid} 2>/dev/null
        then
            break
        fi

        sleep 0.1
        counter=$((counter + 1))

        if [ ${counter} -eq 10 ]
        then
            ###
            # program refuses to die, let's kill it again - order must be!
            #

            kill ${psmqs_pid}
            counter=0
        fi
    done
}


## ==========================================================================
## ==========================================================================


mt_prepare_test()
{

    return 0
}


## ==========================================================================
## ==========================================================================


mt_cleanup_test()
{
    echo -n > $psmqs_stdout
    echo -n > $psmqs_stderr
    echo -n > $psmqp_stdout
    echo -n > $psmqp_stderr
    echo -n > $psmqd_stderr
    echo -n > $psmqd_stdout
    echo -n > $psmqd_log
    return 0
}


## ==========================================================================
#                           __               __
#                          / /_ ___   _____ / /_ _____
#                         / __// _ \ / ___// __// ___/
#                        / /_ /  __/(__  )/ /_ (__  )
#                        \__/ \___//____/ \__//____/
#
## ==========================================================================


psmq_sub_print_help()
{
    ${psmqs_bin} -h > ${psmqs_stdout}
    mt_fail "psmq_grep \"listen to subscribed messages over psmq\" \
        \"${psmqs_stdout}\""
}
psmq_sub_print_version()
{
    ${psmqs_bin} -v > ${psmqs_stdout}
    mt_fail "psmq_grep \"by Michał Łyszczek <michal.lyszczek@bofc.pl>\" \
        \"${psmqs_stdout}\""
}
psmq_sub_broker_doesnt_exist()
{
    ${psmqs_bin} -n${psmqs_name} -b/surely-i-dont-exist 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/broker /surely-i-dont-exist doesn't exist\" \
        \"${psmqs_stderr}\""
}
psmq_sub_qname_too_long()
{
    psmqs_qname="/$(randstr ${psmq_msg_max})"
    ${psmqs_bin} -n${psmqs_qname} -b/surely-i-dont-exist 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/queue name is too long ($((psmq_msg_max + 1))), max is $((psmq_msg_max - 1))\" \
        \"${psmqs_stderr}\""
}
psmq_sub_topic_too_long()
{
    topic="/$(randstr ${psmq_msg_max})"
    ${psmqs_bin} -n${psmqs_name} -b${broker_name} -t${topic} 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"subscribe failed, topic ${topic} is too long\" \
        \"${psmqs_stderr}\""
}
psmq_sub_output_file_does_not_exit()
{
    ${psmqs_bin} -o/yea/sure/i/exist 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/failed to open file /yea/sure/i/exist for logging\" \
        \"${psmqs_stderr}\""
}
psmq_sub_topic_before_broker()
{
    ${psmqs_bin} -t/topic 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/subscribe failed, was -b set before -t option?\" \
        \"${psmqs_stderr}\""
}
psmq_sub_invalid_broker_name()
{
    ${psmqs_bin} -bno-wai 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/broker or queue name is invalid\" \
        \"${psmqs_stderr}\""
}
psmq_sub_invalid_queue_name()
{
    ${psmqs_bin} -nno-wai -b/valid 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/broker or queue name is invalid\" \
        \"${psmqs_stderr}\""
}
psmq_sub_invalid_topic()
{
    ${psmqs_bin} -n${psmqs_name} -b${broker_name} -t/ 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"subscribe failed, topic / is invalid\" \
        \"${psmqs_stderr}\""
}
psmq_sub_missing_argument()
{
    ${psmqs_bin} -b 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/option -b requires an argument\" \
        \"${psmqs_stderr}\""
}
psmq_sub_unknown_argument()
{
    ${psmqs_bin} -Q 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"f/unknown option -Q\" \
        \"${psmqs_stderr}\""
}
psmq_sub_no_arguments()
{
    ${psmqs_bin} 2> ${psmqs_stderr}
    mt_fail "psmq_grep \"missing -b option\" \"${psmqs_stderr}\""
}
psmq_sub_broker_go_down_before_client()
{
    # broker is started by now
    start_psmqs
    kill ${psmqd_pid}

    # psmq-sub should die with psmqd
    mt_fail "psmq_grep \"n/broker has closed the connection\" \
        \"${psmqs_stderr}\""

    # restart psmqd
    start_psmqd
}
psmq_pub_print_help()
{
    ${psmqp_bin} -h > ${psmqp_stdout}
    mt_fail "psmq_grep \"publish message over psmq\" \
        \"${psmqp_stdout}\""
}
psmq_pub_print_version()
{
    ${psmqp_bin} -v > ${psmqp_stdout}
    mt_fail "psmq_grep \"by Michał Łyszczek <michal.lyszczek@bofc.pl>\" \
        \"${psmqp_stdout}\""
}
psmq_pub_broker_doesnt_exist()
{
    ${psmqp_bin} -n${psmqp_name} -b/surely-i-dont-exist -t/t 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/broker /surely-i-dont-exist doesn't exist\" \
        \"${psmqp_stderr}\""
}
psmq_pub_qname_too_long()
{
    psmqp_qname="/$(randstr $((psmq_msg_max - 1)))"
    ${psmqp_bin} -n${psmqp_qname} -b${broker_name} -t/t 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/queue name is too long ($((psmq_msg_max))), max is $((psmq_msg_max - 1))\" \
        \"${psmqp_stderr}\""
}
psmq_pub_message_too_long()
{
    msg="$(randstr $((psmq_msg_max + 1)) )"
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/t -m${msg} 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/topic or message is too long\" \
        \"${psmqp_stderr}\""
}
psmq_pub_topic_too_long()
{
    topic="$(randstr $((psmq_msg_max + 1)) )"
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/${topic} -mmsg 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/topic or message is too long\" \
        \"${psmqp_stderr}\""
}
psmq_pub_invalid_broker_name()
{
    ${psmqp_bin} -bno-wai -t/t 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/broker or queue name is invalid\" \
        \"${psmqp_stderr}\""
}
psmq_pub_invalid_topic()
{
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t1 -mm 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/failed to publish to 1 invalid topic\" \
        \"${psmqp_stderr}\""
}
psmq_pub_invalid_queue_name()
{
    ${psmqp_bin} -nno-wai -b/valid -t/t 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/broker or queue name is invalid\" \
        \"${psmqp_stderr}\""
}
psmq_pub_missing_argument()
{
    ${psmqp_bin} -b 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/option -b requires an argument\" \
        \"${psmqp_stderr}\""
}
psmq_pub_unknown_argument()
{
    ${psmqp_bin} -Q 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/unknown option -Q\" \
        \"${psmqp_stderr}\""
}
psmq_pub_no_arguments()
{
    ${psmqp_bin} 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/missing broker name (-b) option\" \
        \"${psmqp_stderr}\""
}
psmq_pub_missing_b_argument()
{
    ${psmqp_bin} -n${psmqp_name} -t/t -mmsg 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/missing broker name (-b) option\" \
        \"${psmqp_stderr}\""
}
psmq_pub_missing_t_argument()
{
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -mmsg 2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/missing topic (-t) option\" \
        \"${psmqp_stderr}\""
}
psmq_pub_from_stdin()
{
    start_psmqs
    echo "t" | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1
    mt_fail "psmq_grep "t.." \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_from_stdin_max_line()
{
    start_psmqs
    # -2 since line consists of "\n\0"
    # -3 since topic is 3 bytes long "/1\0";
    msg="$(randstr $((psmq_msg_max - 2 - 3)) )"
    echo "${msg}" | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1
    mt_fail "psmq_grep $(echo ${msg} | cut -c-16) \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_from_stdin_too_long_line()
{
    # -2 since line consists of "\n\0"
    # -3 since topic is 3 bytes long "/1\0";
    # +1 because we want to exceed buffer to cause error
    msg="$(randstr $((psmq_msg_max - 2 - 3 + 1)) )"
    echo "${msg}" | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 2> \
        ${psmqp_stderr}
    mt_fail "psmq_grep \"f/line is too long, max line is $((psmq_msg_max - 5))\" \
        \"${psmqp_stderr}\""
}
psmq_pub_from_stdin_too_long_topic()
{
    topic_len=${psmq_msg_max}
    topic_len=$((topic_len + 1))
    topic="/$(randstr ${topic_len} )"
    echo "msg" | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t${topic} 2> \
        ${psmqp_stderr}
    mt_fail "psmq_grep \"f/topic is too long, max is $((psmq_msg_max - 1))\" \
        \"${psmqp_stderr}\""
}
psmq_pub_from_stdin_invalid_topic()
{
    echo m | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t1 2> \
        ${psmqp_stderr}
    mt_fail "psmq_grep \"f/failed to publish to 1 invalid topic\" \
        \"${psmqp_stderr}\""
}
psmq_pub_from_stdin_multi_line()
{
    start_psmqs
    # -2 since line consists of "\n\0"
    # -3 since topic is 3 bytes long "/1\0";
    msg1="$(randstr $((psmq_msg_max - 3 - 2)) )"
    msg2="$(randstr $((psmq_msg_max - 3 - 2)) )"
    msg3="$(randstr 1)"
    msg4="$(randstr $((psmq_msg_max - 3 - 2)) )"
    msg5="$(randstr 1)"

    printf "%s\n%s\n%s\n%s\n%s\n" ${msg1} ${msg2} ${msg3} ${msg4} ${msg5} | \
        ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 2> ${psmqp_stderr}
    mt_fail "psmq_grep $(echo ${msg1} | cut -c-16) \"${psmqs_stdout}\""
    mt_fail "psmq_grep $(echo ${msg2} | cut -c-16) \"${psmqs_stdout}\""
    mt_fail "psmq_grep $(echo ${msg3} | cut -c-16) \"${psmqs_stdout}\""
    mt_fail "psmq_grep $(echo ${msg4} | cut -c-16) \"${psmqs_stdout}\""
    mt_fail "psmq_grep $(echo ${msg5} | cut -c-16) \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_with_prio()
{
    start_psmqs
    msg="m"
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -m${msg} -p2
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: 2, payload\" \
        \"${psmqs_stdout}\""
    mt_fail "psmq_grep \"${msg}.\" \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_with_invalid_prio()
{
    start_psmqs
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -mt -p7812364 \
        2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/failed to publish, invalid prio 7812364\" \
        \"${psmqp_stderr}\""
    stop_psmqs
}
psmq_pub_from_stdin_with_prio()
{
    start_psmqs
    echo t | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: 3, payload\" \
        \"${psmqs_stdout}\""
    mt_fail "psmq_grep \"t..\" \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_empty_message()
{
    start_psmqs
    ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2 -e
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: 0\" \
        \"${psmqs_stdout}\""
    stop_psmqs
}
psmq_pub_binary_single()
{
    start_psmqs
    msg=$(mktemp)
    count=$((psmq_msg_max - 1 - 3))
    dd if=/dev/urandom of=$msg bs=1 count=${count} 2>/dev/null
    cat $msg | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2 -B
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: $count, \" \
        \"${psmqs_stdout}\""
    rm $msg
    stop_psmqs
}
psmq_pub_binary_max()
{
    start_psmqs
    msg=$(mktemp)
    count=$((psmq_msg_max - 3))
    dd if=/dev/urandom of=$msg bs=1 count=${count} 2>/dev/null
    cat $msg | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2 -B
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: $count, \" \
        \"${psmqs_stdout}\""
    rm $msg
    stop_psmqs
}
psmq_pub_binary_split()
{
    start_psmqs
    msg=$(mktemp)
    count=$((psmq_msg_max - 3 + 1))
    splt_count=$((count - 1))
    dd if=/dev/urandom of=$msg bs=1 count=${count} 2>/dev/null
    cat $msg | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2 -B
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: $splt_count\" \
        \"${psmqs_stdout}\""
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: 1, \" \
        \"${psmqs_stdout}\""
    rm $msg
    stop_psmqs
}
psmq_pub_binary_many_split()
{
    start_psmqs
    msg=$(mktemp)
    # 4 full messages + one splitted byte
    count=$((4 * (psmq_msg_max - 3) + 1))
    splt_count=$((psmq_msg_max - 3))
    dd if=/dev/urandom of=$msg bs=1 count=${count} 2>/dev/null
    cat $msg | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p2 -B
    # first check for last split, this will make sure that previous
    # splits are in a log file as well
    mt_fail "psmq_grep \"topic: /1, priority: 2, paylen: 1, \" \
        \"${psmqs_stdout}\""
    # now do custom grep and check if we have 4 full splits
    split_count=$(grep "topic: /1, priority: 2, paylen: $splt_count" \
            $psmqs_stdout | wc -l)
    mt_fail "[ $split_count -eq 4 ]"
    rm $msg
    stop_psmqs
}

psmq_pub_from_stdin_with_invalid_prio()
{
    start_psmqs
    echo t | ${psmqp_bin} -n${psmqp_name} -b${broker_name} -t/1 -p7812364 \
        2> ${psmqp_stderr}
    mt_fail "psmq_grep \"f/failed to publish, invalid prio 7812364\" \
        \"${psmqp_stderr}\""
    stop_psmqs
}
psmqd_log_to_unavailable_file()
{
    ${psmqd_bin} -l7 -p/cant/log/here -b/mq/that/is/unavailable -m12345678 \
        2> ${psmqd_stderr}
    mt_fail "psmq_grep \"w/couldn't open program log file /cant/log/here\" \
        \"${psmqd_stderr}\""
    mt_fail "psmq_grep \"f/mq_open()\" \
        \"${psmqd_stderr}\""
}
psmqd_print_help()
{
    ${psmqd_bin} -h > ${psmqd_stdout}
    mt_fail "psmq_grep \"broker for publish subscribe over mqueue\" \
        \"${psmqd_stdout}\""
}
psmqd_print_version()
{
    ${psmqd_bin} -v > ${psmqd_stdout}
    mt_fail "psmq_grep \"by Michał Łyszczek <michal.lyszczek@bofc.pl>\" \
        \"${psmqd_stdout}\""
}

## ==========================================================================
## ==========================================================================


psmq_progs_simple_pub_sub()
{
    start_psmqs
    msg="$(randstr $((psmq_msg_max - 4)) )"
    ${psmqp_bin} -b${broker_name} -n${psmqp_name} -t/1 -m${msg}
    mt_fail "psmq_grep $(echo ${msg} | cut -c-16) \"${psmqs_stdout}\""
    stop_psmqs
}


## ==========================================================================
#                                             _
#                          ____ ___   ____ _ (_)____
#                         / __ `__ \ / __ `// // __ \
#                        / / / / / // /_/ // // / / /
#                       /_/ /_/ /_/ \__,_//_//_/ /_/
#
## ==========================================================================


start_psmqd

mt_run psmq_progs_simple_pub_sub
mt_run psmq_sub_print_help
mt_run psmq_sub_print_version
mt_run psmq_sub_broker_doesnt_exist
mt_run psmq_sub_qname_too_long
mt_run psmq_sub_output_file_does_not_exit
mt_run psmq_sub_topic_before_broker
mt_run psmq_sub_invalid_broker_name
mt_run psmq_sub_invalid_queue_name
mt_run psmq_sub_missing_argument
mt_run psmq_sub_unknown_argument
mt_run psmq_sub_no_arguments
mt_run psmq_sub_invalid_topic
mt_run psmq_sub_broker_go_down_before_client
mt_run psmq_pub_print_help
mt_run psmq_pub_print_version
mt_run psmq_pub_broker_doesnt_exist
mt_run psmq_pub_qname_too_long
mt_run psmq_pub_message_too_long
mt_run psmq_pub_invalid_broker_name
mt_run psmq_pub_invalid_topic
mt_run psmq_pub_invalid_queue_name
mt_run psmq_pub_missing_argument
mt_run psmq_pub_unknown_argument
mt_run psmq_pub_no_arguments
mt_run psmq_pub_missing_b_argument
mt_run psmq_pub_missing_t_argument
mt_run psmq_sub_topic_too_long
mt_run psmq_pub_empty_message
mt_run psmq_pub_binary_single
mt_run psmq_pub_binary_max
mt_run psmq_pub_binary_split
mt_run psmq_pub_binary_many_split


###
# since line is '\n' and then '\0' for sending a string,
# it is not possible to send line when payload is 2
#

mt_run psmq_pub_from_stdin
mt_run psmq_pub_from_stdin_max_line
mt_run psmq_pub_from_stdin_too_long_line
mt_run psmq_pub_from_stdin_multi_line
mt_run psmq_pub_from_stdin_too_long_topic
mt_run psmq_pub_from_stdin_invalid_topic
mt_run psmq_pub_from_stdin_with_prio
mt_run psmq_pub_from_stdin_with_invalid_prio


if [ "$(uname)" != "QNX" ]
then
    ###
    # this test will not work on QNX, since it is impossible
    # there to pass such invalid parameters to crash the broker
    #

    mt_run psmqd_log_to_unavailable_file
fi

mt_run psmq_pub_with_invalid_prio
mt_run psmq_pub_with_prio
mt_run psmqd_print_help
mt_run psmqd_print_version

kill ${psmqd_pid}

mt_return