x86_64: Remove platform directory library loading test
[glibc.git] / elf / tst-audit25b.c
blob46391770fdfc179668c986b1d9550879a0028323
1 /* Check LD_AUDIT and LD_BIND_NOW.
2 Copyright (C) 2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <getopt.h>
21 #include <limits.h>
22 #include <inttypes.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <support/capture_subprocess.h>
26 #include <support/check.h>
27 #include <support/xstdio.h>
28 #include <support/support.h>
29 #include <sys/auxv.h>
31 static int restart;
32 #define CMDLINE_OPTIONS \
33 { "restart", no_argument, &restart, 1 },
35 void tst_audit25mod1_func1 (void);
36 void tst_audit25mod1_func2 (void);
37 void tst_audit25mod2_func1 (void);
38 void tst_audit25mod2_func2 (void);
40 static int
41 handle_restart (void)
43 tst_audit25mod1_func1 ();
44 tst_audit25mod1_func2 ();
45 tst_audit25mod2_func1 ();
46 tst_audit25mod2_func2 ();
48 return 0;
51 static int
52 do_test (int argc, char *argv[])
54 /* We must have either:
55 - One or four parameters left if called initially:
56 + path to ld.so optional
57 + "--library-path" optional
58 + the library path optional
59 + the application name */
61 if (restart)
62 return handle_restart ();
64 setenv ("LD_AUDIT", "tst-auditmod25.so", 0);
66 char *spargv[9];
67 int i = 0;
68 for (; i < argc - 1; i++)
69 spargv[i] = argv[i + 1];
70 spargv[i++] = (char *) "--direct";
71 spargv[i++] = (char *) "--restart";
72 spargv[i] = NULL;
75 struct support_capture_subprocess result
76 = support_capture_subprogram (spargv[0], spargv);
77 support_capture_subprocess_check (&result, "tst-audit25a", 0,
78 sc_allow_stderr);
80 /* tst-audit25a and tst-audit25mod1 are built with -Wl,-z,now, but
81 tst-audit25mod2 is built with -Wl,-z,lazy. So only
82 tst_audit25mod4_func1 (called by tst_audit25mod2_func1) should not
83 have LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT. */
84 TEST_COMPARE_STRING (result.err.buffer,
85 "la_symbind: tst_audit25mod3_func1 1\n"
86 "la_symbind: tst_audit25mod1_func1 1\n"
87 "la_symbind: tst_audit25mod2_func1 1\n"
88 "la_symbind: tst_audit25mod1_func2 1\n"
89 "la_symbind: tst_audit25mod2_func2 1\n"
90 "la_symbind: tst_audit25mod4_func1 0\n");
92 support_capture_subprocess_free (&result);
96 setenv ("LD_BIND_NOW", "1", 0);
97 struct support_capture_subprocess result
98 = support_capture_subprogram (spargv[0], spargv);
99 support_capture_subprocess_check (&result, "tst-audit25a", 0,
100 sc_allow_stderr);
102 /* With LD_BIND_NOW all symbols are expected to have
103 LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT. Also the resolution
104 order is done in breadth-first order. */
105 TEST_COMPARE_STRING (result.err.buffer,
106 "la_symbind: tst_audit25mod4_func1 1\n"
107 "la_symbind: tst_audit25mod3_func1 1\n"
108 "la_symbind: tst_audit25mod1_func1 1\n"
109 "la_symbind: tst_audit25mod2_func1 1\n"
110 "la_symbind: tst_audit25mod1_func2 1\n"
111 "la_symbind: tst_audit25mod2_func2 1\n");
113 support_capture_subprocess_free (&result);
116 return 0;
119 #define TEST_FUNCTION_ARGV do_test
120 #include <support/test-driver.c>