Hi, > To handle this situation(no signalfd.h) in .[ch] file, I have to define > my own signalfd with using syscall macro and types in my test case. > (I call this C level solution.) > > To handle this situation in Makefile level, I have to define check_header > macro in my Makefile and add run-xxx.sh script. > (I call this Makefile level solution.) > > > You wrote C level solution is better. However, I think implementing the > solution is hard to maintain the test cases. In addition C level solution > cannot detect the bug in glibc. > > I'd like to choose Makefile level solution. > In the next Mail I'll show my implemention of Makefile level solution. > So based on my code, please discuss which solution is better.
Here is the Makefile level solution.
I'd like to introduce cond.mk, in which check_header macro is defined.
check_header macro checks whether sys/signalfd.h exists or not.
In the Makefile of signalfd, -DHAS_SIGNALFD_H is added to CFLAGS if
sys/signalfd.h exists. If it doesn't exist, following code is compiled
as signalfd01 test case:
#include <stdio.h>
int
main(int argc, char** argv)
{
printf("%s 0 CONF: System doesn't support execution of the test\n",
"signalfd01");
return 0;
}
I know people don't like ifdef/endif.
In my opinion in big source code ifdef/endif is bad.
However, generally a test case is not so big, so using
ifdef/endif may be o.k.
Please review the code, and give me feed back.
If they are acceptable, I'll modify other test cases to use cond.mk.
If submitting a patch for reviewing in MIME attachment is inconvenient, let me
know.
I'll paste my code to my mail.
Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]>
# cond.mk --- useful functions to write conditions
#
# Copyright (c) International Business Machines Corp., 2001
# Copyright (c) Red Hat Inc., 2008
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# NAME
# check_header: Checking the existence of header file.
#
# SYNOPSIS
# $(call check_header,HEADFILE)
# $(call check_header,HEADFILE,STRING_IF_FOUND)
# $(call check_header,HEADFILE,STRING_IF_FOUND,STRING_IF_NOT_FOUND)
#
# DESCRIPTION
#
# check_header checks whether $(CC) can found HEADFILE or not.
#
# With the first form, "yes" is returned if it is found.
# "no" is returned if it is not found.
#
# With the second form, STRING_IF_FOUND is returned if it is found.
# "no" is returned if it is not found.
#
# With the second form, STRING_IF_FOUND is returned if it is found.
# STRING_IF_NOT_FOUND is returned if it is not found.
#
# EXAMPLES
#
# (1) yes or no
#
# include ../utils/cond.mk
#
# ifeq ($(call check_header,foo.h),yes)
# RULES if foo.h is available.
# else
# RULES IF foo.h is NOT available.
# endif
#
#
# (2) adding CFLAGS# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H, )
#
# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H, )
#
#
# NOTE
#
# Spaces after `,' are not striped automatically.
#
# The value for CFLAGS is different in following assignment:
#
# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H, )
# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H,)
#
check_header = $(shell
\
if [ "x$(2)" = "x" ]; then FOUND=yes; else FOUND="$(2)"; fi;
\
if [ "x$(3)" = "x" ]; then NOTFOUND=no; else NOTFOUND="$(3)"; fi;
\
if echo "\#include <$(1)>" | $(CC) -E - > /dev/null 2>&1 ;
\
then echo "$${FOUND}" ;
\
else echo "$${NOTFOUND}" ; fi)
#COND_MK_DEBUG=yes
ifdef COND_MK_DEBUG
all:
@echo "-DHAS_STDIO_H == $(call check_header,stdio.h,-DHAS_STDIO_H,)"
@echo "\" \" == \"$(call check_header,foo.h,-DHAS_FOO_H, )\""
@echo "yes == $(call check_header,stdio.h)"
@echo "no == $(call check_header,foo.h)"
@echo "YES == $(call check_header,stdio.h,YES)"
@echo "no == $(call check_header,foo.h,YES)"
@echo "YES == $(call check_header,stdio.h,YES,NO)"
@echo "NO == $(call check_header,foo.h,YES,NO)"
endif
# cond.mk ends here.
signalfd.tar.gz
Description: Binary data
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
