Debian Codegraph @

tests/ts/hardlink/options

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
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 SRCDIR="$TS_OUTDIR/testdir1"
31
32 create_srcdir()
33 {
34 rm -rf "$SRCDIR"
35 tar -C "$TS_OUTDIR" -xJf "$TS_SELF/testdir1.tar.xz"
36 }
37
38 show_srcdir()
39 {
40 find "$SRCDIR" -type f -printf "%P\t%n\t%s\t%Ts\t%m\n" | sort
41 }
42
43 summary_clean()
44 {
45 sed -i \
46 -e 's/^Duration:.*/Duration: [Redacted]/' \
47 -e 's/^Method:.*/Method: [Redacted]/' \
48 -e 's/^Compared:.*files/Compared: [Redacted] files/' \
49 $TS_OUTPUT
50 }
51
52 create_srcdir
53
54 ts_init_subtest "orig" # just list original dir
55 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
56 ts_finalize_subtest
57
58 ts_init_subtest "dryrun"
59 $TS_CMD_HARDLINK --quiet --dry-run "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
60 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
61 ts_finalize_subtest
62
63 ts_init_subtest "nargs"
64 $TS_CMD_HARDLINK --quiet "$SRCDIR"/dir-1/sdir-1 "$SRCDIR"/file-?-{1,2} >> $TS_OUTPUT 2>> $TS_ERRLOG
65 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
66 ts_finalize_subtest
67
68 # cases without and with -x support
69 tmp=$($TS_CMD_HARDLINK --quiet --exclude pattern "$SRCDIR"/dir-1/sdir-2 2>&1)
70 if test $? -ne 0; then
71 ts_init_subtest "noregex"
72 printf "%s\n" "$tmp" >> $TS_OUTPUT 2>> $TS_ERRLOG
73 ts_finalize_subtest
74 else
75 ts_init_subtest "regex-escapes"
76 $TS_CMD_HARDLINK --quiet --exclude '.*z-"ยง\$%&\(\)=\?\*\+$' "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
77 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
78 ts_finalize_subtest
79 fi
80
81 ts_init_subtest "content"
82 $TS_CMD_HARDLINK --quiet --content "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
83 # When using -c we need to cheat with sed because it's not deterministic which
84 # file (i.e. which timestamp and perms) wins. TODO at least the choice of the
85 # permissions should be sensitive by default and/or controllable by the user.
86 show_srcdir | sed 's/\(1540236\).*/\1xxx\tperm/' >> $TS_OUTPUT 2>> $TS_ERRLOG
87 ts_finalize_subtest
88
89 ts_init_subtest "maximum-size-8191"
90 create_srcdir
91 echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT
92 $TS_CMD_HARDLINK --maximum-size 8191 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
93 summary_clean
94 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
95 ts_finalize_subtest
96
97 ts_init_subtest "maximum-size-8192"
98 create_srcdir
99 echo "Number of test files: $(find "$SRCDIR" -type f | wc -l)" >> $TS_OUTPUT
100 $TS_CMD_HARDLINK --maximum-size 8192 "$SRCDIR" >> $TS_OUTPUT 2>> $TS_ERRLOG
101 summary_clean
102 show_srcdir >> $TS_OUTPUT 2>> $TS_ERRLOG
103 ts_finalize_subtest
104
105
106 rm -rf "$SRCDIR"
107 ts_finalize