Skip to content

Commit 2625209

Browse files
sylvestrepixelb
authored andcommitted
tests: ln: add test for non-UTF-8 source names in target-dir mode
* tests/ln/non-utf8-src.sh: New test ensuring ln handles source filenames containing non-UTF-8 bytes when linking into a target directory, for both hard links and symbolic links with -t. * tests/local.mk: Register the new test. uutils/coreutils#11403 #240
1 parent fac4546 commit 2625209

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

tests/ln/non-utf8-src.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
# Ensure ln handles non-UTF-8 source names in target-dir mode.
3+
4+
# Copyright (C) 2026 Free Software Foundation, Inc.
5+
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20+
print_ver_ ln
21+
22+
echo a > "$(bad_unicode)" \
23+
|| skip_ 'bad unicode not supported in shell or file system'
24+
25+
name="$(bad_unicode)"
26+
27+
# Check source file and create target directory.
28+
test -f "$name" || framework_failure_
29+
mkdir dst || framework_failure_
30+
31+
# Hard link in target directory.
32+
ln "$name" dst || fail=1
33+
test -f "dst/$name" || fail=1
34+
rm -f "dst/$name" || framework_failure_
35+
36+
# Symbolic link with -t.
37+
ln -s -t dst "$name" || fail=1
38+
test -L "dst/$name" || fail=1
39+
40+
Exit $fail

tests/local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ all_tests = \
676676
tests/ln/hard-backup.sh \
677677
tests/ln/hard-to-sym.sh \
678678
tests/ln/misc.sh \
679+
tests/ln/non-utf8-src.sh \
679680
tests/ln/relative.sh \
680681
tests/ln/sf-1.sh \
681682
tests/ln/slash-decorated-nonexistent-dest.sh \

0 commit comments

Comments
 (0)