Debian Codegraph @

tests/ts/rename/symlink

raw symbols SCIP
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2014 Sami Kerola <[email protected]>
5 #
6 # This file is part of util-linux.
7 #
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 TS_TOPDIR="${0%/*}/../.."
19 TS_DESC="symlink check"
20
21 . "$TS_TOPDIR"/functions.sh
22 ts_init "$*"
23
24 ts_check_test_command "$TS_CMD_RENAME"
25 ts_cd "$TS_OUTDIR"
26
27 for i in rename_slink.{1..3}; do
28 ln -s old $i
29 done
30
31 $TS_CMD_RENAME --symlink --verbose old new rename_slink.? >> $TS_OUTPUT 2>> $TS_ERRLOG
32
33 for i in rename_slink.{1..3}; do
34 where="$(readlink $i)"
35 if [ "$where" != "new" ]; then
36 echo "error: $i points to $where" >> $TS_OUTPUT
37 fi
38 rm -f $i
39 done
40
41 touch target
42 ln -s target rename_slink.1
43 $TS_CMD_RENAME --verbose slink symlink rename_slink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG
44 readlink rename_symlink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG
45 rm -f rename_slink.1 rename_symlink.1
46
47 rm target
48 ln -s target rename_slink.2
49 $TS_CMD_RENAME -v slink symlink rename_slink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG
50 readlink rename_symlink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG
51 rm -f rename_slink.2 rename_symlink.2
52
53 $TS_CMD_RENAME --verbose slink symlink rename_slink.3 >> $TS_OUTPUT 2>> $TS_ERRLOG
54 # The error may differ on Mac OS X due to faccessat()/lstat(); normalize it.
55 sed -i -e 's/\(rename_slink.3\): not accessible/\1/' -e 's/stat of \(rename_slink.3\) failed/\1/' $TS_ERRLOG
56
57 ts_finalize