| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | # Test runner for old 'eval' test
|
|---|
| 4 |
|
|---|
| 5 | # Copyright (C) 2017-2022 Free Software Foundation, Inc.
|
|---|
| 6 |
|
|---|
| 7 | # This program 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 3 of the License, or
|
|---|
| 10 | # (at your option) any later version.
|
|---|
| 11 |
|
|---|
| 12 | # This program 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 | # You should have received a copy of the GNU General Public License
|
|---|
| 18 | # along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|---|
| 19 | . "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
|
|---|
| 20 | print_ver_ sed
|
|---|
| 21 |
|
|---|
| 22 | cat << \EOF > eval-in || framework_failure_
|
|---|
| 23 | 17380: 2 2 5 11 79
|
|---|
| 24 | abcd
|
|---|
| 25 | cpu
|
|---|
| 26 | abcd
|
|---|
| 27 | cpu
|
|---|
| 28 | EOF
|
|---|
| 29 |
|
|---|
| 30 | # create a copy of the input file.
|
|---|
| 31 | # Keep the name 'eval.in2' - it is used in the 'eval' commands in the
|
|---|
| 32 | # sed program below.
|
|---|
| 33 | cp eval-in eval.in2 || framework_failure_
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | # The sed program - containing multiple 'e' (eval) commands.
|
|---|
| 37 | # NOTE: the program executes 'sed' using 'e' commands - and
|
|---|
| 38 | # assumes GNU sed is in the $PATH (which is the case here).
|
|---|
| 39 | cat << \EOF > eval.sed || framework_failure_
|
|---|
| 40 | 1d
|
|---|
| 41 |
|
|---|
| 42 | #Try eval command
|
|---|
| 43 | /cpu/!b2
|
|---|
| 44 | esed 1q eval.in2
|
|---|
| 45 |
|
|---|
| 46 | :2
|
|---|
| 47 | p
|
|---|
| 48 | i---
|
|---|
| 49 | h
|
|---|
| 50 |
|
|---|
| 51 | #Try eval option
|
|---|
| 52 | s,.* *cpu *,sed 1q eval.in2; echo "&",e
|
|---|
| 53 |
|
|---|
| 54 | :3
|
|---|
| 55 | p
|
|---|
| 56 | g
|
|---|
| 57 | i---
|
|---|
| 58 |
|
|---|
| 59 | h
|
|---|
| 60 | #Try eval option with print
|
|---|
| 61 | s,.* *cpu.*,sed 1q eval.in2,ep
|
|---|
| 62 | g
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | :4
|
|---|
| 66 | p
|
|---|
| 67 | i---
|
|---|
| 68 |
|
|---|
| 69 | $!d
|
|---|
| 70 |
|
|---|
| 71 | #Do some more tests
|
|---|
| 72 | s/.*/Doing some more tests -----------------------/p
|
|---|
| 73 | s,.*,sed 1q eval.in2,ep
|
|---|
| 74 | i---
|
|---|
| 75 | s,.*,sed 1q eval.in2,pe
|
|---|
| 76 | i---
|
|---|
| 77 | s,.*,sed 1q eval.in2,
|
|---|
| 78 | h
|
|---|
| 79 | e
|
|---|
| 80 | p
|
|---|
| 81 | g
|
|---|
| 82 | i---
|
|---|
| 83 | s/^/echo /ep
|
|---|
| 84 | i---
|
|---|
| 85 | s/^fubar$/echo wozthis/e
|
|---|
| 86 | EOF
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | # The expected output file
|
|---|
| 90 | cat << \EOF > eval-exp || framework_failure_
|
|---|
| 91 | abcd
|
|---|
| 92 | ---
|
|---|
| 93 | abcd
|
|---|
| 94 | ---
|
|---|
| 95 | abcd
|
|---|
| 96 | ---
|
|---|
| 97 | 17380: 2 2 5 11 79
|
|---|
| 98 | cpu
|
|---|
| 99 | ---
|
|---|
| 100 | 17380: 2 2 5 11 79
|
|---|
| 101 | cpu
|
|---|
| 102 | ---
|
|---|
| 103 | 17380: 2 2 5 11 79
|
|---|
| 104 | cpu
|
|---|
| 105 | ---
|
|---|
| 106 | abcd
|
|---|
| 107 | ---
|
|---|
| 108 | abcd
|
|---|
| 109 | ---
|
|---|
| 110 | abcd
|
|---|
| 111 | ---
|
|---|
| 112 | 17380: 2 2 5 11 79
|
|---|
| 113 | cpu
|
|---|
| 114 | ---
|
|---|
| 115 | 17380: 2 2 5 11 79
|
|---|
| 116 | cpu
|
|---|
| 117 | ---
|
|---|
| 118 | 17380: 2 2 5 11 79
|
|---|
| 119 | cpu
|
|---|
| 120 | ---
|
|---|
| 121 | Doing some more tests -----------------------
|
|---|
| 122 | 17380: 2 2 5 11 79
|
|---|
| 123 | ---
|
|---|
| 124 | sed 1q eval.in2
|
|---|
| 125 | ---
|
|---|
| 126 | 17380: 2 2 5 11 79
|
|---|
| 127 | ---
|
|---|
| 128 | sed 1q eval.in2
|
|---|
| 129 | ---
|
|---|
| 130 | sed 1q eval.in2
|
|---|
| 131 | EOF
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | sed -f eval.sed eval-in > eval-out || fail=1
|
|---|
| 137 | remove_cr_inplace eval-out
|
|---|
| 138 | compare eval-exp eval-out || fail=1
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | Exit $fail
|
|---|