Debian Codegraph @

tests/ts/hardlink/options

raw ◀ ▶
1 Debian patch touch this file
1 #!/bin/bash
2 #
3 # Copyright (C) 2018 Ruediger Meier <[email protected]>
4 #
5 # This file is part of util-linux.
6 #
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will 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.
16 #
17
18 TS_TOPDIR="${0%/*}/../.."
19 TS_DESC="options"
20
21 . "$TS_TOPDIR"/functions.sh
22
23 ts_init "$*"
24
25 ts_check_test_command "$TS_CMD_HARDLINK"
26 ts_check_prog xz
27 ts_check_prog tar
28 ts_check_prog wc
29
•30 # on some archs sha256 cannot be used
31 TS_KNOWN_FAIL="yes"
32
33 SRCDIR="$TS_OUTDIR/testdir1"
34
35 create_srcdir()
36 {
37 rm -rf "$SRCDIR"
38 tar -C "$TS_OUTDIR" -xJf "$TS_SELF/testdir1.tar.xz"
39 }
40
41 show_srcdir()
42 {
43 find "$SRCDIR" -type f -printf "%P\t%n\t%s\t%Ts\t%m\n" | sort
44 }
45
46 summary_clean()
47 {
48 sed -i \
49 -e 's/^Duration:.*/Duration: [Redacted]/' \
50 -e 's/^Method:.*/Method: [Redacted]/' \
51 -e 's/^Compared:.*files/Compared: [Redacted] files/' \
52 $TS_OUTPUT
53 }
54
55 create_srcdir
56
57 ts_init_subtest "orig" # just list original dir
58 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
59 ts_finalize_subtest
60
61 ts_init_subtest "dryrun"
62 $TS_CMD_HARDLINK --quiet --dry-run "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
63 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
64 ts_finalize_subtest
65
66 ts_init_subtest "nargs"
67 $TS_CMD_HARDLINK --quiet "$SRCDIR"/dir-1/sdir-1 "$SRCDIR"/file-?-{1,2} >> $TS_OUTPUT 2>> $TS_ERRLOG
68 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
69 ts_finalize_subtest
70
71 # cases without and with -x support
72 tmp=$($TS_CMD_HARDLINK --quiet --exclude pattern "$SRCDIR"/dir-1/sdir-2 2>&1)
73 if test $? -ne 0; then
74 ts_init_subtest "noregex"
75 printf "%s\n" "$tmp" >> $TS_OUTPUT 2>> $TS_ERRLOG
76 ts_finalize_subtest
77 else
78 ts_init_subtest "regex-escapes"
79 $TS_CMD_HARDLINK --quiet --exclude '.*z-"ยง\$%&\(\)=\?\*\+$' "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
80 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
81 ts_finalize_subtest
82 fi
83
84 ts_init_subtest "content"
85 $TS_CMD_HARDLINK --quiet --content "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
86 # When using -c we need to cheat with sed because it's not deterministic which
87 # file (i.e. which timestamp and perms) wins. TODO at least the choice of the
88 # permissions should be sensitive by default and/or controllable by the user.
89 show_srcdir | sed 's/\(1540236\).*/\1xxx\tperm/' >> $TS_OUTPUT 2>> $TS_ERRLOG
90 ts_finalize_subtest
91
92 ts_init_subtest "maximum-size-8191"
93 create_srcdir
94 echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT
95 $TS_CMD_HARDLINK --maximum-size 8191 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
96 summary_clean
97 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
98 ts_finalize_subtest
99
100 ts_init_subtest "maximum-size-8192"
101 create_srcdir
102 echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT
103 $TS_CMD_HARDLINK --maximum-size 8192 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
104 summary_clean
105 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
106 ts_finalize_subtest
107
108
109 rm -rf "$SRCDIR"
110 ts_finalize