11 # Setup some variables
12 my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;
20 $res =~ /result=(-?\d+)/;
22 print STDERR
"FAIL ($res)\n";
25 print STDERR
"PASS ($1)\n";
29 print STDERR
"FAIL (unexpected result '$res')\n";
34 socket(SERVER
, PF_INET
, SOCK_STREAM
, 0);
35 setsockopt(SERVER
, SOL_SOCKET
, SO_REUSEADDR
, pack("l", 1));
36 bind(SERVER
, sockaddr_in
($port, INADDR_ANY
)) || die("can't bind\n");
37 listen(SERVER
, SOMAXCONN
);
40 my $raddr = accept(CLIENT
, SERVER
);
41 my ($s, $p) = sockaddr_in
($raddr);
45 last unless length($_);
46 if (/^agi_(\w+)\:\s+(.*)$/) {
50 print STDERR
"AGI Environment Dump from $s:$p --\n";
51 foreach my $i (sort keys %AGI) {
52 print STDERR
" -- $i = $AGI{$i}\n";
55 print STDERR
"1. Testing 'sendfile'...";
56 print CLIENT
"STREAM FILE beep \"\"\n";
57 my $result = <CLIENT
>;
58 &checkresult
($result);
60 print STDERR
"2. Testing 'sendtext'...";
61 print CLIENT
"SEND TEXT \"hello world\"\n";
62 my $result = <CLIENT
>;
63 &checkresult
($result);
65 print STDERR
"3. Testing 'sendimage'...";
66 print CLIENT
"SEND IMAGE asterisk-image\n";
67 my $result = <CLIENT
>;
68 &checkresult
($result);
70 print STDERR
"4. Testing 'saynumber'...";
71 print CLIENT
"SAY NUMBER 192837465 \"\"\n";
72 my $result = <CLIENT
>;
73 &checkresult
($result);
75 print STDERR
"5. Testing 'waitdtmf'...";
76 print CLIENT
"WAIT FOR DIGIT 1000\n";
77 my $result = <CLIENT
>;
78 &checkresult
($result);
80 print STDERR
"6. Testing 'record'...";
81 print CLIENT
"RECORD FILE testagi gsm 1234 3000\n";
82 my $result = <CLIENT
>;
83 &checkresult
($result);
85 print STDERR
"6a. Testing 'record' playback...";
86 print CLIENT
"STREAM FILE testagi \"\"\n";
87 my $result = <CLIENT
>;
88 &checkresult
($result);
90 print STDERR
"================== Complete ======================\n";
91 print STDERR
"$tests tests completed, $pass passed, $fail failed\n";
92 print STDERR
"==================================================\n";