From cfc86deec59de72339db228e2d5813b271e3bc9a Mon Sep 17 00:00:00 2001 From: Partha Dutta <51353699+dutta-partha@users.noreply.github.com> Date: Wed, 17 Mar 2021 22:06:35 +0530 Subject: [PATCH] CVL Changes #11: Enabling mandatory node check (#40) Enabling mandatory node check and related test cases. --- cvl/cvl_test.go | 6 +----- cvl/internal/yparser/yparser.go | 5 ++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cvl/cvl_test.go b/cvl/cvl_test.go index fa37c41c7a93..3e6b10f2a620 100644 --- a/cvl/cvl_test.go +++ b/cvl/cvl_test.go @@ -1188,7 +1188,6 @@ func TestValidateEditConfig_Create_Semantic_AdditionalInvalidNode_Negative(t *te unloadConfigDB(rclient, depDataMap) } -/* func TestValidateEditConfig_Create_Semantic_MissingMandatoryNode_Negative(t *testing.T) { cfgData := []cvl.CVLEditConfigData{ @@ -1214,7 +1213,6 @@ func TestValidateEditConfig_Create_Semantic_MissingMandatoryNode_Negative(t *tes t.Errorf("Config Validation failed -- error details %v", cvlErrInfo) } } -*/ func TestValidateEditConfig_Create_Syntax_Invalid_Negative(t *testing.T) { @@ -3819,7 +3817,6 @@ func TestValidateEditConfig_Multi_Delete_MultiKey_Same_Session_Positive(t *testi unloadConfigDB(rclient, depDataMap) } -/* func TestValidateEditConfig_Update_Leaf_List_Max_Elements_Negative(t *testing.T) { depDataMap := map[string]interface{}{ "VLAN": map[string]interface{} { @@ -3860,7 +3857,6 @@ func TestValidateEditConfig_Update_Leaf_List_Max_Elements_Negative(t *testing.T) cvl.ValidationSessClose(cvSess) unloadConfigDB(rclient, depDataMap) } -*/ func TestValidationTimeStats(t *testing.T) { cvl.ClearValidationTimeStats() @@ -3904,4 +3900,4 @@ func TestValidationTimeStats(t *testing.T) { if (stats.Hits != 0 || stats.Time != 0 || stats.Peak != 0) { t.Errorf("TestValidationTimeStats : clearing stats failed") } -} \ No newline at end of file +} diff --git a/cvl/internal/yparser/yparser.go b/cvl/internal/yparser/yparser.go index 727cccb23722..92343bc688b8 100644 --- a/cvl/internal/yparser/yparser.go +++ b/cvl/internal/yparser/yparser.go @@ -38,7 +38,7 @@ import ( #include #include -//extern int lyd_check_mandatory_tree(struct lyd_node *root, struct ly_ctx *ctx, const struct lys_module **modules, int mod_count, int options); +extern int lyd_check_mandatory_tree(struct lyd_node *root, struct ly_ctx *ctx, const struct lys_module **modules, int mod_count, int options); struct lyd_node* lyd_parse_data_path(struct ly_ctx *ctx, const char *path, LYD_FORMAT format, int options) { return lyd_parse_path(ctx, path, format, options); @@ -54,8 +54,7 @@ int lyd_data_validate(struct lyd_node **node, int options, struct ly_ctx *ctx) int ret = -1; //Check mandatory elements as it is skipped for LYD_OPT_EDIT - //ret = lyd_check_mandatory_tree(*node, ctx, NULL, 0, LYD_OPT_CONFIG | LYD_OPT_NOEXTDEPS); - ret = 0; + ret = lyd_check_mandatory_tree(*node, ctx, NULL, 0, LYD_OPT_CONFIG | LYD_OPT_NOEXTDEPS); if (ret != 0) {