1 /* Check if DT_AUDIT a module with la_plt{enter,exit} call la_symbind
3 Copyright (C) 2021-2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
21 #include <support/capture_subprocess.h>
22 #include <support/check.h>
23 #include <support/xstdio.h>
29 #define CMDLINE_OPTIONS \
30 { "restart", no_argument, &restart, 1 },
32 int tst_audit18bmod1_func (void);
37 TEST_COMPARE (tst_audit18bmod1_func (), 10);
42 startswith (const char *str
, const char *pre
)
44 size_t lenpre
= strlen (pre
);
45 size_t lenstr
= strlen (str
);
46 return lenstr
< lenpre
? false : memcmp (pre
, str
, lenpre
) == 0;
50 do_test (int argc
, char *argv
[])
52 /* We must have either:
53 - One our fource parameters left if called initially:
54 + path to ld.so optional
55 + "--library-path" optional
56 + the library path optional
57 + the application name */
60 return handle_restart ();
64 for (; i
< argc
- 1; i
++)
65 spargv
[i
] = argv
[i
+ 1];
66 spargv
[i
++] = (char *) "--direct";
67 spargv
[i
++] = (char *) "--restart";
70 setenv ("LD_AUDIT", "tst-auditmod18b.so", 0);
71 struct support_capture_subprocess result
72 = support_capture_subprogram (spargv
[0], spargv
);
73 support_capture_subprocess_check (&result
, "tst-audit18b", 0, sc_allow_stderr
);
75 bool find_symbind
= false;
77 FILE *out
= fmemopen (result
.err
.buffer
, result
.err
.length
, "r");
78 TEST_VERIFY (out
!= NULL
);
80 size_t buffer_length
= 0;
81 while (xgetline (&buffer
, &buffer_length
, out
))
82 if (startswith (buffer
, "la_symbind: tst_audit18bmod1_func") == 0)
85 TEST_COMPARE (find_symbind
, true);
93 #define TEST_FUNCTION_ARGV do_test
94 #include <support/test-driver.c>