backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / build-aux / mock-noinline.pl
blob958e133885a84dce86d9999cb447f27b77fdd732
1 #!/usr/bin/env perl
3 my %noninlined;
4 my %mocked;
6 # Functions in public header don't get the noinline annotation
7 # so whitelist them here
8 $noninlined{"virEventAddTimeout"} = 1;
9 # This one confuses the script as its defined in the mock file
10 # but is actually just a local helper
11 $noninlined{"virMockStatRedirect"} = 1;
13 foreach my $arg (@ARGV) {
14 if ($arg =~ /\.h$/) {
15 #print "Scan header $arg\n";
16 &scan_annotations($arg);
17 } elsif ($arg =~ /mock\.c$/) {
18 #print "Scan mock $arg\n";
19 &scan_overrides($arg);
23 my $warned = 0;
24 foreach my $func (keys %mocked) {
25 next if exists $noninlined{$func};
27 $warned++;
28 print STDERR "$func is mocked at $mocked{$func} but missing noinline annotation\n";
31 exit $warned ? 1 : 0;
34 sub scan_annotations {
35 my $file = shift;
37 open FH, $file or die "cannot read $file: $!";
39 my $func;
40 while (<FH>) {
41 if (/^\s*(\w+)\(/ || /^(?:\w+\*?\s+)+(?:\*\s*)?(\w+)\(/) {
42 my $name = $1;
43 if ($name !~ /ATTRIBUTE/) {
44 $func = $name;
46 } elsif (/^\s*$/) {
47 $func = undef;
49 if (/ATTRIBUTE_NOINLINE/) {
50 if (defined $func) {
51 $noninlined{$func} = 1;
56 close FH
59 sub scan_overrides {
60 my $file = shift;
62 open FH, $file or die "cannot read $file: $!";
64 my $func;
65 while (<FH>) {
66 if (/^(\w+)\(/ || /^\w+\s*(?:\*\s*)?(\w+)\(/) {
67 my $name = $1;
68 if ($name =~ /^vir/) {
69 $mocked{$name} = "$file:$.";
74 close FH