Add message types for traffic steering anomaly messages
[ric-plt/lib/rmr.git] / src / rmr / common / include / vet_mtypes.ksh
1 #!/usr/bin/env ksh
2
3 #==================================================================================
4 #        Copyright (c) 2019 Nokia
5 #        Copyright (c) 2018-2019 AT&T Intellectual Property.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #==================================================================================
19
20
21 # This provides a quick sanity check on the message types in
22 # the header file. The check is only to ensure that there are
23 # no duplicate constant names or values for any #define in the file.
24 #
25 # By default RIC_message_types.h is parsed, but it will accept the
26 # filename as the first positional parameter on the command line should
27 # it be necessary.
28 #
29 # The script exits with a 0 return code if all is good, 1 to indicate errors.
30 #
31 # CAUTION:  this breaks if any define is more than a simple key/value
32 #       pair in the header file.
33
34 sed 's!//.*!!' ${1:-RIC_message_types.h} | awk '
35         /#define/ {
36                 vcount[$NF]++;
37                 ncount[$2]++;
38                 lines[$2] = lines[$2] " " NR
39                 lines[$NF] = lines[$NF] " " NR
40                 next
41         }
42
43         END {
44                 vgood = 0
45                 ngood = 0
46                 bad = 0
47
48                 for( x in vcount ) {
49                         if( vcount[x] != 1 ) {
50                                 printf( "duplicate value? %s on lines: %s\n", x, lines[x] );
51                                 bad++
52                         } else {
53                                 vgood++
54                         }
55                 }
56
57                 for( x in ncount ) {
58                         if( ncount[x] != 1 ) {
59                                 printf( "duplicate name? %s on lines: %s\n", x, lines[x] );
60                                 bad++
61                         } else {
62                                 ngood++
63                         }
64                 }
65
66                 printf( "good values=%d good names=%d  bad things=%d\n", vgood, ngood, bad )
67
68                 exit( !! bad )
69         }'