Add VES stndDefined PM and subscription for O-DU.
[sim/o1-interface.git] / ntsimulator / ntsim-ng / core / test.c
1 /*************************************************************************
2 *
3 * Copyright 2020 highstreet technologies GmbH and others
4 *
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
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
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 ***************************************************************************/
17
18 #define _GNU_SOURCE
19
20 #include "test.h"
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"
26 #include <stdio.h>
27 #include <assert.h>
28
29 #include <libyang/libyang.h>
30 #include <sysrepo.h>
31 #include <sysrepo/values.h>
32 #include "core/session.h"
33 #include "core/framework.h"
34 #include "core/docker.h"
35
36 #include "core/datastore/schema.h"
37 #include "core/datastore/populate.h"
38 #include "core/datastore/operations.h"
39
40 int exhaustive_test_run(void) {
41     //first get all xpaths
42     char **xpaths = 0;
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;
47     }
48     else {
49         log_add_verbose(0, "datastore_schema_get_xpaths executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" (%d)\n", xpaths_count);
50     }
51
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;
55
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");
61             return rc;
62         }
63     }
64
65     log_add_verbose(0, "datastore_schema_print_xpath executed with "LOG_COLOR_BOLD_GREEN"success"LOG_COLOR_RESET" for all paths\n");
66
67     //freeing paths
68     for(int i = 0; i < xpaths_count; i++) {
69         free(xpaths[i]);
70     }
71     free(xpaths);
72
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");
77         return rc;
78     }
79
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");
82
83     //switching back verbosity level
84     framework_arguments.verbosity_level = old_verbosity_level;
85
86     return NTS_ERR_OK;
87 }
88
89 int test_mode_run(void) {
90     assert_session();
91
92    
93     return NTS_ERR_OK;
94 }