blob: 875b4a2773874224c3a8418cee56a6b0e4b9d185 [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
Eric Andersenbdfd0d72001-10-24 05:00:29 +000014# How to handle all the CONFIG_APPLET lines
Mark Whitley9ba5bce2001-03-09 01:46:45 +000015# (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
Eric Andersenbdfd0d72001-10-24 05:00:29 +000021$make_opt = "-f $ARGV[0]/Makefile CONFIG_SRC_DIR=$ARGV[0]" if ($ARGV[0] ne "");
Mark Whitley9ba5bce2001-03-09 01:46:45 +000022
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) {
Eric Andersenbdfd0d72001-10-24 05:00:29 +000045 if (/^\/*#define CONFIG_FEATURE_([A-Z0-9_]*)/) {
Mark Whitley9ba5bce2001-03-09 01:46:45 +000046 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;
Eric Andersenbdfd0d72001-10-24 05:00:29 +000063 print O $header, "#define CONFIG_FEATURE_$f\n", $trailer;
Mark Whitley9ba5bce2001-03-09 01:46:45 +000064 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