diff options
| author | apb <apb@NetBSD.org> | 2009-04-07 13:52:07 +0000 |
|---|---|---|
| committer | apb <apb@NetBSD.org> | 2009-04-07 13:52:07 +0000 |
| commit | fc28b4ff36845cc0772d0db1e9df8a96010ada73 (patch) | |
| tree | 39cf049a3812cf077b77ebf54e6ff34e77e06358 | |
| parent | 292ab8c29d33cb958e379e945eee31e140954195 (diff) | |
Add tests for mtree.
| -rw-r--r-- | distrib/sets/lists/tests/mi | 6 | ||||
| -rw-r--r-- | tests/util/Makefile | 4 | ||||
| -rw-r--r-- | tests/util/mtree/Atffile | 6 | ||||
| -rw-r--r-- | tests/util/mtree/Makefile | 14 | ||||
| -rw-r--r-- | tests/util/mtree/d_create.out | 55 | ||||
| -rw-r--r-- | tests/util/mtree/t_mtree.sh | 106 |
6 files changed, 188 insertions, 3 deletions
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi index 5163ac200b0..ef3d96fe86c 100644 --- a/distrib/sets/lists/tests/mi +++ b/distrib/sets/lists/tests/mi @@ -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 diff --git a/tests/util/Makefile b/tests/util/Makefile index 7034bb2dea0..e20c52e9cbc 100644 --- a/tests/util/Makefile +++ b/tests/util/Makefile @@ -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 diff --git a/tests/util/mtree/Atffile b/tests/util/mtree/Atffile new file mode 100644 index 00000000000..09077092df8 --- /dev/null +++ b/tests/util/mtree/Atffile @@ -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 diff --git a/tests/util/mtree/Makefile b/tests/util/mtree/Makefile new file mode 100644 index 00000000000..8d57ca6de3c --- /dev/null +++ b/tests/util/mtree/Makefile @@ -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> diff --git a/tests/util/mtree/d_create.out b/tests/util/mtree/d_create.out new file mode 100644 index 00000000000..6c58470c036 --- /dev/null +++ b/tests/util/mtree/d_create.out @@ -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 +.. + diff --git a/tests/util/mtree/t_mtree.sh b/tests/util/mtree/t_mtree.sh new file mode 100644 index 00000000000..7a1de9764c0 --- /dev/null +++ b/tests/util/mtree/t_mtree.sh @@ -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 +} |
