]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/tst-audit14.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / elf / tst-audit14.c
1 /* Main program with DT_AUDIT. One audit module.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19 #include <stdlib.h>
20 #include <string.h>
21 #include <support/check.h>
22 #include <support/xstdio.h>
23
24 static int
25 do_test (void)
26 {
27 /* Verify what the audit module has written. This test assumes that
28 standard output has been redirected to a regular file. */
29 FILE *fp = xfopen ("/dev/stdout", "r");
30
31 char *buffer = NULL;
32 size_t buffer_length = 0;
33 size_t line_length = xgetline (&buffer, &buffer_length, fp);
34 const char *message = "info: tst-auditlogmod-1.so loaded\n";
35 TEST_COMPARE_BLOB (message, strlen (message), buffer, line_length);
36
37 /* No more audit module output. */
38 line_length = xgetline (&buffer, &buffer_length, fp);
39 TEST_COMPARE_BLOB ("", 0, buffer, line_length);
40
41 free (buffer);
42 xfclose (fp);
43 return 0;
44 }
45
46 #include <support/test-driver.c>