blob: adcb30bbd6d497a015ddd004804d2c8ce94c5b0c [file] [log] [blame]
Mark Whitley9ba5bce2001-03-09 01:46:45 +00001#!/usr/bin/perl
2#
3# multifeat.pl
4#
5# Turns on all applets, then tests turning on one feature at a time through
6# iterative compilations. Tests if any features depend on each other in any
7# weird ways or such-like problems.
8#
9# Hacked by Mark Whitley, but based *heavily* on multibuild.pl which was
10# written by Larry Doolittle.
11
12$logfile = "multifeat.log";
13
14# How to handle all the BB_APPLET lines
15# (most thorough testing occurs when you call it with the -all switch)
16if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
17if ($ARGV[0] eq "-none") { shift(@ARGV); $choice="none"; }
18# neither means, leave that part of Config.h alone
19
20# Support building from pristine source
21$make_opt = "-f $ARGV[0]/Makefile BB_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
22
23# Move the config file to a safe place
24-e "Config.h.orig" || 0==system("mv -f Config.h Config.h.orig") || die;
25
26# Clear previous log file, if any
27unlink($logfile);
28
29# Parse the config file
30open(C,"<Config.h.orig") || die;
31$in_applist=1;
32$in_features=0;
33$in_olympus=0;
34while (<C>) {
35 if ($in_applist) {
36 s/^\/\/#/#/ if ($choice eq "all");
37 s/^#/\/\/#/ if ($choice eq "none");
38 $header .= $_;
39 if (/End of Applications List/) {
40 $in_applist=0;
41 $in_features=1
42 }
43 }
44 elsif ($in_features) {
45 if (/^\/*#define BB_FEATURE_([A-Z0-9_]*)/) {
46 push @features, $1;
47 }
48 if (/End of Features List/) {
49 $in_features=0;
50 $in_olympus=1
51 }
52 } elsif ($in_olympus) {
53 $trailer .= $_;
54 }
55}
56close C;
57
58# Do the real work ...
59$failed_tests=0;
60for $f (@features) {
61 # print "Testing build with feature $f ...\n";
62 open (O, ">Config.h") || die;
63 print O $header, "#define BB_FEATURE_$f\n", $trailer;
64 close O;
65 system("echo -e '\n***\n$f\n***' >>$logfile");
Mark Whitley056960d2001-03-15 22:14:26 +000066 # With a fast computer and 1-second resolution on file timestamps, this
67 # process pushes beyond the limits of what unix make can understand.
68 # That's why need to weed out obsolete files before restarting make.
69 $result{$f} = system("rm -f *.o applet_source_list; make $make_opt busybox >>$logfile 2>&1");
Mark Whitley9ba5bce2001-03-09 01:46:45 +000070 $flag = $result{$f} ? "FAILED!!!" : "ok";
71 printf("Feature %-20s: %s\n", $f, $flag);
72 $total_tests++;
73 $failed_tests++ if $flag eq "FAILED!!!";
74 # pause long enough to let user stop us with a ^C
Mark Whitley056960d2001-03-15 22:14:26 +000075 select(undef, undef, undef, 0.03);
Mark Whitley9ba5bce2001-03-09 01:46:45 +000076}
77
78# Clean up our mess
79system("mv -f Config.h.orig Config.h");
80
81print "$total_tests applets tested, $failed_tests failures\n";
82print "See $logfile for details.\n";
83