Automating a sorting check is the only way to ensure we don't
regress. Suggested by Dan Berrange.
* src/check-symsorting.pl (check_sorting): Add a parameter,
validate that groups are in order, and that files exist.
* src/Makefile.am (check-symsorting): Adjust caller.
* src/libvirt_private.syms: Fix typo.
* src/libvirt_linux.syms: Fix file name.
* src/libvirt_vmx.syms: Likewise.
* src/libvirt_xenxs.syms: Likewise.
* src/libvirt_sasl.syms: Likewise.
* src/libvirt_libssh2.syms: Likewise.
* src/libvirt_esx.syms: Mention file name.
* src/libvirt_openvz.syms: Likewise.
---
While I can manage in perl, I probably don't have the best usage
patterns; suggestions for improving this patch are quite welcome.
src/Makefile.am | 3 ++-
src/check-symsorting.pl | 35 +++++++++++++++++++++++++++++------
src/libvirt_esx.syms | 1 +
src/libvirt_libssh2.syms | 3 +--
src/libvirt_linux.syms | 2 +-
src/libvirt_openvz.syms | 2 ++
src/libvirt_private.syms | 2 +-
src/libvirt_sasl.syms | 8 ++++----
src/libvirt_vmx.syms | 2 +-
src/libvirt_xenxs.syms | 4 ++--
10 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 780cd52..3ef9a9c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -388,7 +388,8 @@ else
check-symfile:
endif
check-symsorting:
- $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl $(USED_SYM_FILES)
+ $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
+ $(srcdir) $(USED_SYM_FILES)
EXTRA_DIST += check-symfile.pl check-symsorting.pl
PROTOCOL_STRUCTS = \
diff --git a/src/check-symsorting.pl b/src/check-symsorting.pl
index 9c62246..cbcb737 100755
--- a/src/check-symsorting.pl
+++ b/src/check-symsorting.pl
@@ -3,22 +3,27 @@
use strict;
use warnings;
-die "syntax: $0 SYMFILE..." unless int(@ARGV) >= 1;
+die "syntax: $0 SRCDIR SYMFILE..." unless int(@ARGV) >= 2;
my $ret = 0;
+my $srcdir = shift;
+my $lastgroup = undef;
foreach my $symfile (@ARGV) {
open SYMFILE, $symfile or die "cannot read $symfile: $!";
my $line;
+ my $groupfile;
my @group;
while (<SYMFILE>) {
chomp;
- next if /^#/;
- if (/^\s*$/) {
+ if (/^#/) {
+ $_ =~ s/^# //;
+ $groupfile = $_;
+ } elsif (/^\s*$/) {
if (@group) {
- &check_sorting(\@group, $symfile, $line);
+ &check_sorting(\@group, $symfile, $line, $groupfile);
}
@group = ();
$line = $.;
@@ -30,20 +35,38 @@ foreach my $symfile (@ARGV) {
close SYMFILE;
if (@group) {
- &check_sorting(\@group, $symfile, $line);
+ &check_sorting(\@group, $symfile, $line, $groupfile);
}
+ $lastgroup = undef;
}
sub check_sorting {
my $group = shift;
my $symfile = shift;
my $line = shift;
+ my $groupfile = shift;
my @group = @{$group};
my @sorted = sort { lc $a cmp lc $b } @group;
my $sorted = 1;
my $first;
my $last;
+
+ # Check that groups are in order and groupfile exists
+ if (defined $lastgroup && lc $lastgroup ge lc $groupfile) {
+ print "Symbol block at $symfile:$line: block not sorted\n";
+ print "Move $groupfile block before $lastgroup block\n";
+ print "\n";
+ $ret = 1;
+ }
+ if (! -e "$srcdir/$groupfile") {
+ print "Symbol block at $symfile:$line: $groupfile not found\n";
+ print "\n";
+ $ret = 1;
+ }
+ $lastgroup = $groupfile;
+
+ # Check that symbols within a group are in order
for (my $i = 0 ; $i <= $#sorted ; $i++) {
if ($sorted[$i] ne $group[$i]) {
$first = $i unless defined $first;
@@ -54,7 +77,7 @@ sub check_sorting {
if (!$sorted) {
@group = splice @group, $first, ($last-$first+1);
@sorted = splice @sorted, $first, ($last-$first+1);
- print "Symbol block at $symfile:$line symbols not sorted\n";
+ print "Symbol block at $symfile:$line: symbols not sorted\n";
print map { " " . $_ . "\n" } @group;
print "Correct ordering\n";
print map { " " . $_ . "\n" } @sorted;
diff --git a/src/libvirt_esx.syms b/src/libvirt_esx.syms
index ad3d60a..3c14b94 100644
--- a/src/libvirt_esx.syms
+++ b/src/libvirt_esx.syms
@@ -2,6 +2,7 @@
# These symbols are dependent upon --with-esx via WITH_ESX
#
+# esx/esx_util.h
esxUtil_EscapeDatastoreItem;
esxUtil_ParseDatastorePath;
esxVI_DateTime_ConvertToCalendarTime;
diff --git a/src/libvirt_libssh2.syms b/src/libvirt_libssh2.syms
index 815195b..55022b5 100644
--- a/src/libvirt_libssh2.syms
+++ b/src/libvirt_libssh2.syms
@@ -2,8 +2,7 @@
# ssh session - specific symbols
#
-# virnetsshsession.h
-#
+# rpc/virnetsshsession.h
virNetSSHChannelRead;
virNetSSHChannelWrite;
virNetSSHSessionAuthAddAgentAuth;
diff --git a/src/libvirt_linux.syms b/src/libvirt_linux.syms
index b5f7ee2..3500898 100644
--- a/src/libvirt_linux.syms
+++ b/src/libvirt_linux.syms
@@ -5,7 +5,7 @@
# nodeinfo.h
linuxNodeInfoCPUPopulate;
-# stats_linux.h
+# util/virstatslinux.h
linuxDomainInterfaceStats;
# Let emacs know we want case-insensitive sorting
diff --git a/src/libvirt_openvz.syms b/src/libvirt_openvz.syms
index 58b93ae..ac0ed0d 100644
--- a/src/libvirt_openvz.syms
+++ b/src/libvirt_openvz.syms
@@ -1,6 +1,8 @@
#
# These symbols are dependent upon --with-openvz via WITH_OPENVZ
#
+
+# openvz/openvz_conf.h
openvzLocateConfFile;
openvzReadConfigParam;
openvzReadNetworkConf;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1686bb8..3c44cc3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -420,7 +420,7 @@ virNetDevVlanFormat;
virNetDevVlanParse;
-# conf/netdev_vportprofile_conf.h
+# conf/netdev_vport_profile_conf.h
virNetDevVPortProfileFormat;
virNetDevVPortProfileParse;
virNetDevVPortTypeFromString;
diff --git a/src/libvirt_sasl.syms b/src/libvirt_sasl.syms
index 099f48a..beb8825 100644
--- a/src/libvirt_sasl.syms
+++ b/src/libvirt_sasl.syms
@@ -2,10 +2,10 @@
# SASL-specific symbols
#
-# virnetclient.h
+# rpc/virnetclient.h
virNetClientSetSASLSession;
-# virnetsaslcontext.h
+# rpc/virnetsaslcontext.h
virNetSASLContextCheckIdentity;
virNetSASLContextNewClient;
virNetSASLContextNewServer;
@@ -25,11 +25,11 @@ virNetSASLSessionServerStart;
virNetSASLSessionServerStep;
-# virnetserverclient.h
+# rpc/virnetserverclient.h
virNetServerClientSetSASLSession;
-# virnetsocket.h
+# rpc/virnetsocket.h
virNetSocketSetSASLSession;
# Let emacs know we want case-insensitive sorting
diff --git a/src/libvirt_vmx.syms b/src/libvirt_vmx.syms
index 99fe590..0b15f49 100644
--- a/src/libvirt_vmx.syms
+++ b/src/libvirt_vmx.syms
@@ -2,7 +2,7 @@
# These symbols are dependent upon --with-esx via WITH_ESX or --with-vmware via
WITH_VMWARE.
#
-# vmx.h
+# vmx/vmx.h
virVMXConvertToUTF8;
virVMXEscapeHex;
virVMXFormatCDROM;
diff --git a/src/libvirt_xenxs.syms b/src/libvirt_xenxs.syms
index 75d5322..04b35c4 100644
--- a/src/libvirt_xenxs.syms
+++ b/src/libvirt_xenxs.syms
@@ -2,7 +2,7 @@
# These symbols are dependent upon --with-xen via WITH_XEN or --with-libxl via
WITH_LIBXL.
#
-# xen_sxpr.h
+# xenxs/xen_sxpr.h
xenFormatSxpr;
xenFormatSxprChr;
xenFormatSxprDisk;
@@ -16,7 +16,7 @@ xenParseSxprChar;
xenParseSxprSound;
xenParseSxprString;
-# xen_xm.h
+# xenxs/xen_xm.h
xenFormatXM;
xenParseXM;
--
1.8.1.2