Blame elf/tst-audit15.c

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