Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom range base enums for api and object_type #2112

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions inc/sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ typedef enum _sai_api_t
SAI_API_PREFIX_COMPRESSION = 53, /**< sai_prefix_compression_api_t */
SAI_API_MAX, /**< total number of APIs */

/**
* @brief Custom range base
*/
SAI_API_CUSTOM_RANGE_BASE = 0x10000000,

/**
* @brief Extensions range base
*/
Expand Down
5 changes: 5 additions & 0 deletions inc/saitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ typedef enum _sai_object_type_t
/** Must remain in last position */
SAI_OBJECT_TYPE_MAX,

/**
* @brief Custom range base
*/
SAI_OBJECT_TYPE_CUSTOM_RANGE_BASE = 0x10000000,

SAI_OBJECT_TYPE_EXTENSIONS_RANGE_BASE = 0x20000000,
} sai_object_type_t;

Expand Down
55 changes: 47 additions & 8 deletions meta/test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ sub CreateCustomRangeTest
WriteTest "}";
}

sub CreateCustomRangeAll
sub CreateCustomRangeAllTest
{
DefineTestName "custom_range_all_test";

Expand All @@ -166,12 +166,6 @@ sub CreateCustomRangeAll

for my $enum (@all)
{
# extepions and will be removed
next if $enum eq "SAI_API_CUSTOM_RANGE_START";
next if $enum eq "SAI_API_CUSTOM_RANGE_END";
next if $enum eq "SAI_OBJECT_TYPE_CUSTOM_RANGE_START";
next if $enum eq "SAI_OBJECT_TYPE_CUSTOM_RANGE_END";

WriteTest " TEST_ASSERT_TRUE($enum == 0x10000000, \"invalid custom range start for $enum\");" if $enum =~ /_START$/;
WriteTest " TEST_ASSERT_TRUE($enum < 0x20000000, \"invalid custom range end for $enum\");" if $enum =~ /_END$/;
}
Expand All @@ -180,6 +174,49 @@ sub CreateCustomRangeAll
WriteTest "}";
}

sub CreateCustomRangeBaseTest
{
DefineTestName "custom_range_base_test";

WriteTest "{";

for my $key (sort keys %main::SAI_ENUMS)
{
next if not defined $main::SAI_ENUMS{$key}{ranges};

my @ranges = @{ $main::SAI_ENUMS{$key}{ranges} };

next if scalar @ranges == 0;

for my $range (@ranges)
{
next if $range eq "SAI_HOSTIF_USER_DEFINED_TRAP_TYPE_CUSTOM_RANGE_BASE"; # TODO exception, to be remove

my $prefix = uc $1 if $key =~ /(sai_\w+)_t$/;

if ($range eq "${prefix}_CUSTOM_RANGE_BASE")
{
WriteTest " TEST_ASSERT_TRUE_EXT($range == 0x10000000, \"invalid custom range base for $range = 0x%x\", $range);" ;
next;
}

if ($range eq "${prefix}_EXTENSIONS_RANGE_BASE")
{
WriteTest " TEST_ASSERT_TRUE_EXT($range == 0x20000000, \"invalid extensions range base for $range: = 0x%x\", $range);" ;
next;
}

LogInfo "Skipping range base $range";

# currently any other range should be less than custom

WriteTest " TEST_ASSERT_TRUE_EXT($range < 0x10000000 , \"invalid extensions range base for $range = 0x%x\", $range);" ;
}
}

WriteTest "}";
}

sub CreateEnumSizeCheckTest
{
DefineTestName "enum_size_check_test";
Expand Down Expand Up @@ -742,7 +779,9 @@ sub CreateTests

CreateStructUnionSizeCheckTest();

CreateCustomRangeAll();
CreateCustomRangeAllTest();

CreateCustomRangeBaseTest();

CreateExtensionRangeTest();

Expand Down
Loading