Skip to content

Commit

Permalink
Introduce bare-bones library for semantic versioning (sonic-net#467)
Browse files Browse the repository at this point in the history
Co-authored-by: smolkaj <smolkaj@google.com>
Co-authored-by: kishanps <kishanps@google.com>
  • Loading branch information
3 people authored Aug 14, 2024
1 parent f6106b5 commit d64a213
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions sai_p4/instantiations/google/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ cc_test(
":sai_p4info_cc",
"//gutil:proto_matchers",
"//gutil:status_matchers",
"//gutil:version",
"@com_github_p4lang_p4_constraints//p4_constraints/backend:constraint_info",
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
"@com_google_absl//absl/strings",
Expand Down
13 changes: 13 additions & 0 deletions sai_p4/instantiations/google/sai_p4info_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
#include "gtest/gtest.h"
#include "gutil/proto_matchers.h"
#include "gutil/status_matchers.h"
#include "gutil/version.h"
#include "p4/config/v1/p4info.pb.h"
#include "p4_constraints/backend/constraint_info.h"
#include "sai_p4/instantiations/google/instantiations.h"

namespace sai {
namespace {

using gutil::IsOkAndHolds;
using testing::_;

class InstantiationTest : public testing::TestWithParam<Instantiation> {};

TEST_P(InstantiationTest, GetP4InfoDoesNotCrashAndP4ConstraintsAreParsable) {
Expand All @@ -25,6 +29,15 @@ TEST_P(InstantiationTest, GetP4InfoDoesNotCrashAndP4ConstraintsAreParsable) {
p4_constraints::P4ToConstraintInfo(info));
}

TEST_P(InstantiationTest, GetP4InfoDoesNotCrashAndPkgInfoVersionIsParsable) {
if (GetParam() == Instantiation::kWbb) {
GTEST_SKIP() << "WBB is not a SAI P4 instantiation";
}
// GetP4Info contains a CHECK; ensure it doesn't fail.
auto info = GetP4Info(GetParam());
EXPECT_THAT(gutil::ParseVersion(info.pkg_info().version()), IsOkAndHolds(_));
}

// GetIrP4Info contains a CHECK; ensure it doesn't fail.
TEST_P(InstantiationTest, GetIrP4InfoDoesNotCrash) {
auto info = GetIrP4Info(GetParam());
Expand Down

0 comments on commit d64a213

Please sign in to comment.