Blame SOURCES/valgrind-3.12.0-skip-cond-var.patch

aa821a
commit 88cf06207b074f387c04de4938a0bb20366616b0
aa821a
Author: mjw <mjw@a5019735-40e9-0310-863c-91ae7b9d1cf9>
aa821a
Date:   Fri Oct 21 00:02:10 2016 +0000
aa821a
aa821a
    Add libc_test to workaround pth_cond_destroy_busy test hangs.
aa821a
    
aa821a
    This is a workaround for bug #371396. It adds a new test program
aa821a
    that can be used skip tests given a specific libc implementation
aa821a
    and optionally a specific minimum version. Currently only glibc
aa821a
    is recognized. This is used for the drd and helgrind tests
aa821a
    pth_cond_destroy_busy to be skipped on glibc 2.24.90+.
aa821a
    
aa821a
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16097 a5019735-40e9-0310-863c-91ae7b9d1cf9
aa821a
aa821a
diff --git a/drd/tests/pth_cond_destroy_busy.vgtest b/drd/tests/pth_cond_destroy_busy.vgtest
aa821a
index eafbd74..f3cf778 100644
aa821a
--- a/drd/tests/pth_cond_destroy_busy.vgtest
aa821a
+++ b/drd/tests/pth_cond_destroy_busy.vgtest
aa821a
@@ -1,2 +1,2 @@
aa821a
-prereq: ./supported_libpthread
aa821a
+prereq: ./supported_libpthread && ! ../../tests/libc_test glibc 2.24.90
aa821a
 prog: pth_cond_destroy_busy
aa821a
diff --git a/helgrind/tests/pth_cond_destroy_busy.vgtest b/helgrind/tests/pth_cond_destroy_busy.vgtest
aa821a
index 45d7853..2957cc3 100644
aa821a
--- a/helgrind/tests/pth_cond_destroy_busy.vgtest
aa821a
+++ b/helgrind/tests/pth_cond_destroy_busy.vgtest
aa821a
@@ -1,2 +1,2 @@
aa821a
-prereq: ! ../../tests/os_test darwin
aa821a
+prereq: ! ../../tests/os_test darwin && ! ../../tests/libc_test glibc 2.24.90
aa821a
 prog: ../../drd/tests/pth_cond_destroy_busy
aa821a
diff --git a/tests/Makefile.am b/tests/Makefile.am
aa821a
index 9c0cc3a..7233626 100644
aa821a
--- a/tests/Makefile.am
aa821a
+++ b/tests/Makefile.am
aa821a
@@ -44,6 +44,7 @@ noinst_HEADERS = \
aa821a
 check_PROGRAMS = \
aa821a
 	arch_test \
aa821a
 	os_test \
aa821a
+	libc_test \
aa821a
 	true \
aa821a
 	x86_amd64_features \
aa821a
 	s390x_features \
