tests: return the proper TAP exit code
[lttng-ust.git] / tests / gcc-weak-hidden / main.c
CommitLineData
5a673446
MD
1/*
2 * Copyright (C) 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 *
4 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
6 *
7 * Permission is hereby granted to use or copy this program for any
8 * purpose, provided the above notices are retained on all copies.
9 * Permission to modify the code and to distribute modified code is
10 * granted, provided the above notices are retained, and a notice that
11 * the code was modified is included with the above copyright notice.
12 */
3227b2b9
MD
13
14#include <stdbool.h>
5a673446
MD
15#include "tap.h"
16
17#define NUM_TESTS 2
18
3227b2b9
MD
19int testint __attribute__((weak, visibility("hidden")));
20void *testptr __attribute__((weak, visibility("hidden")));
21struct {
22 char a[24];
23} testsym_24_bytes __attribute__((weak, visibility("hidden")));
24
25void *testfct_int(void);
26void *testfct_ptr(void);
27void *testfct_24_bytes(void);
28
29void *testlibfct1_int(void);
30void *testlibfct1_ptr(void);
31void *testlibfct1_24_bytes(void);
32
33void *testlibfct2_int(void);
34void *testlibfct2_ptr(void);
35void *testlibfct2_24_bytes(void);
36
37enum {
38 MATCH_PROGRAM_INT,
39 MATCH_PROGRAM_PTR,
40 MATCH_PROGRAM_24_BYTES,
41 MATCH_LIB_INT,
42 MATCH_LIB_PTR,
43 MATCH_LIB_24_BYTES,
44 NR_MATCH,
45};
5a673446 46
3227b2b9 47static bool match_matrix[NR_MATCH];
5a673446
MD
48
49int main()
50{
51 plan_tests(NUM_TESTS);
3227b2b9
MD
52
53 if (testfct_int() == &testint)
54 match_matrix[MATCH_PROGRAM_INT] = true;
55 if (testfct_ptr() == &testptr)
56 match_matrix[MATCH_PROGRAM_PTR] = true;
57 if (testfct_24_bytes() == &testsym_24_bytes)
58 match_matrix[MATCH_PROGRAM_24_BYTES] = true;
59
60 if (testlibfct1_int() == testlibfct2_int())
61 match_matrix[MATCH_LIB_INT] = true;
62 if (testlibfct1_ptr() == testlibfct2_ptr())
63 match_matrix[MATCH_LIB_PTR] = true;
64 if (testlibfct1_24_bytes() == testlibfct2_24_bytes())
65 match_matrix[MATCH_LIB_24_BYTES] = true;
66
67 diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)",
68 match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH");
69 diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)",
70 match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH");
71 diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)",
72 match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH");
73
74 diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)",
75 match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH");
76 diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)",
77 match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH");
78 diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)",
79 match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH");
80
c62783e7
MD
81 ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR],
82 "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program");
83 ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR],
84 "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library");
bf746e7d
MJ
85
86 return exit_status();
5a673446 87}
This page took 0.037899 seconds and 4 git commands to generate.