Skip to content

Commit bcdad85

Browse files
committed
Enhance enum checker to include meta header files
Signed-off-by: Tejaswini Chadaga <tchadaga@microsoft.com>
1 parent 1f3abf9 commit bcdad85

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

meta/ancestry.pl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,20 @@ sub ProcessHeaders
127127
{
128128
my $commit = shift;
129129

130-
my @headers = GetHeaderFiles("temp/commit-$commit/inc");
130+
my @dirs = (
131+
"temp/commit-$commit/inc",
132+
"temp/commit-$commit/meta",
133+
);
131134

132-
for my $header (@headers)
135+
for my $dir (@dirs)
133136
{
134-
LogDebug "Processing $header";
137+
my @headers = GetHeaderFiles($dir);
135138

136-
ProcessSingleHeader "temp/commit-$commit/inc/$header";
139+
for my $header (@headers)
140+
{
141+
LogDebug "Processing $dir/$header";
142+
ProcessSingleHeader "$dir/$header";
143+
}
137144
}
138145
}
139146

meta/checkancestry.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ function checkout_inc_directories()
8484

8585
mkdir temp/commit-$commit
8686
mkdir temp/commit-$commit/inc
87+
mkdir temp/commit-$commit/meta
8788

8889
git --work-tree=temp/commit-$commit checkout $commit inc 2>/dev/null
90+
git --work-tree=temp/commit-$commit checkout $commit meta 2>/dev/null
8991

9092
done
9193
}
@@ -101,7 +103,12 @@ function create_commit_list()
101103

102104
echo "git rev list from $begin to $end"
103105

104-
LIST=$(git rev-list --ancestry-path ${begin}^..${end} | xargs -n 1 git rev-parse --short | tac)
106+
local skip_begin=$3
107+
local skip_end=$4
108+
109+
local FULL_LIST=$(git rev-list --ancestry-path ${begin}^..${end} | xargs -n 1 git rev-parse --short | tac)
110+
local SKIP_LIST=$(git rev-list --ancestry-path ${skip_begin}^..${skip_end} | xargs -n 1 git rev-parse --short | tac)
111+
LIST=$(grep -vxFf <(echo "$SKIP_LIST") <<< "$FULL_LIST")
105112
}
106113

107114
function check_enum_history()
@@ -123,11 +130,17 @@ function check_enum_history()
123130

124131
BEGIN_COMMIT=3132018 # from this commit we are backward compatible
125132
BEGIN_COMMIT=1f2bca1 # to this commit we have history file
133+
134+
# commits from skip_begin to skip_end are skipped from backward compatibility check
135+
# due to a regression in meta directory which was earlier excluded from this check
136+
SKIP_BEGIN=401bd1f
137+
SKIP_END=77578c8
138+
126139
END_COMMIT=HEAD
127140

128141
clean_temp_dir
129142
create_temp_dir
130-
create_commit_list $BEGIN_COMMIT $END_COMMIT
143+
create_commit_list $BEGIN_COMMIT $END_COMMIT $SKIP_BEGIN $SKIP_END
131144
checkout_inc_directories
132145
check_enum_history
133146
clean_temp_dir

meta/checkenumlock.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ rm -rf $TEMP_DIR
3737

3838
mkdir $TEMP_DIR
3939

40-
git --work-tree=$TEMP_DIR/ checkout origin/master inc experimental
40+
git --work-tree=$TEMP_DIR/ checkout origin/master inc experimental meta
4141

4242
echo "Checking for possible enum values shift (current branch vs origin/master) ..."
4343

4444
./checkheaders.pl -s ../inc/ $TEMP_DIR/inc/
4545

46+
./checkheaders.pl -s ../meta/ $TEMP_DIR/meta/
47+
48+
./checkheaders.pl -s ../experimental/ $TEMP_DIR/experimental/
49+
4650
rm -rf $TEMP_DIR

meta/checkheaders.pl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ sub GetEnums
104104

105105
for my $file (@files)
106106
{
107+
next if $file eq "saimetadata.h";
108+
107109
my $data = ReadHeaderFile("$dir/$file");
108110

109111
my %en = FilterEnums($data, "$dir/$file");
@@ -122,7 +124,21 @@ sub ConstructSource
122124

123125
my $source = "#include <stdio.h>\n";
124126

125-
$source .= "#include \"$dir/sai.h\"\n";
127+
$source .= "#include \"$dir/../inc/sai.h\"\n";
128+
129+
if( ! -e "$dir/sai.h") {
130+
131+
my @files = GetHeaderFiles $dir;
132+
133+
for my $file (@files)
134+
{
135+
if ($file =~ /\.h$/)
136+
{
137+
$source .= "#include \"$dir/$file\"\n";
138+
}
139+
}
140+
}
141+
126142
$source .="int main() { ";
127143

128144
for my $en (sort keys %enums)
@@ -149,7 +165,7 @@ sub GetValues
149165

150166
my ($fhb, $bin) = tempfile( SUFFIX => '.bin', UNLINK => 1 );
151167

152-
system("gcc $src -I. -I '$dir'/../experimental -I '$dir/../custom/' -I '$dir' -o $bin") == 0 or die "gcc failed! $!";
168+
system("gcc $src -I. -I '$dir'/../experimental -I '$dir/../custom/' -I '$dir/../inc/' -I '$dir' -o $bin") == 0 or die "gcc failed! $!";
153169

154170
close $fhs;
155171
close $fhb;

0 commit comments

Comments
 (0)