Debian Codegraph @

test/test-deprecated.c

raw
1 /*
2 * Copyright © 2019 Red Hat, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of Red Hat
9 * not be used in advertising or publicity pertaining to distribution
10 * of the software without specific, written prior permission. Red
11 * Hat makes no representations about the suitability of this software
12 * for any purpose. It is provided "as is" without express or implied
13 * warranty.
14 *
15 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 */
24
25 #include "config.h"
26
27 #include <assert.h>
28 #include <dlfcn.h>
29
30 #include "libwacom.h"
31
32 /**
33 * The normal symbols are hidden now when linking against a new library.
34 * We know which version they're in though so we can remap them for this
35 * test - if we get an unresolved symbol something has gone wrong.
36 */
37 asm(".symver libwacom_match_destroy,libwacom_match_destroy@LIBWACOM_0.33");
38 asm(".symver libwacom_match_new,libwacom_match_new@LIBWACOM_0.33");
39 asm(".symver libwacom_error_set,libwacom_error_set@LIBWACOM_0.33");
40 asm(".symver libwacom_update_match,libwacom_update_match@LIBWACOM_0.33");
41 asm(".symver libwacom_stylus_destroy,libwacom_stylus_destroy@LIBWACOM_0.33");
42
43 /* Only generally matches the real functions, but since they're all noops
44 * anyway it doesn't matter that we only have generic pointers. The basic
45 * signatures are the same.
46 */
47 extern void
48 libwacom_match_destroy(void *);
49 void *
50 libwacom_match_new(void *,
51 int,
52 int,
53 int);
54 void
55 libwacom_error_set(void *error,
56 int,
57 char *,
58 ...);
59 void
60 libwacom_stylus_destroy(void *);
61 void
62 libwacom_update_match(void *,
63 const void *);
64
65 int
66 main(void)
67 {
68 const char *syms[] = {
69 "libwacom_match_destroy", "libwacom_match_new",
70 "libwacom_error_set", "libwacom_update_match",
71 "libwacom_stylus_destroy", NULL,
72 };
73 void *lib, *sym;
74
75 lib = dlopen("libwacom.so", RTLD_LAZY);
76 assert(lib != NULL);
77
78 for (const char **s = syms; *s; s++) {
79 sym = dlsym(lib, *s);
80 assert(sym == NULL);
81 }
82
83 /* These are all noops, so all we're looking for is not getting a linker
84 * error */
85 libwacom_match_destroy(NULL);
86 libwacom_match_new(NULL, 0, 0, 0);
87 libwacom_error_set(NULL, 0, NULL);
88 libwacom_stylus_destroy(NULL);
89 libwacom_update_match(NULL, NULL);
90
91 return 0;
92 }