5 #-----------------------------------------------------------------------
6 # Copyright (c) 2014 Miklos Szeredi. All Rights Reserved.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it would be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #-----------------------------------------------------------------------
24 # Setup source or dest
33 regu) echo foo > $path;;
34 symb) ln -s foo $path;;
36 tree) mkdir $path; echo foo > $path/bar;;
41 # Cleanup source or dest
47 if test -d $path; then
56 # Check type of source or destination
62 if test -e $path -o -h $path; then
63 if test -d $path -a -e $path/bar; then
66 echo -n `stat -c %F $path | cut -b-4`
74 # This runs renameat2 on all combinations of source and dest
76 _rename_tests_source_dest()
82 for stype in none regu symb dire tree; do
83 for dtype in none regu symb dire tree; do
84 echo -n "$options $stype/$dtype -> "
85 _setup_one $source $stype
86 _setup_one $dest $dtype
87 src/renameat2 $source $dest $flags
101 # This runs _rename_tests_source_dest() for both same-directory and
102 # cross-directory renames
109 #same directory renames
110 _rename_tests_source_dest $testdir/src $testdir/dst "samedir "
112 #cross directory renames
113 mkdir $testdir/x $testdir/y
114 _rename_tests_source_dest $testdir/x/src $testdir/y/dst "crossdir"
115 rmdir $testdir/x $testdir/y
119 # This checks whether the renameat2 syscall is supported
121 _requires_renameat2()
123 if test ! -x src/renameat2; then
124 _notrun "renameat2 binary not found"
126 if ! src/renameat2 -t; then
127 _notrun "kernel doesn't support renameat2 syscall"