t_rename (2509081a311c715db1fdcc2305b260c6a4ff5169) t_rename (f8c94cec4b75767c61f393090a7486b23bee87dd)
1#!/bin/sh
2#
1#!/bin/sh
2#
3# $NetBSD: t_rename,v 1.7 2007/07/23 15:05:43 jmmv Exp $
3# $NetBSD: t_rename,v 1.5 2006/11/09 16:20:06 jmmv Exp $
4#
5# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
6# All rights reserved.
7#
8# This code is derived from software contributed to The NetBSD Foundation
9# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
10# 2005 program.
11#
12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions
14# are met:
15# 1. Redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution.
4#
5# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
6# All rights reserved.
7#
8# This code is derived from software contributed to The NetBSD Foundation
9# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
10# 2005 program.
11#
12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions
14# are met:
15# 1. Redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution.
20# 3. All advertising materials mentioning features or use of this software
21# must display the following acknowledgement:
22# This product includes software developed by the NetBSD
23# Foundation, Inc. and its contributors.
24# 4. Neither the name of The NetBSD Foundation nor the names of its
25# contributors may be used to endorse or promote products derived
26# from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

--- 16 unchanged lines hidden (view full) ---

44 test_name "'.' and '..' entries cannot be renamed"
45 mkdir a || die
46 mv a/. c 2>/dev/null && die
47 mv a/.. c 2>/dev/null && die
48 rmdir a || die
49
50 test_name "Cross device renames do not work"
51 mkdir a || die
27#
28# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

--- 16 unchanged lines hidden (view full) ---

51 test_name "'.' and '..' entries cannot be renamed"
52 mkdir a || die
53 mv a/. c 2>/dev/null && die
54 mv a/.. c 2>/dev/null && die
55 rmdir a || die
56
57 test_name "Cross device renames do not work"
58 mkdir a || die
52 ${Src_Dir}/h_tools rename a /var/tmp/a >/dev/null 2>&1 && die
59 ${Src_Dir}/h_tools rename a /var/tmp/a && die
53 rmdir a || die
54
55 test_name "Directories can be renamed"
56 mkdir a || die
57 mv a c || die
58 test -d a && die
59 test -d c || die
60 rmdir c || die

--- 34 unchanged lines hidden (view full) ---

95 test_name "Rename works if the target file exists"
96 touch a || die
97 touch b || die
98 mv a b || die
99 test -f a && die
100 test -f b || die
101 rm b
102
60 rmdir a || die
61
62 test_name "Directories can be renamed"
63 mkdir a || die
64 mv a c || die
65 test -d a && die
66 test -d c || die
67 rmdir c || die

--- 34 unchanged lines hidden (view full) ---

102 test_name "Rename works if the target file exists"
103 touch a || die
104 touch b || die
105 mv a b || die
106 test -f a && die
107 test -f b || die
108 rm b
109
103 test_name "Rename a directory to a override an empty directory works"
104 mkdir a || die
105 touch a/c || die
106 mkdir b || die
107 ${Src_Dir}/h_tools rename a b >/dev/null 2>&1 || die
108 test -e a && die
109 test -d b || die
110 test -f b/c || die
111 rm b/c
112 rmdir b
113
114 test_name "Rename a directory to a override a non-empty directory fails"
115 mkdir a || die
116 touch a/c || die
117 mkdir b || die
118 touch b/d || die
119 err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
120 echo ${err} | grep 'Directory not empty' >/dev/null || die
121 test -d a || die
122 test -f a/c || die
123 test -d b || die
124 test -f b/d || die
125 rm a/c
126 rm b/d
127 rmdir a
128 rmdir b
129
130 test_name "Rename a directory to a override a file fails"
131 mkdir a || die
132 touch b || die
133 err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
134 echo ${err} | grep 'Not a directory' >/dev/null || die
135 test -d a || die
136 test -f b || die
137 rmdir a
138 rm b
139
140 test_name "Rename a file to a override a directory fails"
141 touch a || die
142 mkdir b || die
143 err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
144 echo ${err} | grep 'Is a directory' >/dev/null || die
145 test -f a || die
146 test -d b || die
147 rm a
148 rmdir b
149
150 mkdir dir || die
151 touch dir/a
152 echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a || die
153 test_name "Renaming a file raises NOTE_RENAME on the old file"
154 kqueue_check dir/a NOTE_RENAME || die
155 test_name "Renaming a file raises NOTE_WRITE on the parent directory"
156 kqueue_check dir NOTE_WRITE || die
157 rm dir/b || die

--- 33 unchanged lines hidden ---
110 mkdir dir || die
111 touch dir/a
112 echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a || die
113 test_name "Renaming a file raises NOTE_RENAME on the old file"
114 kqueue_check dir/a NOTE_RENAME || die
115 test_name "Renaming a file raises NOTE_WRITE on the parent directory"
116 kqueue_check dir NOTE_WRITE || die
117 rm dir/b || die

--- 33 unchanged lines hidden ---