aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2007-08-10 10:08:43 +0000
committerXin LI <delphij@FreeBSD.org>2007-08-10 10:08:43 +0000
commitd73f7c1723048be5f8e7eca722cf7a285872d37a (patch)
tree7db2d3346b1b69da81d0e08f7b216f7d439ca2a1 /tools
parentdb3f838d97ccdf866f0593dfcc3fc605872e6e1d (diff)
downloadsrc-d73f7c1723048be5f8e7eca722cf7a285872d37a.tar.gz
src-d73f7c1723048be5f8e7eca722cf7a285872d37a.zip
New regression test updates for rename, etc.
Obtained from: NetBSD Approved by: re (tmpfs blanket)
Notes
Notes: svn path=/head/; revision=171801
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/tmpfs/h_tools.c9
-rw-r--r--tools/regression/tmpfs/t_mount4
-rw-r--r--tools/regression/tmpfs/t_rename51
3 files changed, 58 insertions, 6 deletions
diff --git a/tools/regression/tmpfs/h_tools.c b/tools/regression/tmpfs/h_tools.c
index 9d8940165d1d..1339060bc9a1 100644
--- a/tools/regression/tmpfs/h_tools.c
+++ b/tools/regression/tmpfs/h_tools.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_tools.c,v 1.7 2006/11/09 16:20:06 jmmv Exp $ */
+/* $NetBSD: h_tools.c,v 1.8 2007/07/23 15:05:43 jmmv Exp $ */
/*-
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -192,7 +192,12 @@ rename_main(int argc, char **argv)
if (argc < 3)
return EXIT_FAILURE;
- return rename(argv[1], argv[2]);
+ if (rename(argv[1], argv[2]) == -1) {
+ perror("rename");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
}
/* --------------------------------------------------------------------- */
diff --git a/tools/regression/tmpfs/t_mount b/tools/regression/tmpfs/t_mount
index cad7e70d1ea6..c5deaf78d8ff 100644
--- a/tools/regression/tmpfs/t_mount
+++ b/tools/regression/tmpfs/t_mount
@@ -1,8 +1,8 @@
#!/bin/sh
#
-# $NetBSD: t_mount,v 1.7 2006/11/09 16:20:06 jmmv Exp $
+# $NetBSD: t_mount,v 1.8 2007/07/24 11:29:16 jmmv Exp $
#
-# Copyright (c) 2005, 2006, 2006 The NetBSD Foundation, Inc.
+# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
diff --git a/tools/regression/tmpfs/t_rename b/tools/regression/tmpfs/t_rename
index 867a393add32..0dbc0b00fc45 100644
--- a/tools/regression/tmpfs/t_rename
+++ b/tools/regression/tmpfs/t_rename
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: t_rename,v 1.5 2006/11/09 16:20:06 jmmv Exp $
+# $NetBSD: t_rename,v 1.7 2007/07/23 15:05:43 jmmv Exp $
#
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -56,7 +56,7 @@ test_run() {
test_name "Cross device renames do not work"
mkdir a || die
- ${Src_Dir}/h_tools rename a /var/tmp/a && die
+ ${Src_Dir}/h_tools rename a /var/tmp/a >/dev/null 2>&1 && die
rmdir a || die
test_name "Directories can be renamed"
@@ -107,6 +107,53 @@ test_run() {
test -f b || die
rm b
+ test_name "Rename a directory to a override an empty directory works"
+ mkdir a || die
+ touch a/c || die
+ mkdir b || die
+ ${Src_Dir}/h_tools rename a b >/dev/null 2>&1 || die
+ test -e a && die
+ test -d b || die
+ test -f b/c || die
+ rm b/c
+ rmdir b
+
+ test_name "Rename a directory to a override a non-empty directory fails"
+ mkdir a || die
+ touch a/c || die
+ mkdir b || die
+ touch b/d || die
+ err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
+ echo ${err} | grep 'Directory not empty' >/dev/null || die
+ test -d a || die
+ test -f a/c || die
+ test -d b || die
+ test -f b/d || die
+ rm a/c
+ rm b/d
+ rmdir a
+ rmdir b
+
+ test_name "Rename a directory to a override a file fails"
+ mkdir a || die
+ touch b || die
+ err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
+ echo ${err} | grep 'Not a directory' >/dev/null || die
+ test -d a || die
+ test -f b || die
+ rmdir a
+ rm b
+
+ test_name "Rename a file to a override a directory fails"
+ touch a || die
+ mkdir b || die
+ err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
+ echo ${err} | grep 'Is a directory' >/dev/null || die
+ test -f a || die
+ test -d b || die
+ rm a
+ rmdir b
+
mkdir dir || die
touch dir/a
echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a || die