Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a test case for parse_mode
Baptiste Daroussin committed 11 years ago
commit 420162fd81282af1c09b185f07358902106fb676
parent 64d0416
3 files changed +92 -31
modified tests/Kyuafile
@@ -4,5 +4,6 @@ test_suite("pkg")

atf_test_program{name='pkg_validation'}
atf_test_program{name='pkg_printf'}
+
atf_test_program{name='plist'}

include('frontend/Kyuafile')
modified tests/Makefile.am
@@ -1,43 +1,38 @@
AUTOMAKE_OPTIONS=	subdir-objects

+
GENERIC_LDADD=	$(top_builddir)/libpkg/libpkg_static.la \
+
		$(top_builddir)/external/libsbuf_static.la \
+
		@LIBJAIL_LIB@ \
+
		@LIBEXECINFO_LIB@ \
+
		@LIBELF_LIB@ \
+
		@LDNS_LIBS@ \
+
		-lfetch \
+
		-larchive \
+
		-lutil \
+
		-lm \
+
		-latf-c
+
PUBLIC_INCS=	-I$(top_srcdir)/libpkg -DTESTING
+
PRIVATE_INCS=	$(PUBLIC_INCS) \
+
		-I$(top_srcdir)/external/sqlite \
+
		-I$(top_srcdir)/external/uthash \
+
		-I$(top_srcdir)/external/libucl/include
+

pkg_printf_SOURCES=	lib/pkg_printf_test.c \
			lib/pkg_printf.c
-

CLEANFILES=		lib/pkg_printf.c
BUILT_SOURCES=		lib/pkg_printf.c
+
pkg_printf_CFLAGS=	$(PRIVATE_INCS)
+
pkg_printf_LDADD=	$(GENERIC_LDADD)

-
pkg_printf_CFLAGS=	-I$(top_srcdir)/libpkg -DTESTING \
-
			-I$(top_srcdir)/external/sqlite \
-
			-I$(top_srcdir)/external/uthash \
-
			-I$(top_srcdir)/external/libucl/include
-
pkg_printf_LDADD= $(top_builddir)/libpkg/libpkg_static.la \
-
			$(top_builddir)/external/libsbuf_static.la \
-
			$(pkg_OBJECTS) \
-
			@LIBJAIL_LIB@ \
-
			@LIBEXECINFO_LIB@ \
-
			@LIBELF_LIB@ \
-
			@LDNS_LIBS@ \
-
			-lfetch \
-
			-larchive \
-
			-lutil \
-
			-lm \
-
			-latf-c
pkg_validation_SOURCES=	lib/pkg_validation.c
-
pkg_validation_CFLAGS=	-I$(top_srcdir)/libpkg -DTESTING
-
pkg_validation_LDADD= $(top_builddir)/libpkg/libpkg_static.la \
-
			$(top_builddir)/external/libsbuf_static.la \
-
			$(pkg_OBJECTS) \
-
			@LIBJAIL_LIB@ \
-
			@LIBEXECINFO_LIB@ \
-
			@LIBELF_LIB@ \
-
			@LDNS_LIBS@ \
-
			-lfetch \
-
			-larchive \
-
			-lutil \
-
			-lm \
-
			-latf-c
+
pkg_validation_CFLAGS=	$(PUBLIC_INCS)
+
pkg_validation_LDADD=	$(GENERIC_LDADD)
+

+
plist_SOURCES=		lib/plist.c
+
plist_CFLAGS=		$(PRIVATE_INCS)
+
plist_LDADD=		$(GENERIC_LDADD)

-
tests_programs=	pkg_printf pkg_validation
+
tests_programs=	pkg_printf pkg_validation plist
EXTRA_PROGRAMS=	$(tests_programs)
check_PROGRAMS=	@TESTS@

added tests/lib/plist.c
@@ -0,0 +1,65 @@
+
/*-
+
 * Copyright (c) 2013 Baptiste Daroussin <bapt@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.h>
+

+
ATF_TC(parse_mode);
+

+
ATF_TC_HEAD(parse_mode, tc)
+
{
+
	atf_tc_set_md_var(tc, "descr",
+
	    "parse_mode()");
+
}
+

+
ATF_TC_BODY(parse_mode, tc)
+
{
+
	void *set;
+

+
	set = parse_mode("u+x");
+
	ATF_REQUIRE(set == NULL);
+

+
	set = parse_mode("plop");
+
	ATF_REQUIRE(set == NULL);
+

+
	set = parse_mode("0755");
+
	ATF_REQUIRE(set != NULL);
+

+
	free(set);
+

+
	set = parse_mode("u=r,g=rX");
+
	ATF_REQUIRE(set != NULL);
+

+
	free(set);
+
}
+

+
ATF_TP_ADD_TCS(tp)
+
{
+
	ATF_TP_ADD_TC(tp, parse_mode); 
+

+
	return (atf_no_error());
+
}