Fix samples vs. length calculations for g722
[asterisk-bristuff.git] / agi / agi-test.agi
blob4fc36eda8a1fed2b389ebc386bec5ed459e4a6c1
1 #!/usr/bin/perl
2 use strict;
4 $|=1;
6 # Setup some variables
7 my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;
9 while(<STDIN>) {
10 chomp;
11 last unless length($_);
12 if (/^agi_(\w+)\:\s+(.*)$/) {
13 $AGI{$1} = $2;
17 print STDERR "AGI Environment Dump:\n";
18 foreach my $i (sort keys %AGI) {
19 print STDERR " -- $i = $AGI{$i}\n";
22 sub checkresult {
23 my ($res) = @_;
24 my $retval;
25 $tests++;
26 chomp $res;
27 if ($res =~ /^200/) {
28 $res =~ /result=(-?\d+)/;
29 if (!length($1)) {
30 print STDERR "FAIL ($res)\n";
31 $fail++;
32 } else {
33 print STDERR "PASS ($1)\n";
34 $pass++;
36 } else {
37 print STDERR "FAIL (unexpected result '$res')\n";
38 $fail++;
42 print STDERR "1. Testing 'sendfile'...";
43 print "STREAM FILE beep \"\"\n";
44 my $result = <STDIN>;
45 &checkresult($result);
47 print STDERR "2. Testing 'sendtext'...";
48 print "SEND TEXT \"hello world\"\n";
49 my $result = <STDIN>;
50 &checkresult($result);
52 print STDERR "3. Testing 'sendimage'...";
53 print "SEND IMAGE asterisk-image\n";
54 my $result = <STDIN>;
55 &checkresult($result);
57 print STDERR "4. Testing 'saynumber'...";
58 print "SAY NUMBER 192837465 \"\"\n";
59 my $result = <STDIN>;
60 &checkresult($result);
62 print STDERR "5. Testing 'waitdtmf'...";
63 print "WAIT FOR DIGIT 1000\n";
64 my $result = <STDIN>;
65 &checkresult($result);
67 print STDERR "6. Testing 'record'...";
68 print "RECORD FILE testagi gsm 1234 3000\n";
69 my $result = <STDIN>;
70 &checkresult($result);
72 print STDERR "6a. Testing 'record' playback...";
73 print "STREAM FILE testagi \"\"\n";
74 my $result = <STDIN>;
75 &checkresult($result);
77 print STDERR "================== Complete ======================\n";
78 print STDERR "$tests tests completed, $pass passed, $fail failed\n";
79 print STDERR "==================================================\n";