/*-1* Copyright (c) 2022 Baptiste Daroussin <[email protected]>2*~3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer8* in this position and unchanged.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*~13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT18* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,19* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY20* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF22* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*/2425#include <atf-c.h>26#include <err.h>27#include <private/pkg.h>28#include <pkg_config.h>2930ATF_TC_WITHOUT_HEAD(basics);3132ATF_TC_BODY(basics, tc) {33#ifdef HAVE_FFLAGSTOSTR34const char *file = "./file type=file uname=root gname=wheel mode=644 flags=uchg\n"35"./dir type=dir uname=root gname=wheel mode=644 flags=uchg\n"36"./link type=link uname=root gname=wheel mode=644 link=bla\n";37#else38const char *file = "./file type=file uname=root gname=wheel mode=644 flags=\n"39"./dir type=dir uname=root gname=wheel mode=644 flags=\n"40"./link type=link uname=root gname=wheel mode=644 link=bla\n";41#endif42ATF_REQUIRE_EQ(EPKG_FATAL, metalog_open("/dev/nope/nope"));43ATF_REQUIRE_EQ(EPKG_FATAL, metalog_add(PKG_METALOG_FILE, "meh", "root", "wheel", 0644, 2, NULL));44ATF_REQUIRE_EQ(EPKG_OK, metalog_open("out"));45ATF_REQUIRE_EQ(EPKG_OK, metalog_add(PKG_METALOG_FILE, "file", "root", "wheel", 0644, 2, NULL));46ATF_REQUIRE_EQ(EPKG_OK, metalog_add(PKG_METALOG_DIR, "dir", "root", "wheel", 0644, 2, NULL));47ATF_REQUIRE_EQ(EPKG_OK, metalog_add(PKG_METALOG_LINK, "link", "root", "wheel", 0644, 0, "bla"));48metalog_close();49if (!atf_utils_compare_file("out", file)) {50atf_utils_cat_file("out", ">");51atf_tc_fail("Invalid file");52}53}5455ATF_TP_ADD_TCS(tp)56{57ATF_TP_ADD_TC(tp, basics);5859return (atf_no_error());60}616263