| 1 |
# t805 --- stdio/fd desync regression |
| 2 |
# |
| 3 |
# Copyright (C) 2014-2022 Thien-Thi Nguyen |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU General Public License as |
| 7 |
# published by the Free Software Foundation, either version 3 of |
| 8 |
# the License, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty |
| 12 |
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
# See the GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
. $srcdir/common |
| 19 |
split_std_out_err no |
| 20 |
unset TMPDIR |
| 21 |
|
| 22 |
## |
| 23 |
# Check that using the RM_STDIO code path doesn't truncate |
| 24 |
# the work file on Cygwin due to lost stdio/fd synchronization. |
| 25 |
# This test derives from a 5.8 regression (maybe). |
| 26 |
# See: <http://lists.gnu.org/archive/html/bug-rcs/2014-06/msg00000.html>. |
| 27 |
## |
| 28 |
|
| 29 |
## |
| 30 |
# NB: We jam env ‘RCS_MEM_LIMIT=0’ to force stdio operation. |
| 31 |
## |
| 32 |
RCS_MEM_LIMIT=0 |
| 33 |
export RCS_MEM_LIMIT |
| 34 |
|
| 35 |
piped_out_size () |
| 36 |
{ |
| 37 |
co -p $w | wc -c |
| 38 |
} |
| 39 |
|
| 40 |
ca_1_ash_16='65535 65536 65537' |
| 41 |
ca_1_ash_18='262143 262144 262145' |
| 42 |
other_interesting_values='262140 262150' |
| 43 |
|
| 44 |
$hey set -x |
| 45 |
|
| 46 |
for n in $ca_1_ash_16 \ |
| 47 |
$ca_1_ash_18 \ |
| 48 |
$other_interesting_values |
| 49 |
do |
| 50 |
rm -f $v |
| 51 |
# Check in initial revision (1.1), with small contents. |
| 52 |
echo foo > $w |
| 53 |
ci -l $w < /dev/null |
| 54 |
test 4 = `piped_out_size` \ |
| 55 |
|| problem "incorrect initial size: $size (expected 4)" |
| 56 |
# Check in second revision (1.2), size $n bytes. |
| 57 |
# Note, adding "-f" to the ci command prevents the bug. |
| 58 |
printf "%${n}s" '' > $w |
| 59 |
ci -m"blafasel" -l $w |
| 60 |
cp -f $w $w.$n |
| 61 |
cp -f $v $v.$n |
| 62 |
# When n=262143, the following gives 262143 (correct); |
| 63 |
# when n=262144, the following gives 65535 (wrong). |
| 64 |
test $n = `piped_out_size` \ |
| 65 |
|| problem "unexpected size: $size (expected $n)" |
| 66 |
# The following succeeds with n=262143, but fails with n=262144: |
| 67 |
# co: RCS/foo,v:32805: edit script refers to line past end of file |
| 68 |
# co aborted |
| 69 |
must co -p1.1 $w > /dev/null |
| 70 |
done |
| 71 |
|
| 72 |
exit 0 |
| 73 |
|
| 74 |
# t805 ends here |