]>
git.saurik.com Git - apple/ld64.git/blob - unit-tests/bin/make-recursive.pl
11 $ENV{'LD_NO_CLASSSIC_LINKER'} = '1';
12 $ENV{'LD_NO_CLASSSIC_LINKER_STATIC'} = '1';
22 'wanted' => \
&find_callback
,
35 # Determine how many tests to run at a time in parallel. Default to cpu count.
36 my $max_concurrent_tests = $ENV{'LD_UNIT_TEST_CONCURRENCY'};
37 if (!defined $max_concurrent_tests) {
38 # shell command returns cpu count in exit status
39 system("/bin/csh", "-c", "set n=`sysctl hw.ncpu`; exit \$n[2]");
40 if ($? == -1 || $? & 127) {
41 die("could not determine cpu count");
43 $max_concurrent_tests = $? >> 8;
47 my $max_keyword_len = 0;
48 foreach $keyword (keys %$keywords)
49 { if($max_keyword_len < length($keyword)) { $max_keyword_len = length($keyword); } }
51 $max_keyword_len += length($delim) + length(' ');
53 my $last_keyword = '';
57 my ($file, $keyword, $val) = @_;
59 if(!exists($$keywords{$keyword}))
61 print STDERR
"error: keyword $keyword not in \$keywords set\n";
67 if($keyword ne $last_keyword)
69 print($file "$keyword"); print($file $delim);
70 $keyword_len = length($keyword) + length($delim);
72 if($max_keyword_len > $keyword_len)
74 my $num_spaces = $max_keyword_len - $keyword_len;
75 print($file ' ' x
$num_spaces);
80 $last_keyword = $keyword;
85 $root = &realpath
($root);
86 print_line
(*STDOUT
, "root", "$root\n");
87 my $running_test_count=0;
88 find
($find_opts, $root);
89 while ( $running_test_count > 0 ) {
95 if(exists($$makefiles{$_}))
98 my $reldir = $File::Find
::dir
;
99 $reldir =~ s
|^$root/||;
101 my $cmd = [ "make" ];
103 my $arg; foreach $arg (@ARGV) { push @$cmd, $arg; } # better way to do this?
105 $ENV{UNIT_TEST_NAME
} = $reldir;
107 if (not defined $pid) {
111 # Child. Redirect stdout/stderr to files and exec test.
112 open(STDOUT
, ">/tmp/unit-tests-stdout.$PID") || die("$!");
113 open(STDERR
, ">/tmp/unit-tests-stderr.$PID") || die("$!");
115 exit(-1); #just to be sure
118 # Write the test cwd/cmd to a temporary file associated with the child's pid, to be retrieved later.
120 open($info, ">/tmp/unit-tests-info.$pid") || die("$!");
121 &print_line
($info, "cwd", "\$root/$reldir\n"); # post filtering depends on this line being first
122 &print_line
($info, "cmd", "@$cmd\n");
123 close($info) || die("$!");
125 $running_test_count++;
126 # if we have reached max # of concurrent tests, wait for one to exit
127 if ( $running_test_count == $max_concurrent_tests ) {
134 if ( $running_test_count > 0 ) {
141 $running_test_count--;
143 open(INFO
, "</tmp/unit-tests-info.$pid") || die("$!");
148 close(INFO
) || die("$!");
149 unlink("/tmp/unit-tests-info.$pid");
151 &print_line
(*STDOUT
, "exit", "$exit\n");
153 open(OUT
, "</tmp/unit-tests-stdout.$pid") || die("$!");
156 &print_line
(*STDOUT
, "stdout", "$_");
158 close(OUT
) || die("$!");
159 unlink("/tmp/unit-tests-stdout.$pid");
161 open(ERR
, "</tmp/unit-tests-stderr.$pid") || die("$!");
164 &print_line
(*STDOUT
, "stderr", "$_");
166 close(ERR
) || die("$!");
167 unlink("/tmp/unit-tests-stderr.$pid");