aa821a
diff --git a/tests/libc_test.c b/tests/libc_test.c
aa821a
new file mode 100644
aa821a
index 0000000..0de3d5d
aa821a
--- /dev/null
aa821a
+++ b/tests/libc_test.c
aa821a
@@ -0,0 +1,78 @@
aa821a
+// Compare given libc name and version number to system name and version.
aa821a
+
aa821a
+// Returns
aa821a
+// - 0 if the libc name matches is at least the minimum version (if given).
aa821a
+// - 1 if the libc name doesn't match or the version is lower than requested.
aa821a
+// - 2 if the requested libc name isn't recognised.
aa821a
+// - 3 if there was a usage error (it also prints an error message).
aa821a
+
aa821a
+#include <stdio.h>
aa821a
+#include <stdlib.h>
aa821a
+#include <string.h>
aa821a
+
aa821a
+#ifdef __GLIBC__
aa821a
+#include <gnu/libc-version.h>
aa821a
+#endif
aa821a
+
aa821a
+#define False  0
aa821a
+#define True   1
aa821a
+typedef int    Bool;
aa821a
+
aa821a
+/* Assumes the versions are x.y.z, with y and z optional. */
aa821a
+static Bool matches_version(char *min_version) {
aa821a
+   int a1=0, a2=0, a3=0, g1=0, g2=0, g3=0;  // 'a' = actual;  'g' = given
aa821a
+   const char *aversion;
aa821a
+
aa821a
+   if (min_version == NULL)  return True;  // no version specified
aa821a
+
aa821a
+   // get actual version number
aa821a
+#ifdef __GLIBC__
aa821a
+   aversion = gnu_get_libc_version();
aa821a
+#else
aa821a
+   aversion = "unknown";
aa821a
+#endif
aa821a
+   // We expect at least one number.
aa821a
+   if (sscanf(aversion, "%d.%d.%d", &a1, &a2, &a3) < 1) return False;
aa821a
+
aa821a
+   // parse given version number.
aa821a
+   if (sscanf(min_version, "%d.%d.%d", &g1, &g2, &g3) < 1) return False;
aa821a
+
aa821a
+   if (a1 > g1) return True;
aa821a
+   if (a1 < g1) return False;
aa821a
+   if (a2 > g2) return True;
aa821a
+   if (a2 < g2) return False;
aa821a
+   if (a3 >= g3) return True;
aa821a
+
aa821a
+   return False;
aa821a
+}
aa821a
+
aa821a
+static Bool go(char* libc, char *min_version)
aa821a
+{
aa821a
+#ifdef __GLIBC__
aa821a
+   if ( 0 == strcmp( libc, "glibc" )
aa821a
+	&& matches_version( min_version ))
aa821a
+      return True;
aa821a
+#endif
aa821a
+
aa821a
+   return False;
aa821a
+}
aa821a
+
aa821a
+//---------------------------------------------------------------------------
aa821a
+// main
aa821a
+//---------------------------------------------------------------------------
aa821a
+int main(int argc, char **argv)
aa821a
+{
aa821a
+   if ( argc < 2 ) {
aa821a
+      fprintf( stderr, "usage: libc_test <libc-name> [<min-version>]\n" );
aa821a
+      exit(3);             // Usage error.
aa821a
+   }
aa821a
+   if (go( argv[1], argv[2] )) {
aa821a
+      return 0;            // Matched.
aa821a
+   }
aa821a
+
aa821a
+   if ( 0 == strcmp ( argv[1], "glibc" ) ) {
aa821a
+     return 1;             // Requested libc name known, but this isn't it.
aa821a
+                           // Or it wasn't the minimum requested version.
aa821a
+   }
aa821a
+   return 2;               // Didn't match any known libc name.
aa821a
+}
aa821a
Only in valgrind-3.12.0.RC2: autom4te.cache
aa821a
diff -ur valgrind-3.12.0.RC2.orig/tests/Makefile.in valgrind-3.12.0.RC2/tests/Makefile.in
aa821a
--- valgrind-3.12.0.RC2.orig/tests/Makefile.in	2016-10-21 02:10:24.283643034 +0200
aa821a
+++ valgrind-3.12.0.RC2/tests/Makefile.in	2016-10-21 02:11:09.668003685 +0200
aa821a
@@ -121,10 +121,11 @@
aa821a
 @COMPILER_IS_CLANG_TRUE@	-Wno-uninitialized -Wno-unused-value # \
aa821a
 @COMPILER_IS_CLANG_TRUE@	clang 3.0.0
aa821a
 @COMPILER_IS_CLANG_TRUE@am__append_7 = -Wno-unused-private-field    # drd/tests/tsan_unittest.cpp
aa821a
-check_PROGRAMS = arch_test$(EXEEXT) os_test$(EXEEXT) true$(EXEEXT) \
aa821a
-	x86_amd64_features$(EXEEXT) s390x_features$(EXEEXT) \
aa821a
-	mips_features$(EXEEXT) power_insn_available$(EXEEXT) \
aa821a
-	is_ppc64_BE$(EXEEXT) min_power_isa$(EXEEXT)
aa821a
+check_PROGRAMS = arch_test$(EXEEXT) os_test$(EXEEXT) \
aa821a
+	libc_test$(EXEEXT) true$(EXEEXT) x86_amd64_features$(EXEEXT) \
aa821a
+	s390x_features$(EXEEXT) mips_features$(EXEEXT) \
aa821a
+	power_insn_available$(EXEEXT) is_ppc64_BE$(EXEEXT) \
aa821a
+	min_power_isa$(EXEEXT)
aa821a
 subdir = tests
