Fix failing nss/tst-nss-files-hosts-long with local resolver
[glibc.git] / elf / tst-audit16.c
blob168a294c86c3eea8294e294b3d34c6943bb40be6
1 /* Main program with DT_AUDIT and DT_DEPAUDIT. Three audit modules.
2 Copyright (C) 2020-2021 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 <stdlib.h>
20 #include <string.h>
21 #include <support/check.h>
22 #include <support/xstdio.h>
24 static int
25 do_test (void)
27 /* Verify what the audit modules have written. This test assumes
28 that standard output has been redirected to a regular file. */
29 FILE *fp = xfopen ("/dev/stdout", "r");
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);
37 line_length = xgetline (&buffer, &buffer_length, fp);
38 message = "info: tst-auditlogmod-2.so loaded\n";
39 TEST_COMPARE_BLOB (message, strlen (message), buffer, line_length);
41 line_length = xgetline (&buffer, &buffer_length, fp);
42 message = "info: tst-auditlogmod-3.so loaded\n";
43 TEST_COMPARE_BLOB (message, strlen (message), buffer, line_length);
45 /* No more audit module output. */
46 line_length = xgetline (&buffer, &buffer_length, fp);
47 TEST_COMPARE_BLOB ("", 0, buffer, line_length);
49 free (buffer);
50 xfclose (fp);
51 return 0;
54 #include <support/test-driver.c>