tbtest 17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl -w

# tbtest

# This is the toplevel of the testbed testing setup.  This command
# should be invokved by a user and script.  It well then create a
# separate object tree, configure it appropriately, setup a testing
# database, and then proceed to run tests.

# IMPORTANT: This command should be come from a tree configured 
# for the real DB.

13
# tbtest [options] <mode stuff>
14
15
# Options:
#   -path <path> - Path to test tree, otherwise uses cwd.
16
17
18
#   -full - Do full testing.
#   -frontend - Do frontend only testing.#
#   -leavedb - Avoids removing the DB on exit.
19
#   -exitonfail - Exit on the first failure.
20
#   -session <sessionid> - Specify an alternate session id.
21
#   -flest - Generate flest.log file for flest runs.
22
23
#
# <mode> is one of:
24
#    run <db> <testlist> [<pid> <eid> <num>] - Do everything.
25
#    init <db> [<pid> <eid> <num>] - Initiatlize.  
26
27
#    test <testlist> - Run tests
#    single <tests> - Run only <tests>
28
#    finish - Finish run
29
# <num> is "X <type> ...", for example "10 pc 16 shark"
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

use DBI;
use POSIX;

$| = 1;

$pwd = `/bin/pwd`;
chop $pwd;

# Figure out where the script is
if ($0 =~ m|/|) {
    # Not pwd
    @a = split("/",$0);
    $dir = join("/",@a[0..$#a-1]);
    if ($0 =~ m|^/|) {
	# absolute path
	$basedir = $dir;
    } else {
	# relative path
	chdir $dir;
	$basedir = `/bin/pwd`;
	chop $basedir;
	chdir $pwd;
    }
} else {
    $basedir = `/bin/pwd`;
    chop $basedir;
}

$path = $pwd;

61
$ENV{'PATH'} = "/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/site/bin:$basedir:.";
62
63
64
$basepath = $ENV{'PATH'};

$type = "frontend";
65
66

# Parse argv
67
68
69
70
71
72
sub show_help {
    print STDERR "Syntax: $0 [-leavedb] [-path <path>] [-frontend] [-full] <mode>\n";
    print STDERR "Options:\n";
    print STDERR "  -leavedb - Do not drop the test database on exit.\n";
    print STDERR "  -path <path> - Path to directory to store test files.\n";
    print STDERR "  -frontend - Run in frontend mode.\n";
73
    print STDERR "  -full - Run in full mode.\n";
74
    print STDERR "  -exitonfail - Exit on any failure.\n";
75
    print STDERR "  -session <sessionid> - Specify an alternate session id.\n";
76
    print STDERR "  -flest - Generate flest.log for flest runs.\n";
77
    print STDERR "Mode:\n";
78
    print STDERR "  run <db> <testlist> [<pid> <eid> <num>]\n";
79
    print STDERR "  init <db> [<pid> <eid> <num>]\n";
80
81
    print STDERR "  test <testlist>\n";
    print STDERR "  single <tests>\n";
82
    print STDERR "  finish\n";
83
84
85
86
87
    print STDERR "<num>: Must be even lengthed list of <number> <type>.\n";
    print STDERR "   Ex: \"4 pc 16 shark\"\n";
    print STDERR "Examples:\n";
    print STDERR "   $0 run tbdb frontend\n";
    print STDERR "   $0 -full run tbdb frontend testbed mytest \"10 pc 16 shark\"\n";
88
    print STDERR "   $0 init tbdb;$0 single ping basic;$0 finish\n";
89
90
91
92
93
    exit(1);
};

$mode = "";
$leavedb = 0;
94
$exitonfail = 0;
95
$flestlog = 0;
96
97
$user=`whoami`;
chop $user;
98
99

while (($#ARGV > -1) && ($mode eq "")) {
100
101
    $arg = shift;
    if ($arg eq "-path") {
102
	if ($#ARGV == -1) {show_help;}
103
	$path = shift;
104
105
106
107
108
109
    } elsif ($arg eq "-frontend") {
	$type = "frontend";
    } elsif ($arg eq "-full") {
	$type = "full";
    } elsif ($arg eq "-leavedb") {
	$leavedb = 1;
110
111
    } elsif ($arg eq "-exitonfail") {
	$exitonfail = 1;
112
113
114
    } elsif ($arg eq "-session") {
	if ($#ARGV == -1) {show_help;}
	$user = shift;
115
116
    } elsif ($arg eq "-flest") {
	$flestlog = 1;
117
    } else {
118
	$mode = $arg;
119
120
121
122
    }
}

chdir $path;
123
124
$logfile = "test.log";
$statefile = "state";
125

126
127
128
if ($mode eq "run") {
    if ($type eq "frontend") {
	if ($#ARGV != 1) {show_help;}
129
	($TBDB,$testlist) = @ARGV;
130
131
    } else {
	if ($#ARGV != 4) {show_help;}
132
	($TBDB,$testlist,$pid,$eid,$num) = @ARGV;
133
134
135
136
137
138
139
    }
} elsif ($mode eq "init") {
    if ($type eq "frontend") {
	if ($#ARGV != 0) {show_help;}
	($TBDB) = @ARGV;
    } else {
	if ($#ARGV != 3) {show_help;}
140
	($TBDB,$pid,$eid,$num) = @ARGV;
141
142
143
    }
} elsif ($mode eq "test") {
    if ($#ARGV != 0) {show_help;}
144
    ($testlist) = @ARGV;
145
} elsif ($mode eq "single") {
146
147
    if ($#ARGV == -1) {show_help;}
    (@tests) = @ARGV;
148
    $testlist = "N/A";
149
} elsif ($mode eq "finish") {
150
    if ($#ARGV != -1) {show_help;}
151
152
153
} else {
    print STDERR "Unknown mode: $mode\n";
    show_help;
154
155
}

156
157
158
159
160
161
162
163
164
165
166
if (($mode ne "run") && ($mode ne "init")) {
    # Read state
    open(STATE,$statefile) || do {
	print STDERR "Could not find state file ($statefile).\n";
	print STDERR "  Run in init mode first.\n";
	exit(1);
    };
    ($type,$TBDB,$user,$pid,$eid) = split(" ",<STATE>);
    close(STATE);
}

167
168
169
170
171
172
173
if (($type eq "full") && (($mode eq "init") || ($mode eq "run"))) {
    @t = split(" ",$num);
    if (($#t % 2) == 0) {
	print STDERR "<num> must be list of even length.\n";
	show_help;
    }
}
174
175

$testdb = "tbdb_$user";
176
177
178
179
180

# Test counts
$pass = 0;
$fail = 0;
$unknown = 0;
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200

# prints sends the string to stdout and the logfile.
sub prints {
    print $_[0];
    print LOG $_[0];
};

# tbexec <cmd> <file>
# Executes <cmd> storing results to <file> and displaying appropriate
# message and exiting on failure.
sub tbexec {
    my ($cmd,$file) = @_;
    open(EXEC,"$cmd 2>&1 |");
    open(FILE,"> $file");
    while (<EXEC>) {
	print FILE $_;
    }
    close(FILE);
    close(EXEC);
    if (($? >> 8) == 0) {
Christopher Alfeld's avatar
Christopher Alfeld committed
201
	prints "PASS\n";
202
203
	$pass++;
    } else {
Christopher Alfeld's avatar
Christopher Alfeld committed
204
	prints "FAIL - See $file\n";
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
	$fail++;
	doexit(1);
    }
};

# tbexect <cmd> <logfp>
# This is similar to tbexec except is used for running commands specific
# to tests.  It runs the command appending the output to the file handle
# <logfp> and returns the exit code.
sub tbexect {
    my ($cmd,$logfp) = @_;
    print $logfp "$cmd\n";
    open(EXEC,"$cmd 2>&1 |");
    while (<EXEC>) {
	print $logfp $_;
    }
    close(EXEC);
    return ($? >> 8);
};

# doexit
# This displays exit counts and then exits with the specified exit code.
sub doexit {
    printf LOG "Total Tests: %-5d  Pass: %-5d  Fail: %-5d  Unknown: %-5d\n", $pass+$fail+$unknown, $pass, $fail, $unknown;
    printf "Total Tests: %-5d  Pass: %-5d  Fail: %-5d  Unknown: %-5d\n", $pass+$fail+$unknown, $pass, $fail, $unknown;
230
231
    if ($_[0] != 0) {
	prints "Run in finish mode to clean up any residual state.\n";
232
    }
233
    close(LOG);
234
235
236
    exit($_[0]);
};

237
238
239
240
241
242
243
244
245
246
247
# These are flest routines
sub pass {
    if ($flestlog) {
	print FLESTLOG "PASS $_[0]\n";
    }
};
sub fail {
    if ($flestlog) {
	print FLESTLOG "FAIL $_[0]\n";
    }
};
248
249
250
251
252
sub fail2 {
    if ($flestlog) {
	print FLESTLOG "FAIL: $_[0]\n";
    }
}
253

254
255
sub step_init {
    open(LOG,"> $logfile");
256

257
    prints "START INIT\n";
258
    prints "Session:  $user\n";
259
260
    prints "Logfile:  $logfile\n";
    prints "Database: $TBDB\n";
261
    prints "Type:     $type\n";
262
    prints "\n";
263
    prints "Beginning test run. " . ctime(time);
264

265
266
267
268
269
270
    # Initialize DB
    $dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") || 
	die "Could not connect to DB.\n";
    # Having made sure we can, we now disconnect so as not to harm DB.
    $dbh->disconnect;

271
272
273
274
275
276
277
278
279
    # Write state
    open(STATE,"> $statefile");
    if ($type eq "full") {
	print STATE "$type $TBDB $user $pid $eid\n";
    } else {
	print STATE "$type $TBDB $user\n";
    }
    close(STATE);

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
    # Reserve nodes
    if ($type eq "full") {
	prints "Reserving nodes.\n";
	
	my (@nums) = split(" ",$num);
	my $num;
	my $type;
	my %want;
	my %have;
	my $node;

	while ($#nums > -1) {
	    $num = shift @nums;
	    $type = shift @nums;
	    $want{$type} = $num;
	    $have{$type} = [];
	}
	
	open(AVAIL,"/usr/testbed/sbin/avail |");
	while (<AVAIL>) {
	    if (! /^\|/) {next};
	    if (/node_id/) {next;}
	    ($node,$type) = /^\|([-a-zA-Z0-9]+)\s*\|(\w+)\s*\|$/;
	    if (defined($want{$type}) && $want{$type} > 0) {
		push(@{$have{$type}},$node);
		$want{$type}--;
	    }
	}
	close(AVAIL);

	my $good = 1;
	foreach $type (keys(%want)) {
	    if ($want{$type} > 0) {
		print STDERR "Could not get enough $type - Need $want{$type} more.\n";
		$good = 0;
	    }
	}
	if (! $good) {exit(1);}

	my $raw = "";
	foreach $type (keys(%have)) {
	    $raw .= join(" ",@{$have{$type}});
	}
	prints "  Reserving ";
	tbexec("/usr/testbed/bin/nalloc $pid $eid $raw","$path/reserve.log");
325
326
327
328

	prints "  Setting up tmcc redirect ";
	$dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") || 
	    die "Could not connect to DB.\n";
329
330
331
332
333
334
335
	$dbh->do("UPDATE experiments set testdb=\"$testdb\" where" .
		 " pid=\"$pid\" and eid=\"$eid\"") || do {
		     prints "FAIL\n";
		     $fail++;
		     doexit(1);
		 };
	$pass++;
336
337
	prints "PASS\n";
	$dbh->disconnect;
338
339
    }

340
341
342
343
    # Set up object tree
    prints "Setting up object tree.\n";
    if (! -d $path) {
	mkdir $path,0755;
344
    }
345
346
347
348
    mkdir "tbobj",0755;
    mkdir "install",0755;
    chdir "tbobj";
    system("cp -f $basedir/test-defs $path/defs");
349
350
351
352
    if (($? >> 8) != 0) {
	print STDERR "ERROR: Could not copy defs file.\n";
	doexit(1);
    }
353
354
355
356
357
358
359
    open(DEFS,">>$path/defs");
    print DEFS "TBDBNAME=$testdb\n";
    print DEFS "TBOPSEMAIL=$user\@emulab.net\n";
    print DEFS "TBLOGSEMAIL=$user\@emulab.net\n";
    close(DEFS);
    
    prints "  Configuring ";
360
361
362
363
364
365
366
    my $testmode;
    if ($type eq "full") {
	$testmode = "";
    } else {
	$testmode = "--enable-testmode";
    }
    tbexec("$basedir/../configure --prefix=$path/install $testmode ".
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
	   "--with-TBDEFS=$path/defs --with-LEDA=/usr/testbed/LEDA/LEDA-4.0",
	   "$path/configure.log");
    
    prints "  Building ";
    tbexec("gmake","$path/build.log");
    
    prints "  Installing ";
    tbexec("gmake boss-install","$path/install.log");
    
    prints "  Post-Installing ";
    tbexec("su1 gmake post-install","$path/postinstall.log");
        
    chdir $path;
    
    # Setup test database
    prints "Setting up test database.\n";
    prints "  Dumping Current ";
    tbexec("mysqldump $TBDB","$path/dbdump.txt");
385
    # Now add a line to the dumped database that sets flest as an admin
Christopher Alfeld's avatar
Christopher Alfeld committed
386
    prints "  Setting up flest admin account ";
387
    tbexec("echo \"update users set admin=1 where uid='flest';\"".
388
	   " >> $path/dbdump.txt", "dbdump.log");
389
390
    
    prints "  Creating DB ";
391
    system("echo \"drop database if exists $testdb\" | mysql");
392
393
394
395
    tbexec("echo \"create database $testdb\" | mysql","createdb.log");
    
    prints "  Filling DB ";
    tbexec("cat $path/dbdump.txt | mysql $testdb","fill.log");
396
397


398
399
    $dbh = DBI->connect("DBI:mysql:database=$testdb;host=localhost") || do {
	prints "ERROR: Could not connect to new DB.\n";
400
	doexit(1);
401
402
    };
    $ENV{'PATH'} = "$basepath:$path/install/bin:$path/install/sbin";    
403
404
405
406
407

    if ($type eq "frontend") {
	# Clear out experiments and set up test experiment.     
	prints "  Clearing out existing experiments ";
	open(CLEARLOG,"> clear.log");
408
409
	$sth = $dbh->prepare("SELECT pid,eid from experiments ".
			     "where !(pid='emulab-ops' and eid='hwdown')");
410
411
412
	$sth->execute;
	while (($pid,$eid) = $sth->fetchrow_array) {
	    print CLEARLOG "$pid $eid\n";
413
414
	    print CLEARLOG "tbswapout -force $pid $eid\n";
	    open(EXEC,"tbswapout -force $pid $eid 2>&1 |");
415
416
417
418
419
420
421
422
423
	    while (<EXEC>) {
		print CLEARLOG $_;
	    }
	    close(EXEC);
	    if (($? >> 8) != 0) {
		prints "FAIL - For $pid $eid - On tbswapout - See clear.log\n";
		$fail++;
		doexit(1);
	    } 
424
425
	    print CLEARLOG "tbend $pid $eid\n";
	    open(EXEC,"tbend $pid $eid 2>&1 |");
426
427
428
429
430
431
432
433
434
	    while (<EXEC>) {
		print CLEARLOG $_;
	    }
	    close(EXEC);
	    if (($? >> 8) != 0) {
		prints " FAIL - For $pid $eid - On tbend - See clear.log\n";
		$fail++;
		doexit(1);
	    }   
435
	}
436
	# now we clear 
437
438
	$dbh->do("delete from reserved ".
		 "where pid='emulab-ops' and eid!='hwdown'") || do {
439
440
441
442
443
	    prints "FAIL\n";
	    $fail++;
	    doexit(1);
	};

444
445
446
447
448
449
450
	prints "PASS\n";
	$pass++;

	close(CLEARLOG);
    } else {
	# Free nodes we allocated for the experiment and allocate all
	# others.
451
	prints "  Creating testbed/unavailable in test DB ";
452
453
454
455
456
457
458
	open(AVAIL,"avail |");
	$raw = "";
	while (<AVAIL>) {
	    if (! /^\|/) {next};
	    if (/node_id/) {next;}
	    ($node) = /^\|([-a-zA-Z0-9]+)/;
	    $raw .= " $node";
459
	}
460
461
462
463
464
465
466
467
468
469
470
	close(AVAIL);
	
	$dbh->do("DELETE from experiments where pid=\"testbed\" and eid=\"unavailable\"");
	$dbh->do("INSERT into experiments (pid,eid) "
		 . "values (\"testbed\",\"unavailable\")") || do {
		     prints "FAIL\n";
		     $fail++;
		     doexit(1);
		 };
	print "PASS\n";
	$pass++;
471

472
473
	prints "  Marking nodes as unavailable ";
	tbexec("nalloc testbed unavailable $raw","unavailable.log");
474

475
476
477
478
	prints "  Freeing test nodes ";
	tbexec("nfree $pid $eid","free.log");
    }
    
479
480
481
482
483
484
485
486
487
488
489
490
491
492
    prints "  Setting up test experiment ";
    $dbh->do("DELETE from experiments where pid=\"testbed\" and eid=\"test\"");
    $dbh->do("INSERT into experiments (pid,eid) "
	     . "values (\"testbed\",\"test\")") || do {
		 prints "FAIL\n";
		 $fail++;
		 doexit(1);
	     };
    print "PASS\n";
    $pass++;
    
    prints "  Snapshotting clean state ";
    tbexec("mysqldump $testdb","clean.txt");
    prints "END INIT\n";
493
494
}

495
496
497
498
499
sub step_test {
    open(LOG,">> $logfile");
    
    prints "START TEST\n";
    
500
501
502
503
504
505
    if ($flestlog) {
	open(FLESTLOG,"> flest.log");
    }
    
    pass("Pre-Test Setup");

506
507
    # Time to run tests!
    prints "Running Tests\n";
508
    prints "Testlist: $testlist\n";
509

510
511
512
513
514
515
516
517
    # Let's add some stuff to our path
    $ENV{'PATH'} = "$basepath:$path/install/bin:$path/install/sbin";
    
    my @tests;
    my $testmode;
    my $dir;

    if ($#_ == -1) {
518
519
520
521
522
523
524
	open(TESTLIST,"$basedir/testlists/$testlist");
	@tests = ();
	while (<TESTLIST>) {
	    chop;
	    push(@tests,$_);
	}
	close(TESTLIST);
525
526
    } else {
	@tests = @_;
527
528
    }

529
530
531
    mkdir "tests",0755;
    foreach $test (@tests) {
	if (($test eq ".") || ($test eq "..") || ($test eq "CVS")) {
532
533
	    next;
	}
534
535
	prints "  $test ";
	
536
537
	mkdir "tests/$test",0755;
	chdir "tests/$test";
538
539
540
541
542
543
	open(TESTLOG,"> test.log");
	
	# Set up DB state
	if (tbexect("echo \"drop database if exists $testdb\" | mysql",TESTLOG)) {
	    prints "FAIL - Could not drop test DB.\n";
	    prints "Failure was FATAL - Exiting.\n";
544
	    fail2("$test - Drop test DB");
545
546
547
548
549
550
	    $fail++;
	    doexit(1);
	}
	if (tbexect("echo \"create database $testdb\" | mysql",TESTLOG)) {
	    prints "FAIL - Could not recreate test DB.\n";
	    prints "Failure was FATAL - Exiting.\n";
551
	    fail2("$test - Recreate test DB");
552
	    $fail++;
553
554
555
556
557
	    doexit(1);
	}
	if (tbexect("cat $path/clean.txt | mysql $testdb",TESTLOG)) {
	    prints "FAIL - Could not populate test DB.\n";
	    prints "Failure was FATAL - Exiting.\n";
558
	    fail2("$test - Populate test DB");
559
560
561
562
	    $fail++;
	    doexit(1);
	}
	
563
564
	if (-f "$basedir/tests/$test/dbstate") {
	    if (tbexect("cat $basedir/tests/$test/dbstate | mysql $testdb",TESTLOG)) {
565
		prints "FAIL - Could not evaluate dbstate.\n";
566
		fail2("$test - Evaluate dbstate");
567
		$fail++;
568
		if ($exitonfail) {doexit(1);}
569
		next;
Christopher Alfeld's avatar
Christopher Alfeld committed
570
	    }
571
572
573
574
575
576
577
	}
	
	# We're now ready to run the test.
	
	# The last line of this command will be either PASS
	# or FAIL <msg>, all output before that should be sent 
	# to the log file.
578
	open(TESTFP,"tbstub $testdb testbed test $test $basedir/tests/$test |");
579
580
581
582
583
584
585
586
	while (<TESTFP>) {
	    print TESTLOG $_;
	    $status = $_;
	}
	chop $status;
	close(TESTFP);
	if (($? >> 8) != 0) {
	    prints "UNKNOWN - Test exited with non-0 code.\n";
587
	    $unknown++;
588
589
590
591
592
593
594
595
596
597
598
	} else {
	    if ($status =~ /^PASS/) {
		$pass++;
	    } elsif ($status =~ /^FAIL/) {
		$fail++;
		# grab copy of testbed
		system("mysqldump $testdb > db.txt");
		if (($? >> 8) != 0) {
		    prints "ERROR: Could not grab copy of database.\n";
		    doexit(1);
		}
599
		if ($exitonfail) {prints "FAIL\n"; doexit(1);}
600
601
	    } else {
		$unknown++;
602
		$status = "UKNOWN";
603
604
	    }
	    prints "$status\n";
605
606
607
608
	    if ($flestlog) {
		@t = split(" ",$status);
		$result = $t[0];
		$msg = join(" ",@t[1..$#t]);
609
		print FLESTLOG "$result: $test $msg\n";
610
	    }
611
	}
612
613
614
615
	
	close(TESTLOG);
	
	chdir $path;
616
    }
617
618
619
    if ($flestlog) {
	close FLESTLOG;
    }
620
    prints "END TEST\n";
621
}
622
   
623
624
sub step_cleanup {
    open(LOG,">> $logfile");
625
626
    
    prints "START cleanup\n";
627

628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
    # Try to do the necessary cleanup
    if ($leavedb == 0) {
	prints "  Dropping test DB ";
	system("echo \"drop database if exists $testdb\" | mysql");
	if (($? >> 8) != 0) {
	    prints "FAIL\n";
	    $fail++;
	} else {
	    prints "PASS\n";
	    $pass++;
	}
    }
    if (($type eq "full")) { 	
	prints "  Clearing redirects ";
	$ok = 1;
	$dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost") || do {
	    $ok = 0;
	};
	if (! $ok) {
	    prints "FAIL - Could not connect to db\n";
	    $fail++;
	} else {
	    $ok = 1;
651
652
653
654
	    $dbh->do("UPDATE experiments set testdb=NULL" .
		     " where pid=\"$pid\" and eid=\"$eid\"") || do {
			 $ok = 0;
		     };
655
	    if ($ok) {
656
		$pass++;
657
		prints "PASS\n";
658
659
660
	    } else {
		$fail++;
		prints "FAIL\n";
661
662
663
	    }
	    $dbh->disconnect;
	}
664

665
666
667
668
669
670
	prints "  Freeing nodes ";
	system("/usr/testbed/bin/nfree $pid $eid > /dev/null");
	if (($? >> 8) != 0) {
	    prints "FAIL\n";
	    $fail++;
	} else {
671
	    prints("PASS\n");
672
673
	    $pass++;
	}
674
    }
675
676
677
678
679
680
681
682
683
    prints "  Clearing state ";
    system("rm -f $statefile");
    if (($? >> 8) != 0) {
	prints "FAIL\n";
	$fail++;
    } else {
	prints "PASS\n";
	$pass++;
    }
684
    prints "End test run. " . ctime(time);
685
686
    prints "END CLEANUP\n";
}
687
688

	     
689
690
691
692
693
694
695
696
697
698
699
700
701
if ($mode eq "run") {
    step_init;
    step_test;
    step_cleanup;
} elsif ($mode eq "init") {
    step_init;
} elsif ($mode eq "test") {
    step_test;
} elsif ($mode eq "single") {
    step_test @tests;
} elsif ($mode eq "finish") {
    step_cleanup;
}
702

703
704
open(LOG,">> $logfile");

705
706
# Do exit does all cleanup.
doexit(0);