]> git.proxmox.com Git - mirror_ovs.git/blame - tests/uuidfilt.pl
ovs-dev.py: Build with both GCC and Clang.
[mirror_ovs.git] / tests / uuidfilt.pl
CommitLineData
f85f8ebb
BP
1#! /usr/bin/perl
2
3use strict;
4use warnings;
5
6our %uuids;
7our $n_uuids = 0;
8sub lookup_uuid {
9 my ($uuid) = @_;
10 if (!exists($uuids{$uuid})) {
11 $uuids{$uuid} = $n_uuids++;
12 }
13 return "<$uuids{$uuid}>";
14}
15
7360012b
BP
16sub sort_set {
17 my ($s) = @_;
18 my (@uuids) = sort { $a <=> $b } (grep(/\d+/, split(/(\d+)/, $s)));
19 return '["set",[' . join(',', map('["uuid","<' . $_ . '>"]', @uuids)) . ']]';
20}
21
f85f8ebb
BP
22my $u = '[0-9a-fA-F]';
23my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}";
24while (<>) {
25 s/($uuid_re)/lookup_uuid($1)/eg;
7360012b
BP
26
27 # Sort sets like this:
28 # [["uuid","<1>"],["uuid","<0>"]]
29 # to look like this:
30 # [["uuid","<0>"],["uuid","<1>"]]
31 s/(\["set",\[(,?\["uuid","<\d+>"\])+\]\])/sort_set($1)/ge;
f85f8ebb
BP
32 print $_;
33}