Blame elf/tst-audit15.c

Packit Service d5c301
/* Main program with DT_AUDIT and DT_DEPAUDIT.  Two audit modules.
Packit Service d5c301
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service d5c301
   This file is part of the GNU C Library.
Packit Service d5c301
Packit Service d5c301
   The GNU C Library is free software; you can redistribute it and/or
Packit Service d5c301
   modify it under the terms of the GNU Lesser General Public
Packit Service d5c301
   License as published by the Free Software Foundation; either
Packit Service d5c301
   version 2.1 of the License, or (at your option) any later version.
Packit Service d5c301
Packit Service d5c301
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service d5c301
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service d5c301
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service d5c301
   Lesser General Public License for more details.
Packit Service d5c301
Packit Service d5c301
   You should have received a copy of the GNU Lesser General Public
Packit Service d5c301
   License along with the GNU C Library; if not, see
Packit Service d5c301
   <https://www.gnu.org/licenses/>.  */
Packit Service d5c301
Packit Service d5c301
#include <stdlib.h>
Packit Service d5c301
#include <string.h>
Packit Service d5c301
#include <support/check.h>
Packit Service d5c301
#include <support/xstdio.h>
Packit Service d5c301
Packit Service d5c301
static int
Packit Service d5c301
do_test (void)
Packit Service d5c301
{
Packit Service d5c301
  /* Verify what the audit modules have written.  This test assumes
Packit Service d5c301
     that standard output has been redirected to a regular file.  */
Packit Service d5c301
  FILE *fp = xfopen ("/dev/stdout", "r");
Packit Service d5c301
Packit Service d5c301
  char *buffer = NULL;
Packit Service d5c301
  size_t buffer_length = 0;
Packit Service d5c301
  size_t line_length = xgetline (&buffer, &buffer_length, fp);
Packit Service d5c301
  const char *message = "info: tst-auditlogmod-1.so loaded\n";
Packit Service d5c301
  TEST_COMPARE_BLOB (message, strlen (message), buffer, line_length);
Packit Service d5c301
Packit Service d5c301
  line_length = xgetline (&buffer, &buffer_length, fp);
Packit Service d5c301
  message = "info: tst-auditlogmod-2.so loaded\n";
Packit Service d5c301
  TEST_COMPARE_BLOB (message, strlen (message), buffer, line_length);
Packit Service d5c301
Packit Service d5c301
  /* No more audit module output.  */
Packit Service d5c301
  line_length = xgetline (&buffer, &buffer_length, fp);
Packit Service d5c301
  TEST_COMPARE_BLOB ("", 0, buffer, line_length);
Packit Service d5c301
Packit Service d5c301
  free (buffer);
Packit Service d5c301
  xfclose (fp);
Packit Service d5c301
  return 0;
Packit Service d5c301
}
Packit Service d5c301
Packit Service d5c301
#include <support/test-driver.c>