Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 302 lines (234 sloc) 5.329 kB
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
1 use Cwd;
2 use Config;
2666536 @perusionmike Changed test.pl to use Errno.pm to derive socket test error messages.
perusionmike authored
3 use Errno;
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
4
5 $cur_dir = cwd();
6 $failed = 0;
7
b31a690 @jonjensen Move DEV_4_7_0 development branch to repository trunk.
jonjensen authored
8 if($^O =~ /cygwin|win32/) {
9 print "no tests supported on Windows platform.\n";
10 exit;
11 }
12
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
13 die "Must be in build directory\n" unless -d 'blib';
14 die "No tests defined for Windows\n" if $^O =~ /win32/i;
15
16 $ENV{MINIVEND_ROOT} = "$cur_dir/blib";
17 $ENV{MINIVEND_PORT} = 8786 unless defined $ENV{MINIVEND_PORT};
18
d4330cc @perusionmike Change minivend.cfg to interchange.cfg, etc.
perusionmike authored
19 open(CONFIG, ">$ENV{MINIVEND_ROOT}/interchange.cfg")
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
20 or die "open: $!\n";
21
22 print CONFIG <<EOF;
23 Catalog test $ENV{MINIVEND_ROOT} /test
24 TcpMap $ENV{MINIVEND_PORT} -
3c05294 @perusionmike * Keep test from giving warning about not being able to stat
perusionmike authored
25 TagDir 0
26 TagDir etc
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
27 EOF
28
29 open(CONFIG, ">$ENV{MINIVEND_ROOT}/catalog.cfg")
30 or die "open: $!\n";
31
a5878f0 @jonjensen Update some old URLs and Red Hat references.
jonjensen authored
32 print CONFIG <<'EOF';
33 MailOrderTo info@icdevgroup.org
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
34 VendURL http:/test
35 SecureURL http:/test
36 Database products products.asc DEFAULT
37 EOF
38
39 mkdir ("$ENV{MINIVEND_ROOT}/etc", 0777);
40 mkdir ("$ENV{MINIVEND_ROOT}/pages", 0777);
41 mkdir ("$ENV{MINIVEND_ROOT}/products", 0777);
42 mkdir ("$ENV{MINIVEND_ROOT}/session", 0777);
43 if( $ENV{PERL5LIB} ) {
44 $ENV{PERL5LIB} .= ":$cur_dir/extra:$cur_dir/blib/lib";
45 }
46 else {
47 $ENV{PERL5LIB} = "$cur_dir/extra:$cur_dir/blib/lib";
48 }
49
50 my $testnum = 1;
51
52 open(CONFIG, ">$ENV{MINIVEND_ROOT}/products/products.asc")
53 or die "open: $!\n";
54
55 print CONFIG <<EOF;
56 sku description price
57 test test product 1
58 EOF
59
60 open(CONFIG, ">$ENV{MINIVEND_ROOT}/pages/catalog.html")
61 or die "open: $!\n";
62
63 for(1 .. 100) {
64 print CONFIG <<EOF;
65 test succeeded test succeeded
66 EOF
67 }
68
69 close CONFIG;
70
71 $| = 1;
72
73 print "server/unixmode.......";
ca460c8 s:blib/script/minivend:blib/script/interchange:
Eric Zarko authored
74 if ( system qq{$Config{'perlpath'} blib/script/interchange -q -r -u} ) {
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
75 print "not ok $testnum\n";
76 $failed++;
77 }
78 else {
79 print "ok $testnum\n";
80 }
81 $testnum++;
82
83 print "server/startup........";
84 for(1 .. 5) {
d4330cc @perusionmike Change minivend.cfg to interchange.cfg, etc.
perusionmike authored
85 open(PID, "$ENV{MINIVEND_ROOT}/etc/interchange.pid") or sleep $_, next;
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
86 $pid = <PID>;
87 $pid =~ s/\D+//g;
88 last;
89 }
90
91 for(1 .. 5) {
92 unless (-e "$ENV{MINIVEND_ROOT}/etc/socket") {
93 system "ls -l $ENV{MINIVEND_ROOT}/*";
94 sleep $_;
95 next;
96 }
97 $LINK_FILE = "$ENV{MINIVEND_ROOT}/etc/socket";
98 last;
99 }
100
101 if(! $pid or ! $LINK_FILE) {
102 print "not ok $testnum\n";
103 $failed++;
104 }
105 else {
106 print "ok $testnum\n";
107 }
108 $testnum++;
109
110 use Socket;
8ef654a @jonjensen Use 127.0.0.1 instead of localhost for default INET host values to avoid
jonjensen authored
111 my $LINK_HOST = '127.0.0.1';
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
112 my $LINK_PORT = $ENV{MINIVEND_PORT};
113 my $LINK_TIMEOUT = 15;
114 my $ERROR_ACTION = "-none";
115
116 $ENV{SCRIPT_NAME} = "/test";
117 $ENV{PATH_INFO} = "/catalog";
118 $ENV{REMOTE_ADDR} = "TEST";
119 $ENV{REQUEST_METHOD} = "GET";
120
121 sub send_arguments {
122
123 my $count = @ARGV;
124 my $val = "arg $count\n";
125 for(@ARGV) {
126 $val .= length($_);
127 $val .= " $_\n";
128 }
129 return $val;
130 }
131
132 sub send_environment () {
133 my (@tmp) = keys %ENV;
134 my $count = @tmp;
135 my ($str);
136 my $val = "env $count\n";
137 for(@tmp) {
138 $str = "$_=$ENV{$_}";
139 $val .= length($str);
140 $val .= " $str\n";
141 }
142 return $val;
143 }
144
145 $SIG{PIPE} = sub { die("signal"); };
146 $SIG{ALRM} = sub { die("not communicating with server\n"); exit 1; };
147
148
149
150 print "link/unixmode.........";
151 eval {
152 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!\n";
153
154 my $ok;
155 do {
156 $ok = connect(SOCK, sockaddr_un($LINK_FILE));
2666536 @perusionmike Changed test.pl to use Errno.pm to derive socket test error messages.
perusionmike authored
157 } while ( ! defined $ok and $!{EINTR} || $!{ENOENT});
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
158
159 my $undef = ! defined $ok;
160 die "ok=$ok def: $undef connect: $!\n" if ! $ok;
161
162 select SOCK;
163 $| = 1;
164 select STDOUT;
165
166 print SOCK send_arguments();
167 print SOCK send_environment();
168 print SOCK "end\n";
169
170
171 while(<SOCK>) {
172 $result .= $_;
173 }
174
175 close (SOCK) or die "close: $!\n";
176
177 };
178
179 if(length($result) > 500 and $result =~ /test succeeded/i) {
180 print "ok $testnum\n";
181 }
182 else {
183 print "not ok $testnum";
184 print " ($@)" if $@;
185 print "\n";
186 print <<EOF;
187
188 # When the above test fails, it may be due to your ISP or some other
189 # mechanism blocking port 8786.
190
191 EOF
192 $failed++;
193 }
194 $testnum++;
195
196 print "server/inetmode.......";
ca460c8 s:blib/script/minivend:blib/script/interchange:
Eric Zarko authored
197 if ( system qq{$Config{'perlpath'} blib/script/interchange -q -r -i} ) {
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
198 print "not ok $testnum\n";
199 $failed++;
200 }
201 else {
202 print "ok $testnum\n";
203 }
204 $testnum++;
205
206 alarm 0;
207 alarm $LINK_TIMEOUT;
208
209 $result = '';
210
211 print "link/inetmode.........";
212 eval {
213 $remote = $LINK_HOST;
214 $port = $LINK_PORT;
215
216 if ($port =~ /\D/) { $port = getservbyname($port, 'tcp'); }
217
218 die("no port") unless $port;
219
220 $iaddr = inet_aton($remote);
221 $paddr = sockaddr_in($port,$iaddr);
222
223 $proto = getprotobyname('tcp');
224
225 socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!\n";
226
227 my $ok;
228
229 do {
230 $ok = connect(SOCK, $paddr);
2666536 @perusionmike Changed test.pl to use Errno.pm to derive socket test error messages.
perusionmike authored
231 } while ( ! defined $ok and $!{EINTR});
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
232
233 my $undef = ! defined $ok;
234 die "ok=$ok def: $undef connect: $!\n" if ! $ok;
235
236 select SOCK;
237 $| = 1;
238 select STDOUT;
239
240 print SOCK send_arguments();
241 print SOCK send_environment();
242 print SOCK "end\n";
243
244
245 while(<SOCK>) {
246 $result .= $_;
247 }
248
249 close (SOCK) or die "close: $!\n";
250
251 };
252
253 alarm 0;
254
255 if(length($result) > 500 and $result =~ /test succeeded/i) {
256 print "ok $testnum\n";
257 }
258 else {
259 print "not ok $testnum\n";
260 $failed++;
261 }
262 $testnum++;
263
264 print "server/control........";
ca460c8 s:blib/script/minivend:blib/script/interchange:
Eric Zarko authored
265 if ( system qq{$Config{'perlpath'} blib/script/interchange -q -stop} ) {
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
266 print "not ok $testnum\n";
267 $failed++;
268 }
269
270 my $pid_there;
271
272 for(1 .. 5) {
d4330cc @perusionmike Change minivend.cfg to interchange.cfg, etc.
perusionmike authored
273 $pid_there = -f 'blib/etc/interchange.pid';
5550c3a @perusionmike Initial import of changed Challenger with UI instead of Minimate.
perusionmike authored
274 last unless $pid_there;
275 sleep 1;
276 }
277
278 if ($pid_there) {
279 print "not ok $testnum\n";
280 $failed++;
281 }
282 else {
283 print "ok $testnum\n";
284 }
285 $testnum++;
286
287
288 $testnum--;
289 print "$testnum tests run";
290 if($failed) {
291 print " -- $failed/$testnum failed.\n";
292 exit 1;
293 }
294 else {
295 print ", all tests successful.\n";
296 exit 0;
297 }
298
299 END {
300 kill 'KILL', $pid if $pid;
301 }
Something went wrong with that request. Please try again.