Index: stable/11/etc/mtree/BSD.tests.dist =================================================================== --- stable/11/etc/mtree/BSD.tests.dist (revision 321644) +++ stable/11/etc/mtree/BSD.tests.dist (revision 321645) @@ -1,712 +1,714 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chmod .. date .. dd .. echo .. expr .. ln .. ls .. mv .. pax .. pkill .. pwait .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. zfsd .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcam .. libcrypt .. libdevdctl .. libkvm .. libmp .. libnv .. libpam .. libproc .. librt .. libsbuf .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. + tap + .. .. .. .. sys acl .. aio .. fifo .. file .. fs tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. mac bsdextended .. portacl .. .. mqueue .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. sys .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. bsdcat .. calendar .. cmp .. compress .. cpio .. col .. comm .. cut .. dirname .. du .. file2c .. getconf .. grep .. gzip .. ident .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. pr .. printf .. procstat .. sdiff .. sed regress.multitest.out .. .. soelim .. stat .. tail .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. uniq .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin chown .. etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: stable/11/share/examples/tests/tests/Makefile =================================================================== --- stable/11/share/examples/tests/tests/Makefile (revision 321644) +++ stable/11/share/examples/tests/tests/Makefile (revision 321645) @@ -1,27 +1,28 @@ # $FreeBSD$ .include # Directory into which the Kyuafile provided by this directory will be # installed. # # This is always a subdirectory of ${TESTSBASE}/. The remainder of the # path has to match the relative path within the source tree in which # these files are found modulo the tests/ component at the end. # # For example: if this Makefile were in src/bin/cp/tests/, its TESTSDIR # would point at ${TESTSBASE}/bin/cp/. TESTSDIR= ${TESTSBASE}/share/examples/tests # List of subdirectories into which we want to recurse during the build # of the system. We use TESTS_SUBDIRS instead of SUBDIR because we want # the auto-generated Kyuafile to recurse into these directories. TESTS_SUBDIRS= atf plain +TESTS_SUBDIRS+= tap # We leave KYUAFILE unset so that bsd.test.mk auto-generates a Kyuafile # for us based on the contents of the TESTS_SUBDIRS line above. The # generated file will tell the tests run-time engine to recurse into the # directories listed above. #KYUAFILE= auto .include Index: stable/11/share/examples/tests/tests/tap/Kyuafile =================================================================== --- stable/11/share/examples/tests/tests/tap/Kyuafile (nonexistent) +++ stable/11/share/examples/tests/tests/tap/Kyuafile (revision 321645) @@ -0,0 +1,47 @@ +-- $FreeBSD$ +-- +-- Copyright 2013 Google Inc. +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are +-- met: +-- +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * 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. +-- * Neither the name of Google Inc. nor the names of its contributors +-- may be used to endorse or promote products derived from this software +-- without specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +-- "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 COPYRIGHT +-- OWNER OR CONTRIBUTORS 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. + +syntax(2) + +-- All tests provided by the FreeBSD base system should set the test_suite +-- property to FreeBSD. This creates a namespace in the configuration file +-- in which specific run-time properties can be passed to the tests below. +test_suite('FreeBSD') + +-- Register the various test programs into the test suite defined in this +-- directory. +-- +-- Because plain test programs cannot define metadata in their code (they +-- have no mechanism to communicate that to Kyua), we can instead define +-- any metadata properties in here. These have the exact same meaning as +-- their ATF counterparts. These properties are often useful to define +-- prerequisites for the execution of the tests. +tap_test_program{name='cp_test', required_programs='/bin/cp'} +tap_test_program{name='printf_test'} Property changes on: stable/11/share/examples/tests/tests/tap/Kyuafile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/share/examples/tests/tests/tap/Makefile =================================================================== --- stable/11/share/examples/tests/tests/tap/Makefile (nonexistent) +++ stable/11/share/examples/tests/tests/tap/Makefile (revision 321645) @@ -0,0 +1,49 @@ +# $FreeBSD$ + +# The release package to use for the tests contained within the directory +# +# This applies to components which rely on ^/projects/release-pkg support +# (see UPDATING XXXXXXXXX / svn revision r298107). +PACKAGE= tests + +# Directory into which the Kyuafile provided by this directory will be +# installed. +# +# This is always a subdirectory of ${TESTSBASE}/. The remainder of the +# path has to match the relative path within the source tree in which +# these files are found modulo the tests/ component at the end. +# +# For example: if this Makefile were in src/bin/cp/tests/, its TESTSDIR +# would point at ${TESTSBASE}/bin/cp/. +TESTSDIR= ${TESTSBASE}/share/examples/tests/tap + +# List of test programs to build. Note that we can build more than one +# test from a single directory, and this is expected. +TAP_TESTS_C= printf_test +TAP_TESTS_SH= cp_test + +# Tell bsd.test.mk that we are providing a hand-crafted Kyuafile in this +# directory. We do so because the file in this directory exists for +# documentation purposes. +# +# In general, however, you should NOT define KYUAFILE at all to allow +# bsd.test.mk auto-generate one for you based on the PLAIN_TESTS_* +# definitions from above. +KYUAFILE= yes + +# Install file1 and file2 as files via bsd.prog.mk. Please note the intentional +# ${PACKAGE} namespace of files. +# +# The basic semantics of this are the same as FILES in bsd.prog.mk, e.g. the +# installation of the files can be manipulated via ${PACKAGE}FILESDIR, +# ${PACKAGE}FILESMODE, etc. +# +# Please see comment above about ${PACKAGE}. Feel free to omit the ${PACKAGE} +# namespace if release package support isn't needed. +${PACKAGE}FILES+= file1 +CLEANFILES+= file1 + +file1: + @echo "File 1" > ${.TARGET} + +.include Property changes on: stable/11/share/examples/tests/tests/tap/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/share/examples/tests/tests/tap/Makefile.depend =================================================================== --- stable/11/share/examples/tests/tests/tap/Makefile.depend (nonexistent) +++ stable/11/share/examples/tests/tests/tap/Makefile.depend (revision 321645) @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libgcc \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif Property changes on: stable/11/share/examples/tests/tests/tap/Makefile.depend ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/share/examples/tests/tests/tap/cp_test.sh =================================================================== --- stable/11/share/examples/tests/tests/tap/cp_test.sh (nonexistent) +++ stable/11/share/examples/tests/tests/tap/cp_test.sh (revision 321645) @@ -0,0 +1,99 @@ +#!/bin/sh +# +# Copyright (c) 2017 Ngie Cooper +# 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. +# 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``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 FOUNDATION OR CONTRIBUTORS +# 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. +# +# $FreeBSD$ +# + +# +# INTRODUCTION +# +# This TAP test program mimics the structure and contents of its +# ATF-based counterpart. It attempts to represent various test cases +# in different separate functions and just calls them all from main. +# + +test_num=1 +TEST_COUNT=4 + +result() +{ + local result=$1; shift + local result_string + + result_string="$result $test_num" + if [ $# -gt 0 ]; then + result_string="$result_string - $@" + fi + echo "$result_string" + : $(( test_num += 1 )) +} + +# Auxiliary function to compare two files for equality. +verify_copy() { + if cmp -s "${1}" "${2}"; then + result "ok" + else + result "not ok" "${1} and ${2} differ, but they should be equal" + diff -u "${1}" "${2}" + fi +} + +simple_test() { + cp "$(dirname "${0}")/file1" . + if cp file1 file2; then + result "ok" + verify_copy file1 file2 + else + result "not ok" "cp failed" + result "not ok" "# SKIP" + fi +} + +force_test() { + echo 'File 3' >file3 + chmod 400 file3 + if cp -f file1 file3; then + result "ok" + verify_copy file1 file3 + else + result "not ok" "cp -f failed" + result "not ok" "# SKIP" + fi +} + +# If you have read the cp_test.sh counterpart in the atf/ directory, you +# may think that the sequencing of tests below and the exposed behavior +# to the user is very similar. But you'd be wrong. +# +# There are two major differences with this and the ATF version. First off, +# the TAP test doesn't isolate simple_test from force_test, whereas the ATF +# version does. Secondly, the test script accepts arbitrary command line +# inputs. +echo "1..$TEST_COUNT" + +simple_test +force_test +exit 0 Property changes on: stable/11/share/examples/tests/tests/tap/cp_test.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/share/examples/tests/tests/tap/printf_test.c =================================================================== --- stable/11/share/examples/tests/tests/tap/printf_test.c (nonexistent) +++ stable/11/share/examples/tests/tests/tap/printf_test.c (revision 321645) @@ -0,0 +1,185 @@ +/* $FreeBSD$ + * + * Copyright 2013 Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 COPYRIGHT + * OWNER OR CONTRIBUTORS 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. */ + +/* + * INTRODUCTION + * + * This plain test program mimics the structure and contents of its + * ATF-based counterpart. It attempts to represent various test cases + * in different separate functions and just calls them all from main(). + * + * In reality, plain test programs can be much simpler. All they have + * to do is return 0 on success and non-0 otherwise. + */ + +#include +#include +#include +#include +#include + +static int failed; +static int test_num = 1; + +#define TEST_COUNT 7 + +static void +fail(const char *fmt, ...) +{ + char *msg; + va_list ap; + + failed = 1; + + va_start(ap, fmt); + if (vasprintf(&msg, fmt, ap) == -1) + err(1, NULL); + va_end(ap); + printf("not ok %d - %s\n", test_num, msg); + free(msg); + + test_num++; +} + +static void +pass(void) +{ + + printf("ok %d\n", test_num); + test_num++; +} + +static void +skip(int skip_num) +{ + int i; + + for (i = 0; i < skip_num; i++) { + printf("not ok %d # SKIP\n", test_num); + test_num++; + } +} + +static void +snprintf__two_formatters(void) +{ + char buffer[128]; + + if (snprintf(buffer, sizeof(buffer), "%s, %s!", "Hello", + "tests") <= 0) { + fail("snprintf with two formatters failed"); + skip(1); + } else { + pass(); + if (strcmp(buffer, "Hello, tests!") != 0) + fail("Bad formatting: got %s", buffer); + else + pass(); + } +} + +static void +snprintf__overflow(void) +{ + char buffer[10]; + + if (snprintf(buffer, sizeof(buffer), "0123456789abcdef") != 16) { + fail("snprintf did not return the expected " + "number of characters"); + skip(1); + return; + } + pass(); + + if (strcmp(buffer, "012345678") != 0) + fail("Bad formatting: got %s", buffer); + else + pass(); +} + +static void +fprintf__simple_string(void) +{ + FILE *file; + char buffer[128]; + size_t length; + const char *contents = "This is a message\n"; + + file = fopen("test.txt", "w+"); + if (fprintf(file, "%s", contents) <= 0) { + fail("fprintf failed to write to file"); + skip(2); + return; + } + pass(); + rewind(file); + length = fread(buffer, 1, sizeof(buffer) - 1, file); + if (length != strlen(contents)) { + fail("fread failed"); + skip(1); + return; + } + pass(); + buffer[length] = '\0'; + fclose(file); + + if (strcmp(buffer, contents) != 0) + fail("Written and read data differ"); + else + pass(); + + /* Of special note here is that we are NOT deleting the temporary + * files we created in this test. Kyua takes care of this cleanup + * automatically and tests can (and should) rely on this behavior. */ +} + +int +main(void) +{ + /* If you have read the printf_test.c counterpart in the atf/ + * directory, you may think that the sequencing of tests below and + * the exposed behavior to the user is very similar. But you'd be + * wrong. + * + * There are two major differences with this and the ATF version. + * The first is that the code below has no provisions to detect + * failures in one test and continue running the other tests: the + * first failure causes the whole test program to exit. The second + * is that this particular main() has no arguments: without ATF, + * all test programs may expose a different command-line interface, + * and this is an issue for consistency purposes. */ + printf("1..%d\n", TEST_COUNT); + + snprintf__two_formatters(); + snprintf__overflow(); + fprintf__simple_string(); + + return (failed); +} Property changes on: stable/11/share/examples/tests/tests/tap/printf_test.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11 =================================================================== --- stable/11 (revision 321644) +++ stable/11 (revision 321645) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r320443-320444