mirror of
https://github.com/openvswitch/ovs
synced 2025-10-21 14:49:41 +00:00
ovsdb-client's 'monitor' command works with --detach such that the parent detaches after printing initial transactions in the database. This is a little tricky to implement in windows. So for windows, send the process to background with '&' and then sleep for a second to let the intial transactions printed. (We can do the same for Linux, but it slows down the test run) Also let the perl script that looks at the o/p be aware of CR LF in windows. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
53 lines
1.0 KiB
Perl
Executable File
53 lines
1.0 KiB
Perl
Executable File
#! /usr/bin/perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
# Breaks lines read from <STDIN> into groups using blank lines as
|
|
# group separators, then sorts lines within the groups for
|
|
# reproducibility.
|
|
|
|
sub compare_lines {
|
|
my ($a, $b) = @_;
|
|
|
|
my $u = '[0-9a-fA-F]';
|
|
my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}";
|
|
if ($a =~ /^$uuid_re/) {
|
|
if ($b =~ /^$uuid_re/) {
|
|
return substr($a, 36) cmp substr($b, 36);
|
|
} else {
|
|
return 1;
|
|
}
|
|
} elsif ($b =~ /^$uuid_re/) {
|
|
return -1;
|
|
} else {
|
|
return $a cmp $b;
|
|
}
|
|
}
|
|
|
|
sub output_group {
|
|
my (@group) = @_;
|
|
print "$_\n" foreach sort { compare_lines($a, $b) } @group;
|
|
}
|
|
|
|
if ("$^O" eq "msys") {
|
|
$/ = "\r\n";
|
|
}
|
|
my @group = ();
|
|
while (<STDIN>) {
|
|
chomp;
|
|
if ($_ eq '') {
|
|
output_group(@group);
|
|
@group = ();
|
|
print "\n";
|
|
} else {
|
|
if (/^,/ && @group) {
|
|
$group[$#group] .= "\n" . $_;
|
|
} else {
|
|
push(@group, $_);
|
|
}
|
|
}
|
|
}
|
|
|
|
output_group(@group) if @group;
|