Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a new sub-dir under tests for pkg_printf. This pokes around in the private internals of pkg_printf, so it specially compiles pkg_printf.c using CPP trickery to make all the static functions in there extern. This means it has to be a separate binary from the tests in ../lib
Matthew Seaman committed 12 years ago
commit 0fc9a5dccbb923658a6cfb1c71557a063f8ca76d
parent 1b34f58
5 files changed +113 -12
modified libpkg/pkg_printf.c
@@ -37,7 +37,7 @@
#include <time.h>

#include "pkg.h"
-
#include "private/pkg_printf.h"
+
#include <private/pkg_printf.h>

/*
 * Format codes
@@ -1430,7 +1430,7 @@ iterate_item(struct sbuf *sbuf, const struct pkg *pkg, const char *format,
	return (sbuf);
}

-
inline const char *
+
const char *
field_modifier(const char *f, struct percent_esc *p)
{
	bool	done;
@@ -1478,7 +1478,7 @@ field_modifier(const char *f, struct percent_esc *p)
	return (f);
}

-
inline const char *
+
const char *
field_width(const char *f, struct percent_esc *p)
{
	bool	done;
@@ -1531,7 +1531,7 @@ field_width(const char *f, struct percent_esc *p)
	return (f);
}

-
inline const char *
+
const char *
format_trailer(const char *f, struct percent_esc *p)
{

@@ -1639,7 +1639,7 @@ parse_format(const char *f, unsigned context, struct percent_esc *p)
	return (f);
}

-
inline const char*
+
const char*
maybe_read_hex_byte(struct sbuf *sbuf, const char *f)
{
	int	val;
@@ -1773,7 +1773,7 @@ maybe_read_hex_byte(struct sbuf *sbuf, const char *f)
	return (f);
}

-
inline const char*
+
const char*
read_oct_byte(struct sbuf *sbuf, const char *f)
{
	int	val = 0;
modified libpkg/private/pkg_printf.h
@@ -28,7 +28,7 @@
#ifndef _PKG_PRINTF_H
#define _PKG_PRINTF_H

-
#include "pkg.h"
+
#include <pkg.h>

#ifdef TESTING
#define _static	
@@ -213,12 +213,13 @@ _static struct percent_esc *set_list_defaults(struct percent_esc *, const char *
_static struct sbuf *iterate_item(struct sbuf *, const struct pkg *, const char *,
				 const void *, int, unsigned);

-
_static inline const char *field_modifier(const char *, struct percent_esc *);
-
_static inline const char *field_width(const char *, struct percent_esc *);
+
_static const char *field_modifier(const char *, struct percent_esc *);
+
_static const char *field_width(const char *, struct percent_esc *);
+
_static const char *format_trailer(const char *, struct percent_esc *);
_static const char *parse_format(const char *, unsigned, struct percent_esc *);

-
_static inline const char *maybe_read_hex_byte(struct sbuf *, const char *);
-
_static inline const char *read_oct_byte(struct sbuf *, const char *);
+
_static const char *maybe_read_hex_byte(struct sbuf *, const char *);
+
_static const char *read_oct_byte(struct sbuf *, const char *);
_static const char *process_escape(struct sbuf *, const char *);

_static const char *process_format_trailer(struct sbuf *, const char *, const struct pkg *,
modified tests/Makefile
@@ -1,5 +1,6 @@
SUBDIR=	lib \
-
	frontend
+
	frontend \
+
	pkg_printf

.include <bsd.subdir.mk>

added tests/pkg_printf/Makefile
@@ -0,0 +1,65 @@
+
PROG=	test
+
SRCS=	test.c		\
+
	pkg_printf.c
+

+
TOPDIR=	${.CURDIR}/../..
+

+
CLEANFILES=	pkg_printf.c
+

+
CFLAGS+=-DTESTING		\
+
	-I${.CURDIR}		\
+
	-I${TOPDIR}/libpkg	\
+
	-I/usr/local/include
+

+
CFLAGS+=-I${TOPDIR}/external/sqlite		\
+
	-I${TOPDIR}/external/libyaml/include	\
+
	-I${TOPDIR}/external/uthash
+

+
.if defined(STATIC_TESTS)
+
NO_SHARED=	yes
+
.else
+
LDFLAGS+=	-Wl,-rpath=${TOPDIR}/libpkg
+
.endif
+

+
LDADD+=	-L${TOPDIR}/libpkg		\
+
	-lpkg				\
+
	-L${TOPDIR}/external/sqlite	\
+
	-lsqlite3			\
+
	-L${TOPDIR}/external/libyaml	\
+
	-lyaml				\
+
	-L/usr/local/lib		\
+
	-latf-c
+

+
.if defined(STATIC_TESTS)
+
LDADD+=	-larchive	\
+
	-lsbuf		\
+
	-lfetch		\
+
	-lelf		\
+
	-lutil		\
+
	-lpthread	\
+
	-lssl		\
+
	-lcrypto	\
+
	-lmd		\
+
	-lz		\
+
	-lbz2		\
+
	-llzma
+

+
.  if exists(/usr/include/edit/readline/readline.h)
+
LDADD+=	-ledit		\
+
	-lncursesw
+
.  endif
+
.endif
+

+
NO_MAN=	true
+

+
TESTS=	pkg_printf
+

+
pkg_printf.c:	${TOPDIR}/libpkg/pkg_printf.c
+
	ln -s ${.OODATE} ${.TARGET}
+

+
run: ${PROG}
+
.for test in ${TESTS}
+
	@env LD_LIBRARY_PATH=${TOPDIR}/libpkg ./${PROG} ${test}
+
.endfor
+

+
.include <bsd.prog.mk>
added tests/pkg_printf/test.c
@@ -0,0 +1,34 @@
+
/*
+
 * Copyright (c) 2012 Matthew Seaman <matthew@FreeBSD.org>
+
 * All rights reserved.
+
 * 
+
 * Redistribution and use in source and binary forms, with or without
+
 * modification, are permitted provided that the following conditions
+
 * are met:
+
 * 1. Redistributions of source code must retain the above copyright
+
 *    notice, this list of conditions and the following disclaimer
+
 *    in this position and unchanged.
+
 * 2. Redistributions in binary form must reproduce the above copyright
+
 *    notice, this list of conditions and the following disclaimer in the
+
 *    documentation and/or other materials provided with the distribution.
+
 * 
+
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 */
+

+
#include <atf-c.h>
+
#include <pkg.h>
+
#include <private/pkg_printf.h>
+

+
ATF_TP_ADD_TCS(tp)
+
{
+
	return atf_no_error();
+
}