Added a testcase for offsetof. Reorganized the rest.

This commit is contained in:
rillig 2007-03-08 14:31:06 +00:00
parent 30823b1e96
commit f100f6b8e2
6 changed files with 54 additions and 18 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2007/02/22 19:01:24 wiz Exp $
# $NetBSD: Makefile,v 1.4 2007/03/08 14:31:06 rillig Exp $
#
DISTNAME= compiler-1.1
@ -11,25 +11,12 @@ COMMENT= Tests whether the pkgsrc compilers work as expected
NO_CHECKSUM= yes
WRKSRC= ${WRKDIR}
USE_TOOLS+= printf
SRC_CMD= ${PRINTF} '\#if defined(__cplusplus)\nLANG: Cplus\n\#else\nLANG: Cplain\n\#endif\n'
USE_LANGUAGES= c c++
do-extract:
cd ${FILESDIR} && cp *.c ${WRKSRC}
cd ${FILESDIR} && cp Makefile *.c ${WRKSRC}
cd ${WRKSRC} && for i in *.c; do ln $$i $${i}c; done
do-build:
# Test whether CPP is a C preprocessor.
${SRC_CMD} | cpp -DLANG=Cplain
# Test whether CXXCPP is a C++ preprocessor.
# CXXCPP is not (yet)? defined.
#${SRC_CMD} | cxxcpp -DLANG=Cplus
# Test whether white-space is preserved in macro definitions.
cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES=\"\ \ \ \ \" && ./checklen
cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES=\"" \"" && ./checklen
cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES='" "' && ./checklen
# Test whether backslashes are preserved in macro definitions.
cd ${WRKSRC} && cc -c checktype.c -DTYPE="unsigned long"
cd ${WRKSRC} && cc -c checktype.c -DTYPE=unsigned\ long
do-wrksrc-build:
.include "../../mk/bsd.pkg.mk"

View file

@ -0,0 +1,29 @@
# $NetBSD: Makefile,v 1.1 2007/03/08 14:31:06 rillig Exp $
#
all: \
test-preprocessor \
test-offsetof \
test-wrapper
test-preprocessor:
# Test whether CPP is a C preprocessor.
${CPP} language.c | grep Cplain
.if defined(CXXCPP)
# Test whether CXXCPP is a C++ preprocessor.
${CXXCPP} language.cc | grep Cplus
.endif
test-wrapper:
# Test whether white-space is preserved in macro definitions.
${CC} checklen.c -o checklen -DLEN=4 -DSPACES=\"\ \ \ \ \" && ./checklen
${CC} checklen.c -o checklen -DLEN=4 -DSPACES=\"" \"" && ./checklen
${CC} checklen.c -o checklen -DLEN=4 -DSPACES='" "' && ./checklen
# Test whether backslashes are preserved in macro definitions.
${CC} -c checktype.c -DTYPE="unsigned long"
${CC} -c checktype.c -DTYPE=unsigned\ long
test-offsetof:
# Test whether offsetof is available in both C and C++
${CC} -c offsetof.c
${CXX} -c offsetof.c

View file

@ -1,3 +1,5 @@
/* $NetBSD: checklen.c,v 1.2 2007/03/08 14:31:06 rillig Exp $ */
#include <assert.h>
#include <string.h>

View file

@ -1 +1,3 @@
/* $NetBSD: checktype.c,v 1.2 2007/03/08 14:31:06 rillig Exp $ */
typedef TYPE t;

View file

@ -0,0 +1,7 @@
/* $NetBSD: language.c,v 1.1 2007/03/08 14:31:07 rillig Exp $ */
#if defined(__cplusplus)
Cplus
#else
Cplain
#endif

View file

@ -0,0 +1,9 @@
/* $NetBSD: offsetof.c,v 1.1 2007/03/08 14:31:07 rillig Exp $ */
#include <stddef.h>
#if !defined(offsetof)
"force a syntax error" = 1;
#else
typedef int dummy;
#endif