Whamcloud - gitweb
b=23090 Wirecheck.c is still missing some structs
[fs/lustre-release.git] / lustre / utils / checkwirecheck.sh
1 #!/bin/bash
2
3 IDL=../../lustre/include/lustre/lustre_idl.h
4
5 idl_types=$(mktemp -t idl_types-XXXX)
6 idl_types2=$(mktemp -t idl_types2-XXXX)
7 idl_struct_types=$(mktemp -t idl_struct_types-XXXX)
8 idl_struct_types2=$(mktemp -t idl_struct_types2-XXXX)
9 status=0
10
11 trap 'rm -f "$idl_types" "$idl_types2" "$idl_struct_types" "$idl_struct_types2"' EXIT
12
13 # All named types
14 egrep '^(struct|union|enum|typedef|#define)' $IDL |
15     grep -v '} __attribute__((packed));' |
16     grep -v '}__attribute__((packed));' > $idl_types
17 sed -e '/^#define/s/^#define.\([^       ]*\).*$/\1/' \
18     -e '/^typedef/s/typedef.[^  ]*[     ]*\<\(.*\);/\1/' \
19     -e '/^struct/s/^struct[     ]*\([^  ]*\).*$/\1/' \
20     -e '/^enum/s/^enum[         ]*\([^  ]*\).*$/\1/' \
21     -e '/^typedef enum/s/^typedef enum[         ]*\([^  ]*\)[   ].*/\1/' \
22     -e '/^typedef union/s/^typedef union[       ]*\([^  ]*\)[   ].*/\1/' \
23     "$idl_types" | grep -v '[()]'  > "$idl_types2"
24 while read sym; do
25         # Ignore the #define for the header guard
26         [[ "$sym" = _LUSTRE_IDL_H_ ]] && continue
27         grep -q "$sym" wirecheck.c || echo "Missing wirecheck for $sym"
28 done < "$idl_types2"
29
30 # Just struct types (the grep -v ';' part ignores incomplete structs; we can't
31 # check those).
32 grep '^struct' $IDL | grep -v ';' > "$idl_struct_types"
33 sed -e '/^struct/s/^struct[     ]*\([^  ]*\).*$/\1/' \
34     "$idl_struct_types" | grep -v '[()]'  > "$idl_struct_types2"
35 while read sym; do
36         grep -q "$sym" wirecheck.c && continue
37         status=1
38         echo "Missing wirecheck for struct $sym"
39 done < "$idl_struct_types2"
40
41 # Reflect only missing structs, for now.
42 exit $status