1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
21 #include "utils/debug_utils.h"
22 #include "utils/log_utils.h"
23 #include "utils/rand_utils.h"
24 #include "utils/type_utils.h"
25 #include "utils/sys_utils.h"
29 #include <libyang/libyang.h>
31 #include <sysrepo/values.h>
32 #include "core/session.h"
33 #include "core/framework.h"
34 #include "core/docker.h"
36 #include "core/datastore/schema.h"
37 #include "core/datastore/populate.h"
38 #include "core/datastore/operations.h"
40 int exhaustive_test_run(void) {
41 //first get all xpaths
43 int xpaths_count = datastore_schema_get_xpaths(&xpaths);
44 if(xpaths_count < 0) {
45 log_error("datastore_schema_get_xpaths failed\n");
46 return NTS_ERR_FAILED;
49 log_add_verbose(0, "datastore_schema_get_xpaths executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" (%d)\n", xpaths_count);
52 //switching verbosity level to 0 so we don't see logs
53 int old_verbosity_level = framework_arguments.verbosity_level;
54 framework_arguments.verbosity_level = 0;
56 //testing datastore_schema_print_xpath()
57 for(int i = 0 ; i < xpaths_count; i++) {
58 int rc = datastore_schema_print_xpath(xpaths[i]);
59 if(rc != NTS_ERR_OK) {
60 log_error("error in datastore_schema_print_xpath\n");
65 log_add_verbose(0, "datastore_schema_print_xpath executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" for all paths\n");
68 for(int i = 0; i < xpaths_count; i++) {
73 //testing schema_populate
74 int rc = datastore_populate_all();
75 if(rc != NTS_ERR_OK) {
76 log_error("error in datastore_populate_all\n");
80 log_add_verbose(0, "datastore_populate_all executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET"\n");
81 log_add_verbose(0, LOG_COLOR_BOLD_GREEN"ALL TESTS WENT GOOD!"LOG_COLOR_RESET"\n\n\n");
83 //switching back verbosity level
84 framework_arguments.verbosity_level = old_verbosity_level;
89 int test_mode_run(void) {