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/log_utils.h"
22 #include "utils/rand_utils.h"
23 #include "utils/type_utils.h"
24 #include "utils/sys_utils.h"
28 #include <libyang/libyang.h>
29 #include "core/session.h"
30 #include "core/framework.h"
31 #include "core/docker.h"
33 #include "core/datastore/schema.h"
34 #include "core/datastore/populate.h"
37 int exhaustive_test_run(void) {
38 //first get all xpaths
40 int xpaths_count = datastore_schema_get_xpaths(&xpaths);
41 if(xpaths_count < 0) {
42 log_error("datastore_schema_get_xpaths failed\n");
43 return NTS_ERR_FAILED;
46 log_add_verbose(0, "datastore_schema_get_xpaths executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" (%d)\n", xpaths_count);
49 //switching verbosity level to 0 so we don't see logs
50 int old_verbosity_level = framework_arguments.verbosity_level;
51 framework_arguments.verbosity_level = 0;
53 //testing datastore_schema_print_xpath()
54 for(int i = 0 ; i < xpaths_count; i++) {
55 int rc = datastore_schema_print_xpath(xpaths[i]);
56 if(rc != NTS_ERR_OK) {
57 log_error("error in datastore_schema_print_xpath\n");
62 log_add_verbose(0, "datastore_schema_print_xpath executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" for all paths\n");
65 for(int i = 0; i < xpaths_count; i++) {
70 //testing schema_populate
71 int rc = datastore_populate(1);
72 if(rc != NTS_ERR_OK) {
73 log_error("error in datastore_populate\n");
77 log_add_verbose(0, "datastore_populate executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET"\n");
78 log_add_verbose(0, LOG_COLOR_BOLD_GREEN"ALL TESTS WENT GOOD!"LOG_COLOR_RESET"\n\n\n");
80 //switching back verbosity level
81 framework_arguments.verbosity_level = old_verbosity_level;
86 int test_mode_run(void) {