1570af302Sopenharmony_ci/*
2570af302Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3570af302Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4570af302Sopenharmony_ci * you may not use this file except in compliance with the License.
5570af302Sopenharmony_ci * You may obtain a copy of the License at
6570af302Sopenharmony_ci *
7570af302Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8570af302Sopenharmony_ci *
9570af302Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10570af302Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11570af302Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12570af302Sopenharmony_ci * See the License for the specific language governing permissions and
13570af302Sopenharmony_ci * limitations under the License.
14570af302Sopenharmony_ci */
15570af302Sopenharmony_ci
16570af302Sopenharmony_ci#include <stdio.h>
17570af302Sopenharmony_ci#include <string.h>
18570af302Sopenharmony_ci
19570af302Sopenharmony_ci#include "test.h"
20570af302Sopenharmony_ci
21570af302Sopenharmony_ciextern const char *dso_symbol_invalid;
22570af302Sopenharmony_ciextern const char *dso_version_invalid;
23570af302Sopenharmony_ci
24570af302Sopenharmony_ciextern const char *dso_no_symver_name;
25570af302Sopenharmony_ciextern const char *dso_no_symver_symbol;
26570af302Sopenharmony_ci
27570af302Sopenharmony_ciextern const char *dso_easy_symver_name;
28570af302Sopenharmony_ciextern const char *dso_easy_symver_symbol;
29570af302Sopenharmony_ciextern const char *dso_easy_symver_symbol_old;
30570af302Sopenharmony_ciextern const char *dso_easy_symver_symbol_stable;
31570af302Sopenharmony_ciextern const char *dso_easy_symver_symbol_dev;
32570af302Sopenharmony_ciextern const char *dso_easy_symver_version_old;
33570af302Sopenharmony_ciextern const char *dso_easy_symver_version_stable;
34570af302Sopenharmony_ciextern const char *dso_easy_symver_version_dev;
35570af302Sopenharmony_ci
36570af302Sopenharmony_ciextern const char *dso_hard_symver_name;
37570af302Sopenharmony_ciextern const char *dso_hard_symver_if_symbol;
38570af302Sopenharmony_ciextern const char *dso_hard_symver_if_symbol_old;
39570af302Sopenharmony_ciextern const char *dso_hard_symver_if_symbol_stable;
40570af302Sopenharmony_ciextern const char *dso_hard_symver_if_symbol_dev;
41570af302Sopenharmony_ciextern const char *dso_hard_symver_ld_symbol;
42570af302Sopenharmony_ciextern const char *dso_hard_symver_ld_symbol_old;
43570af302Sopenharmony_ciextern const char *dso_hard_symver_ld_symbol_stable;
44570af302Sopenharmony_ciextern const char *dso_hard_symver_ld_symbol_dev;
45570af302Sopenharmony_ciextern const char *dso_hard_symver_version_old;
46570af302Sopenharmony_ciextern const char *dso_hard_symver_version_stable;
47570af302Sopenharmony_ciextern const char *dso_hard_symver_version_dev;
48570af302Sopenharmony_ci
49570af302Sopenharmony_citypedef char *(*functype)(void);
50570af302Sopenharmony_ci
51570af302Sopenharmony_ci#define SYMVER_DEBUG
52570af302Sopenharmony_ci#ifdef SYMVER_DEBUG
53570af302Sopenharmony_ci
54570af302Sopenharmony_ci#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
55570af302Sopenharmony_ci#define symver_log(fmt, ...)                                                                  \
56570af302Sopenharmony_ci    do {                                                                                      \
57570af302Sopenharmony_ci        printf("[%s:%4d][%s]" fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
58570af302Sopenharmony_ci    } while (0)
59570af302Sopenharmony_ci
60570af302Sopenharmony_ci#else  // SYMVER_DEBUG
61570af302Sopenharmony_ci
62570af302Sopenharmony_ci#define symver_log(fmt, ...)
63570af302Sopenharmony_ci
64570af302Sopenharmony_ci#endif  // SYMVER_DEBUG
65570af302Sopenharmony_ci
66570af302Sopenharmony_ci#define symver_error(fmt, ...)                                        \
67570af302Sopenharmony_ci    do {                                                              \
68570af302Sopenharmony_ci        t_error("%s failed: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \
69570af302Sopenharmony_ci    } while (0)
70570af302Sopenharmony_ci
71570af302Sopenharmony_ci#define symver_streq(s1, s2)                                                \
72570af302Sopenharmony_ci    do {                                                                    \
73570af302Sopenharmony_ci        if (strcmp(s1, s2)) {                                               \
74570af302Sopenharmony_ci            t_error("%s failed: s1 = %s, s2 = %s\n", __FUNCTION__, s1, s2); \
75570af302Sopenharmony_ci        }                                                                   \
76570af302Sopenharmony_ci    } while (0)
77