Skip to content

HTTPS clone URL

Subversion checkout URL

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