Add an input buffer (currently 32kB) to speed things up heaps, it still requires...
[oweals/busybox.git] / tests / multifeat.pl
1 #!/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 CONFIG_APPLET lines
15 # (most thorough testing occurs when you call it with the -all switch)
16 if ($ARGV[0] eq "-all" ) { shift(@ARGV); $choice="all"; }
17 if ($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 CONFIG_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
27 unlink($logfile);
28
29 # Parse the config file
30 open(C,"<Config.h.orig") || die;
31 $in_applist=1;
32 $in_features=0;
33 $in_olympus=0;
34 while (<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 CONFIG_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 }
56 close C;
57
58 # Do the real work ...
59 $failed_tests=0;
60 for $f (@features) {
61         # print "Testing build with feature $f ...\n";
62         open (O, ">Config.h") || die;
63         print O $header, "#define CONFIG_FEATURE_$f\n", $trailer;
64         close O;
65         system("echo -e '\n***\n$f\n***' >>$logfile");
66         # 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");
70         $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
75         select(undef, undef, undef, 0.03);
76 }
77
78 # Clean up our mess
79 system("mv -f Config.h.orig Config.h");
80
81 print "$total_tests applets tested, $failed_tests failures\n";
82 print "See $logfile for details.\n";
83