ci: Update image list
[libvirt/ericb.git] / src / check-drivername.pl
blob3a62193e3318b1fff5f940c8993963640b94e97e
1 #!/usr/bin/env perl
3 # Copyright (C) 2013 Red Hat, Inc.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library. If not, see
17 # <http://www.gnu.org/licenses/>.
20 use strict;
21 use warnings;
23 my $drvfile = shift;
24 my @symfiles = @ARGV;
26 my %symbols;
28 foreach my $symfile (@symfiles) {
29 open SYMFILE, "<", $symfile
30 or die "cannot read $symfile: $!";
31 while (<SYMFILE>) {
32 if (/^\s*(vir\w+)\s*;\s*$/) {
33 $symbols{$1} = 1;
37 close SYMFILE;
40 open DRVFILE, "<", $drvfile
41 or die "cannot read $drvfile: $!";
43 my $status = 0;
45 while (<DRVFILE>) {
46 next if /virDrvConnectSupportsFeature/;
47 if (/\*(virDrv\w+)\s*\)/) {
49 my $drv = $1;
51 next if $drv =~ /virDrvState/;
52 next if $drv =~ /virDrvDomainMigrate(Prepare|Perform|Confirm|Begin|Finish)/;
54 my $sym = $drv;
55 $sym =~ s/virDrv/vir/;
57 unless (exists $symbols{$sym}) {
58 print "Driver method name $drv doesn't match public API name\n";
59 $status = 1;
61 } elsif (/^\*(vir\w+)\s*\)/) {
62 my $name = $1;
63 print "Bogus name $1\n";
64 $status = 1;
65 } elsif (/^\s*(virDrv\w+)\s+(\w+);\s*/) {
66 my $drv = $1;
67 my $field = $2;
69 my $tmp = $drv;
70 $tmp =~ s/virDrv//;
71 $tmp =~ s/^NWFilter/nwfilter/;
72 $tmp =~ s/^(\w)/lc $1/e;
74 unless ($tmp eq $field) {
75 print "Driver struct field $field should be named $tmp\n";
76 $status = 1;
81 close DRVFILE;
83 exit $status;