diff options
| -rwxr-xr-x | tests/multifeat.pl | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/multifeat.pl b/tests/multifeat.pl new file mode 100755 index 000000000..1169a3daf --- /dev/null +++ b/tests/multifeat.pl | |||
| @@ -0,0 +1,81 @@ | |||
| 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 BB_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 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 | ||
| 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 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 | } | ||
| 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 BB_FEATURE_$f\n", $trailer; | ||
| 64 | close O; | ||
| 65 | system("echo -e '\n***\n$f\n***' >>$logfile"); | ||
| 66 | # todo: figure out why the "rm -f *.o" is needed | ||
| 67 | $result{$f} = system("rm -f *.o; make $make_opt busybox >>$logfile 2>&1"); | ||
| 68 | $flag = $result{$f} ? "FAILED!!!" : "ok"; | ||
| 69 | printf("Feature %-20s: %s\n", $f, $flag); | ||
| 70 | $total_tests++; | ||
| 71 | $failed_tests++ if $flag eq "FAILED!!!"; | ||
| 72 | # pause long enough to let user stop us with a ^C | ||
| 73 | select(undef, undef, undef, 0.05); | ||
| 74 | } | ||
| 75 | |||
| 76 | # Clean up our mess | ||
| 77 | system("mv -f Config.h.orig Config.h"); | ||
| 78 | |||
| 79 | print "$total_tests applets tested, $failed_tests failures\n"; | ||
| 80 | print "See $logfile for details.\n"; | ||
| 81 | |||