aa821a
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
aa821a
 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
aa821a
@@ -142,6 +143,9 @@
aa821a
 is_ppc64_BE_SOURCES = is_ppc64_BE.c
aa821a
 is_ppc64_BE_OBJECTS = is_ppc64_BE.$(OBJEXT)
aa821a
 is_ppc64_BE_LDADD = $(LDADD)
aa821a
+libc_test_SOURCES = libc_test.c
aa821a
+libc_test_OBJECTS = libc_test.$(OBJEXT)
aa821a
+libc_test_LDADD = $(LDADD)
aa821a
 min_power_isa_SOURCES = min_power_isa.c
aa821a
 min_power_isa_OBJECTS = min_power_isa-min_power_isa.$(OBJEXT)
aa821a
 min_power_isa_LDADD = $(LDADD)
aa821a
@@ -201,10 +205,10 @@
aa821a
 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
aa821a
 am__v_CCLD_0 = @echo "  CCLD    " $@;
aa821a
 am__v_CCLD_1 = 
aa821a
-SOURCES = arch_test.c is_ppc64_BE.c min_power_isa.c mips_features.c \
aa821a
-	os_test.c power_insn_available.c s390x_features.c true.c \
aa821a
-	x86_amd64_features.c
aa821a
-DIST_SOURCES = arch_test.c is_ppc64_BE.c min_power_isa.c \
aa821a
+SOURCES = arch_test.c is_ppc64_BE.c libc_test.c min_power_isa.c \
aa821a
+	mips_features.c os_test.c power_insn_available.c \
aa821a
+	s390x_features.c true.c x86_amd64_features.c
aa821a
+DIST_SOURCES = arch_test.c is_ppc64_BE.c libc_test.c min_power_isa.c \
aa821a
 	mips_features.c os_test.c power_insn_available.c \
aa821a
 	s390x_features.c true.c x86_amd64_features.c
aa821a
 am__can_run_installinfo = \
aa821a
@@ -681,6 +685,10 @@
aa821a
 	@rm -f is_ppc64_BE$(EXEEXT)
aa821a
 	$(AM_V_CCLD)$(LINK) $(is_ppc64_BE_OBJECTS) $(is_ppc64_BE_LDADD) $(LIBS)
aa821a
 
aa821a
+libc_test$(EXEEXT): $(libc_test_OBJECTS) $(libc_test_DEPENDENCIES) $(EXTRA_libc_test_DEPENDENCIES) 
aa821a
+	@rm -f libc_test$(EXEEXT)
aa821a
+	$(AM_V_CCLD)$(LINK) $(libc_test_OBJECTS) $(libc_test_LDADD) $(LIBS)
aa821a
+
aa821a
 min_power_isa$(EXEEXT): $(min_power_isa_OBJECTS) $(min_power_isa_DEPENDENCIES) $(EXTRA_min_power_isa_DEPENDENCIES) 
aa821a
 	@rm -f min_power_isa$(EXEEXT)
aa821a
 	$(AM_V_CCLD)$(min_power_isa_LINK) $(min_power_isa_OBJECTS) $(min_power_isa_LDADD) $(LIBS)
aa821a
@@ -717,6 +725,7 @@
aa821a
 
aa821a
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arch_test.Po@am__quote@
aa821a
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_ppc64_BE.Po@am__quote@
aa821a
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libc_test.Po@am__quote@
aa821a
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/min_power_isa-min_power_isa.Po@am__quote@
aa821a
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mips_features.Po@am__quote@
aa821a
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os_test.Po@am__quote@