about summary refs log tree commit diff
path: root/elf/valgrind-test.c
diff options
context:
space:
mode:
authorAlexandra Hájková <ahajkova@redhat.com>2021-10-26 11:42:44 +0200
committerAlexandra Hájková <ahajkova@redhat.com>2022-01-22 17:31:16 +0100
commit6c2f050dbe11fb4ed0a401a5f25731f2aa53046b (patch)
treed18ef8608320942fe90b94aacfa007c8a32fe970 /elf/valgrind-test.c
parent8c86ba446367fd676457e51eb44d7af2e5d9a392 (diff)
downloadglibc-6c2f050dbe11fb4ed0a401a5f25731f2aa53046b.tar.gz
glibc-6c2f050dbe11fb4ed0a401a5f25731f2aa53046b.tar.xz
glibc-6c2f050dbe11fb4ed0a401a5f25731f2aa53046b.zip
Add valgrind smoke test
Check if whether valgrind is available in the test environment.
If not, skip the test. Run smoke tests with valgrind to verify dynamic loader.
First, check if algrind works with the system ld.so in the test
environment. Then run the actual test inside the test environment,
using the just build ld.so and new libraries.

Co-authored-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'elf/valgrind-test.c')
-rw-r--r--elf/valgrind-test.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/elf/valgrind-test.c b/elf/valgrind-test.c
new file mode 100644
index 0000000000..71b8a09b35
--- /dev/null
+++ b/elf/valgrind-test.c
@@ -0,0 +1,49 @@
+/* This is the simple test intended to be called by
+   tst-valgrind-smoke to perform vagrind smoke test.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <libintl.h>
+#include <locale.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <support/support.h>
+
+int
+main (int argc, char **argv)
+{
+  /* Do some non-trivial stuff that has been known to trigger
+     issues under valgrind in the past.
+     Setting up the locale textdomain makes sure to test some
+     string/path comparisons, file search and library loading. */
+  xsetlocale (LC_ALL, "");
+  if (bindtextdomain ("translit", "") == NULL)
+      return errno;
+  if (textdomain ("translit") == NULL)
+      return errno;
+
+  /* Show what we are executing and how...  */
+  char *me = realpath (argv[0], NULL);
+  printf ("bin: %s\n", me);
+  printf ("ld.so: %s\n", argv[1]);
+  free (me);
+
+  return 0;
+}