source: trunk/src/sed/testsuite/compile-tests.sh@ 3613

Last change on this file since 3613 was 3613, checked in by bird, 10 months ago

src/sed: Merged in changes between 4.1.5 and 4.9 from the vendor branch. (svn merge /vendor/sed/4.1.5 /vendor/sed/current .)

File size: 4.0 KB
Line 
1#!/bin/sh
2# Test compilation less-common cases
3
4# Copyright (C) 2016-2022 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. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
19print_ver_ sed
20
21#
22# Special file names, with gnu extensions and without (if the host
23# supports /dev/std{out,err} )
24#
25echo a > a || framework_failure_
26
27# With gnu extension enabled, /dev/stderr is emulated internally
28# regardless of the operating system.
29sed 'w/dev/stderr' a >out 2>err|| fail=1
30compare_ a out || fail=1
31compare_ a err || fail=1
32
33# In posix mode /dev/std* are not emulated internally. Skip if they
34# don't exist. 'env' is used to avoid built-in 'test' which
35# simulates /dev/stderr, e.g. bash on AIX.
36if env test -w /dev/stderr ; then
37 sed --posix 'w/dev/stderr' a >out-psx 2>err-psx || fail=1
38 compare_ a out-psx || fail=1
39 compare_ a err-psx || fail=1
40fi
41
42
43#
44# labels followed by various characters
45# (read_label)
46echo a > lbl-in-exp || framework_failure_
47cat << \EOF > lbl-prog || framework_failure_
48bZ
49:Z
50bY;
51:Y
52{bX}
53:X ;
54b W
55: W
56EOF
57sed -f lbl-prog lbl-in-exp > lbl-out || fail=1
58compare_ lbl-in-exp lbl-out
59
60
61
62#
63# character classes (compile.c:snarf_char_class)
64#
65
66# open brackets followed by EOF
67cat <<\EOF >exp-err-op-bracket || framework_failure_
68sed: -e expression #1, char 2: unterminated address regex
69EOF
70returns_ 1 sed '/[' </dev/null 2>err-op-bracket1 || fail=1
71compare_ exp-err-op-bracket err-op-bracket1 || fail=1
72
73
74# open brackets followed by \n
75printf "/[\n" > op-bracket-prog || framework_failure_
76cat <<\EOF >exp-err-op-bracket || framework_failure_
77sed: file op-bracket-prog line 1: unterminated address regex
78EOF
79returns_ 1 sed -f op-bracket-prog </dev/null 2>err-op-bracket2 || fail=1
80compare_ exp-err-op-bracket err-op-bracket2 || fail=1
81
82
83# unterminated character class '[.'
84# (snarf_char_class terminates on char 7, then returns)
85cat <<\EOF >exp-chr-class || framework_failure_
86sed: -e expression #1, char 7: unterminated `s' command
87EOF
88returns_ 1 sed 's/[[.//' </dev/null 2>err-chr-class || fail=1
89compare_ exp-chr-class err-chr-class || fail=1
90
91
92# closing bracket immediately after char-class opening
93# sequence (e.g. '[:]' instead of '[:alpha:]' ).
94cat<< \EOF >exp-chr-class2 || framework_failure_
95sed: -e expression #1, char 9: unterminated `s' command
96EOF
97returns_ 1 sed 's/[[:]]//' </dev/null 2>err-chr-class2 || fail=1
98compare_ exp-chr-class2 err-chr-class2 || fail=1
99
100
101# EOF after backslash in a regex (compile.c:match_slash())
102cat<< \EOF >exp-backslash-eof || framework_failure_
103sed: -e expression #1, char 2: unterminated address regex
104EOF
105returns_ 1 sed '/\' </dev/null 2>err-backslash-eof || fail=1
106compare_ exp-backslash-eof err-backslash-eof || fail=1
107
108
109# Valid version requirement
110sed 'v4' < /dev/null || fail=1
111
112# Closing braces followed by another closing braces, and '#'
113echo X > in-exp || framework_failure_
114sed -n '{{p}}' in-exp > out-braces-1 || fail=1
115compare_ in-exp out-braces-1 || fail=1
116
117sed -n '{p}#foo' in-exp > out-braces-2 || fail=1
118compare_ in-exp out-braces-2 || fail=1
119
120# 'l' followed by closing braces, and '#'
121printf 'X$\n' > exp-l || framework_failure_
122sed -n '{l}' in-exp > out-l-braces || fail=1
123compare_ exp-l out-l-braces || fail=1
124sed -n 'l#foo' in-exp > out-l-hash || fail=1
125compare_ exp-l out-l-hash || fail=1
126
127
128#
129# unterminated a/c/i as last command
130# (pending_text)
131sed -e 'a\' in-exp > out-unterm-a1 || fail=1
132compare_ in-exp out-unterm-a1 || fail=1
133
134
135Exit $fail
Note: See TracBrowser for help on using the repository browser.