1312521Sngie#
2312521Sngie# Copyright 2017 Dell EMC.
3312521Sngie# All rights reserved.
4312521Sngie#
5312521Sngie# Redistribution and use in source and binary forms, with or without
6312521Sngie# modification, are permitted provided that the following conditions are
7312521Sngie# met:
8312521Sngie#
9312521Sngie# * Redistributions of source code must retain the above copyright
10312521Sngie#   notice, this list of conditions and the following disclaimer.
11312521Sngie# * Redistributions in binary form must reproduce the above copyright
12312521Sngie#   notice, this list of conditions and the following disclaimer in the
13312521Sngie#   documentation and/or other materials provided with the distribution.
14312521Sngie#
15312521Sngie# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16312521Sngie# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17312521Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18312521Sngie# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19312521Sngie# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20312521Sngie# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21312521Sngie# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22312521Sngie# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23312521Sngie# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24312521Sngie# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25312521Sngie# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26312521Sngie#
27312521Sngie# $FreeBSD: stable/10/usr.bin/sed/tests/sed2_test.sh 321209 2017-07-19 15:59:51Z ngie $
28312521Sngie#
29312521Sngie
30312521Sngieatf_test_case inplace_hardlink_src
31312521Sngieinplace_hardlink_src_head()
32312521Sngie{
33312521Sngie	atf_set "descr" "Verify -i works with a symlinked source file"
34312521Sngie}
35312521Sngieinplace_hardlink_src_body()
36312521Sngie{
37312521Sngie	echo foo > a
38312521Sngie	atf_check ln a b
39312521Sngie	atf_check sed -i '' -e 's,foo,bar,g' b
40312521Sngie	atf_check -o 'inline:bar\n' -s exit:0 cat b
41312521Sngie}
42312521Sngie
43312521Sngieatf_test_case inplace_symlink_src
44312521Sngieinplace_symlink_src_head()
45312521Sngie{
46312521Sngie	atf_set "descr" "Verify -i works with a symlinked source file"
47312521Sngie}
48312521Sngieinplace_symlink_src_body()
49312521Sngie{
50312521Sngie	echo foo > a
51312521Sngie	atf_check ln -s a b
52312521Sngie	atf_check -e not-empty -s not-exit:0 sed -i '' -e 's,foo,bar,g' b
53312521Sngie}
54312521Sngie
55312521Sngieatf_init_test_cases()
56312521Sngie{
57312521Sngie	atf_add_test_case inplace_hardlink_src
58312521Sngie	atf_add_test_case inplace_symlink_src
59312521Sngie}
60