Module Name: src Committed By: apb Date: Tue Apr 7 13:52:08 UTC 2009
Modified Files: src/distrib/sets/lists/tests: mi src/tests/util: Makefile Added Files: src/tests/util/mtree: Atffile Makefile d_create.out t_mtree.sh Log Message: Add tests for mtree. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.5 -r1.6 src/tests/util/Makefile cvs rdiff -u -r0 -r1.1 src/tests/util/mtree/Atffile \ src/tests/util/mtree/Makefile src/tests/util/mtree/d_create.out \ src/tests/util/mtree/t_mtree.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.35 src/distrib/sets/lists/tests/mi:1.36 --- src/distrib/sets/lists/tests/mi:1.35 Sat Feb 28 13:32:51 2009 +++ src/distrib/sets/lists/tests/mi Tue Apr 7 13:52:08 2009 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.35 2009/02/28 13:32:51 njoly Exp $ +# $NetBSD: mi,v 1.36 2009/04/07 13:52:08 apb Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -984,6 +984,10 @@ ./usr/tests/util/make/d_varcmd.mk tests-util-tests ./usr/tests/util/make/d_varcmd.out tests-util-tests ./usr/tests/util/make/t_make tests-util-tests +./usr/tests/util/mtree tests-util-tests +./usr/tests/util/mtree/Atffile tests-util-tests +./usr/tests/util/mtree/d_create.out tests-util-tests +./usr/tests/util/mtree/t_mtree tests-util-tests ./usr/tests/util/ps tests-util-tests ./usr/tests/util/ps/Atffile tests-util-tests ./usr/tests/util/ps/keywords tests-util-tests Index: src/tests/util/Makefile diff -u src/tests/util/Makefile:1.5 src/tests/util/Makefile:1.6 --- src/tests/util/Makefile:1.5 Fri Feb 13 05:19:51 2009 +++ src/tests/util/Makefile Tue Apr 7 13:52:07 2009 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.5 2009/02/13 05:19:51 jmmv Exp $ +# $NetBSD: Makefile,v 1.6 2009/04/07 13:52:07 apb Exp $ .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/util -SUBDIR= awk bzip2 config cut df grep id m4 make ps sdiff sh +SUBDIR= awk bzip2 config cut df grep id m4 make mtree ps sdiff sh TESTS_SH= t_basename TESTS_SH+= t_cp Added files: Index: src/tests/util/mtree/Atffile diff -u /dev/null src/tests/util/mtree/Atffile:1.1 --- /dev/null Tue Apr 7 13:52:08 2009 +++ src/tests/util/mtree/Atffile Tue Apr 7 13:52:08 2009 @@ -0,0 +1,6 @@ +Content-Type: application/X-atf-atffile; version="1" +X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/04/07 13:52:08 apb Exp $" + +prop: test-suite = "NetBSD" + +tp: t_mtree Index: src/tests/util/mtree/Makefile diff -u /dev/null src/tests/util/mtree/Makefile:1.1 --- /dev/null Tue Apr 7 13:52:08 2009 +++ src/tests/util/mtree/Makefile Tue Apr 7 13:52:08 2009 @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2009/04/07 13:52:08 apb Exp $ + +NOMAN= # defined + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/util/mtree + +TESTS_SH= t_mtree + +FILESDIR= ${TESTSDIR} +FILES= d_create.out + +.include <bsd.test.mk> Index: src/tests/util/mtree/d_create.out diff -u /dev/null src/tests/util/mtree/d_create.out:1.1 --- /dev/null Tue Apr 7 13:52:08 2009 +++ src/tests/util/mtree/d_create.out Tue Apr 7 13:52:08 2009 @@ -0,0 +1,55 @@ +# user: x +# machine: x +# tree: x +# date: x + +# . +/set type=file nlink=1 +. type=dir nlink=4 + a.symlink.1 type=link + top.dangling \ + type=link + top.file.1 size=18 \ + sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195 + top.symlink.b \ + type=link + +# ./a +a type=dir nlink=4 + a.file.1 size=18 \ + sha256=bdbea62f7ccdf862f22254ea871d523845250010d5f233896e800142a859eef2 + a.file.2 size=18 \ + sha256=77876d113fe1b45a41f8d1d3e178aaad7f91fcd93d3df782690625b74ad90fe6 + a.hardlink.b2 \ + nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + +# ./a/1 +1 type=dir nlink=2 + a1.file.1 size=21 \ + sha256=a062cd272facdd38c4fdeff2a18947b28c99a28a8fe51f88468978740382e592 +# ./a/1 +.. + + +# ./a/2 +2 type=dir nlink=2 +# ./a/2 +.. + +# ./a +.. + + +# ./b +b type=dir nlink=2 + b.file.1 nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 + b.file.2 nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + b.hardlink.1 \ + nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 +# ./b +.. + Index: src/tests/util/mtree/t_mtree.sh diff -u /dev/null src/tests/util/mtree/t_mtree.sh:1.1 --- /dev/null Tue Apr 7 13:52:08 2009 +++ src/tests/util/mtree/t_mtree.sh Tue Apr 7 13:52:08 2009 @@ -0,0 +1,106 @@ +# $NetBSD: t_mtree.sh,v 1.1 2009/04/07 13:52:08 apb Exp $ +# +# Copyright (c) 2009 The NetBSD Foundation, 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: +# 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. +# + +# Postprocess mtreee output, canonicalising portions that +# are expected to differ from one run to another. +h_postprocess() +{ + sed -e ' + /^# user: /s/:.*/: x/ + /^# machine: /s/:.*/: x/ + /^# tree: /s/:.*/: x/ + /^# date: /s/:.*/: x/ + ' +} + +h_check() +{ + diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ" +} + +atf_test_case create +create_head() +{ + atf_set "descr" "Create a specfile describing a directory tree" +} +create_setup() +{ + # create some directories + mkdir -p create/a/1 create/a/2 create/b + # create some files + for file in create/top.file.1 \ + create/a/a.file.1 \ + create/a/a.file.2 \ + create/a/1/a1.file.1 \ + create/b/b.file.1 \ + create/b/b.file.2 + do + echo "$file" >$file + done + # hard link to file in same dir + ln create/b/b.file.1 create/b/b.hardlink.1 + # hard link to file in another dir + ln create/b/b.file.2 create/a/a.hardlink.b2 + # symlink to file + ln -s a.file.1 create/a.symlink.1 + # symlink to dir + ln -s b create/top.symlink.b + # dangling symlink + ln -s nonexistent create/top.dangling +} +create_body() +{ + create_setup + + # run mtree and check output + ( cd create && mtree -c -k type,nlink,size,sha256 ) >output.raw \ + || atf_fail "mtree exit status $?" + h_postprocess <output.raw >output + h_check "$(atf_get_srcdir)/d_create.out" output +} + +atf_test_case check +check_head() +{ + atf_set "descr" "Check a directory tree against a specfile" +} +check_body() +{ + # we use the same directory tree and specfile as in the "create" test + create_setup + + # run mtree and check output + ( cd create && mtree ) <"$(atf_get_srcdir)/d_create.out" >output \ + || atf_fail "mtree exit status $?" + h_check /dev/null output +} + +atf_init_test_cases() +{ + atf_add_test_case create + atf_add_test_case check +}