From e98779aa56fae0346dff2d0b72acadd0eaf01891 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 27 May 2015 16:10:50 -0700
Subject: [PATCH 27/27] eglibc-use-option-groups: Conditionally exclude c++
 tests

    Some test programs written in c++ are still included in spite of
    "libc-cxx-tests" being omitted from DISTRO_FEATURES_LIBC.
    All .cc programs are compiled with g++.
    g++ automatically specifies linking against the C++ library.
    This patch conditionally excludes the following tests as well:

      bug-atexit3-lib.cc
      tst-cancel24.cc
      tst-cancel24-static.cc
      tst-unique3lib.cc
      tst-unique3lib2.cc
      tst-unique4lib.cc
      tst-unique3.cc
      tst-unique4.cc

    Tested with DISTRO_FEATURES_LIBC_remove = " libc-cxx-tests"

    [YOCTO #7003]

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 dlfcn/Makefile |  8 ++++++--
 elf/Makefile   | 19 ++++++++++++++-----
 nptl/Makefile  | 12 ++++++++++--
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/dlfcn/Makefile b/dlfcn/Makefile
index 3827607..920bd58 100644
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -39,16 +39,20 @@ ifeq (yes,$(build-shared))
 tests = glrefmain failtest tst-dladdr default errmsg1 tstcxaatexit \
 	bug-dlopen1 bug-dlsym1 tst-dlinfo bug-atexit1 bug-atexit2 \
 	tstatexit bug-dl-leaf tst-rec-dlopen
-endif
-
 tests-$(OPTION_EGLIBC_CXX_TESTS) += bug-atexit3
 
+endif
+
 modules-names = glreflib1 glreflib2 glreflib3 failtestmod defaultmod1 \
 		defaultmod2 errmsg1mod modatexit modcxaatexit \
 		bug-dlsym1-lib1 bug-dlsym1-lib2 bug-atexit1-lib \
 		bug-atexit2-lib bug-dl-leaf-lib \
 		bug-dl-leaf-lib-cb moddummy1 moddummy2
 
+ifeq (y,$(OPTION_EGLIBC_CXX_TESTS))
+modules-names += bug-atexit3-lib
+endif
+
 failtestmod.so-no-z-defs = yes
 glreflib2.so-no-z-defs = yes
 errmsg1mod.so-no-z-defs = yes
diff --git a/elf/Makefile b/elf/Makefile
index 71a18a1..26fe3c5 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -17,6 +17,8 @@
 
 # Makefile for elf subdirectory of GNU C Library.
 
+include ../option-groups.mak
+
 subdir		:= elf
 
 include ../Makeconfig
@@ -145,12 +147,15 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
 	 tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
 	 tst-stackguard1 tst-addr1 tst-thrlock \
-	 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
-	 tst-nodelete) \
+	 tst-unique1 tst-unique2 \
 	 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
 	 tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
 	 tst-nodelete2
 #	 reldep9
+ifeq (y,$(OPTION_EGLIBC_CXX_TESTS))
+tests += $(if $(CXX),tst-unique3 tst-unique4 tst-nodelete)
+endif
+
 ifeq ($(build-hardcoded-path-in-tests),yes)
 tests += tst-dlopen-aout
 LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
@@ -209,9 +214,6 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
 		tst-unique1mod1 tst-unique1mod2 \
 		tst-unique2mod1 tst-unique2mod2 \
 		tst-auditmod9a tst-auditmod9b \
-		$(if $(CXX),tst-unique3lib tst-unique3lib2 tst-unique4lib \
-		  tst-nodelete-uniquemod tst-nodelete-rtldmod \
-		  tst-nodelete-zmod) \
 		tst-initordera1 tst-initorderb1 \
 		tst-initordera2 tst-initorderb2 \
 		tst-initordera3 tst-initordera4 \
@@ -220,6 +222,13 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
 		tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
 		tst-array5dep tst-null-argv-lib \
 		tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod
+
+ifeq (y,$(OPTION_EGLIBC_CXX_TESTS))
+modules-names += $(if $(CXX),tst-unique3lib tst-unique3lib2 tst-unique4lib \
+		  tst-nodelete-uniquemod tst-nodelete-rtldmod \
+		  tst-nodelete-zmod)
+endif
+
 ifeq (yes,$(have-protected-data))
 modules-names += tst-protected1moda tst-protected1modb
 tests += tst-protected1a tst-protected1b
diff --git a/nptl/Makefile b/nptl/Makefile
index 596ca3c..50a708b 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -390,12 +390,20 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 		    $(common-objpfx)libc.a
 
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
-		tst-cancel21-static tst-cancel24-static tst-cond8-static \
+		tst-cancel21-static tst-cond8-static \
 		tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
 		tst-sem12-static
-tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
+
+ifeq (y,$(OPTION_EGLIBC_CXX_TESTS))
+tests-static += tst-cancel24-static
+endif
+
+tests += tst-stackguard1-static tst-cancel21-static \
 	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
 	 tst-sem11-static tst-sem12-static
+
+tests-$(OPTION_EGLIBC_CXX_TESTS) += tst-cancel24-static
+
 xtests-static += tst-setuid1-static
 
 # These tests are linked with libc before libpthread
-- 
2.1.4