forked from n8gray/Backup-Bouncer
/
20-hardlinks.test
53 lines (43 loc) · 1.1 KB
/
20-hardlinks.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
max_priority () {
echo $Important
}
create () {
cd $1
echo "testing 1 2 3" > some-file
ln ./some-file link1
ln ./some-file link2
ln ./link1 link3
# Leopard allows hard links to directories
# mkdir dir1
# mkdir dir2
# hardlink-util dir1 dir2/dir1-link
}
verify () {
cd $1
tmpfile=/tmp/hardlinks-test
set +e
#begin-subtests
stat -f "%i" link1 > $tmpfile
stat -f "%i" link2 >> $tmpfile
stat -f "%i" link3 >> $tmpfile
test "`uniq $tmpfile | wc -l | awk '{print $1}'`" = "1"
#x1=$?
#subtest "on files" $x1
# stat -f "%i" dir1 > $tmpfile
# stat -f "%i" dir2/dir1-link >> $tmpfile
# test "`uniq $tmpfile | wc -l | awk '{print $1}'`" = "1"
# x2=$?
# subtest "on directories" $x2
#rm -f $tmpfile
#alltrue $x1
}
clean () {
true
}
# This is a hard test to do. You want to make sure the same paths are linked
# to the file, but there's no easy way to test that. Instead, just check that
# the link count is the same. Not great, but oh well.
compare () {
test "`stat -f '%l' $1`" = "`stat -f '%l' $2`"
}