@@ -0,0 +1,289 @@ |
| 1 | +metadata: |
| 2 | + category: Stress |
| 3 | + description: Interactive stress tests for buffer limits, deep nesting, large values, and escape sequences |
| 4 | +tests: |
| 5 | +# ========================================== |
| 6 | +# 1. Long command lines |
| 7 | +# ========================================== |
| 8 | +- name: '1. LONG COMMANDS: 200-char echo' |
| 9 | + steps: |
| 10 | + - send_line: echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 11 | + expect_output: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 12 | + match_type: contains |
| 13 | + |
| 14 | +- name: '1. LONG COMMANDS: long pipeline' |
| 15 | + steps: |
| 16 | + - send_line: echo abcdefghij | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat |
| 17 | + expect_output: abcdefghij |
| 18 | + match_type: contains |
| 19 | + |
| 20 | +- name: '1. LONG COMMANDS: long variable value' |
| 21 | + steps: |
| 22 | + - send_line: X=$(printf '%0200d' 0); echo ${#X} |
| 23 | + expect_output: '200' |
| 24 | + match_type: contains |
| 25 | + |
| 26 | +# ========================================== |
| 27 | +# 2. Escape sequences (the gap that triggered this) |
| 28 | +# ========================================== |
| 29 | +- name: '2. ESCAPE SEQUENCES: hex in dollar-single-quote' |
| 30 | + steps: |
| 31 | + - send_line: echo $'\x48\x65\x6c\x6c\x6f' |
| 32 | + expect_output: Hello |
| 33 | + match_type: contains |
| 34 | + |
| 35 | +- name: '2. ESCAPE SEQUENCES: octal in dollar-single-quote' |
| 36 | + steps: |
| 37 | + - send_line: echo $'\110\145\154\154\157' |
| 38 | + expect_output: Hello |
| 39 | + match_type: contains |
| 40 | + |
| 41 | +- name: '2. ESCAPE SEQUENCES: mixed escapes' |
| 42 | + steps: |
| 43 | + - send_line: echo $'\x41\t\x42\t\x43' |
| 44 | + expect_output: A |
| 45 | + match_type: contains |
| 46 | + |
| 47 | +- name: '2. ESCAPE SEQUENCES: tab in dollar-quote' |
| 48 | + steps: |
| 49 | + - send_line: echo $'a\tb' |
| 50 | + expect_output: a |
| 51 | + match_type: contains |
| 52 | + |
| 53 | +- name: '2. ESCAPE SEQUENCES: newline in dollar-quote' |
| 54 | + steps: |
| 55 | + - send_line: echo $'line1\nline2' |
| 56 | + expect_output: line1 |
| 57 | + match_type: contains |
| 58 | + |
| 59 | +- name: '2. ESCAPE SEQUENCES: single quote in dollar-quote' |
| 60 | + steps: |
| 61 | + - send_line: echo $'it'\''s fine' |
| 62 | + expect_output: it's fine |
| 63 | + match_type: contains |
| 64 | + |
| 65 | +- name: '2. ESCAPE SEQUENCES: printf hex' |
| 66 | + steps: |
| 67 | + - send_line: printf '\x41\x42\x43\n' |
| 68 | + expect_output: ABC |
| 69 | + match_type: contains |
| 70 | + |
| 71 | +- name: '2. ESCAPE SEQUENCES: printf %b hex' |
| 72 | + steps: |
| 73 | + - send_line: printf '%b' '\x41\x42\x43\n' |
| 74 | + expect_output: ABC |
| 75 | + match_type: contains |
| 76 | + |
| 77 | +- name: '2. ESCAPE SEQUENCES: printf octal' |
| 78 | + steps: |
| 79 | + - send_line: printf '\101\102\103\n' |
| 80 | + expect_output: ABC |
| 81 | + match_type: contains |
| 82 | + |
| 83 | +- name: '2. ESCAPE SEQUENCES: var@E hex' |
| 84 | + steps: |
| 85 | + - send_line: X='\x48\x69'; echo "${X@E}" |
| 86 | + expect_output: Hi |
| 87 | + match_type: contains |
| 88 | + |
| 89 | +- name: '2. ESCAPE SEQUENCES: var@E octal' |
| 90 | + steps: |
| 91 | + - send_line: X='\110\151'; echo "${X@E}" |
| 92 | + expect_output: Hi |
| 93 | + match_type: contains |
| 94 | + |
| 95 | +# ========================================== |
| 96 | +# 3. Associative arrays (previously broken on ARM64) |
| 97 | +# ========================================== |
| 98 | +- name: '3. ASSOC ARRAYS: basic set and get' |
| 99 | + steps: |
| 100 | + - send_line: declare -A m; m[key]=val; echo ${m[key]} |
| 101 | + expect_output: val |
| 102 | + match_type: contains |
| 103 | + |
| 104 | +- name: '3. ASSOC ARRAYS: multiple keys' |
| 105 | + steps: |
| 106 | + - send_line: declare -A m; m[a]=1; m[b]=2; m[c]=3; echo ${#m[@]} |
| 107 | + expect_output: '3' |
| 108 | + match_type: contains |
| 109 | + |
| 110 | +- name: '3. ASSOC ARRAYS: overwrite' |
| 111 | + steps: |
| 112 | + - send_line: declare -A m; m[k]=old; m[k]=new; echo ${m[k]} |
| 113 | + expect_output: new |
| 114 | + match_type: contains |
| 115 | + |
| 116 | +- name: '3. ASSOC ARRAYS: key with spaces' |
| 117 | + steps: |
| 118 | + - send_line: declare -A m; m["hello world"]=yes; echo ${m["hello world"]} |
| 119 | + expect_output: 'yes' |
| 120 | + match_type: contains |
| 121 | + |
| 122 | +# ========================================== |
| 123 | +# 4. Deep nesting |
| 124 | +# ========================================== |
| 125 | +- name: '4. NESTING: nested command substitution' |
| 126 | + steps: |
| 127 | + - send_line: echo $(echo $(echo $(echo deep))) |
| 128 | + expect_output: deep |
| 129 | + match_type: contains |
| 130 | + |
| 131 | +- name: '4. NESTING: nested parameter expansion' |
| 132 | + steps: |
| 133 | + - send_line: A=hello; B=A; echo ${!B} |
| 134 | + expect_output: hello |
| 135 | + match_type: contains |
| 136 | + |
| 137 | +- name: '4. NESTING: nested arithmetic' |
| 138 | + steps: |
| 139 | + - send_line: echo $(( (1 + 2) * (3 + 4) )) |
| 140 | + expect_output: '21' |
| 141 | + match_type: contains |
| 142 | + |
| 143 | +# ========================================== |
| 144 | +# 5. Case transforms (previously broken on macOS) |
| 145 | +# ========================================== |
| 146 | +- name: '5. CASE TRANSFORMS: uppercase all' |
| 147 | + steps: |
| 148 | + - send_line: X=hello; echo ${X^^} |
| 149 | + expect_output: HELLO |
| 150 | + match_type: contains |
| 151 | + |
| 152 | +- name: '5. CASE TRANSFORMS: lowercase all' |
| 153 | + steps: |
| 154 | + - send_line: X=HELLO; echo ${X,,} |
| 155 | + expect_output: hello |
| 156 | + match_type: contains |
| 157 | + |
| 158 | +- name: '5. CASE TRANSFORMS: capitalize first' |
| 159 | + steps: |
| 160 | + - send_line: X=hello; echo ${X^} |
| 161 | + expect_output: Hello |
| 162 | + match_type: contains |
| 163 | + |
| 164 | +# ========================================== |
| 165 | +# 6. C-style for loops |
| 166 | +# ========================================== |
| 167 | +- name: '6. C-STYLE FOR: basic count' |
| 168 | + steps: |
| 169 | + - send_line: for ((i=0; i<5; i++)); do printf "%d " $i; done; echo |
| 170 | + expect_output: 0 1 2 3 4 |
| 171 | + match_type: contains |
| 172 | + |
| 173 | +- name: '6. C-STYLE FOR: countdown' |
| 174 | + steps: |
| 175 | + - send_line: for ((i=5; i>0; i--)); do printf "%d " $i; done; echo |
| 176 | + expect_output: 5 4 3 2 1 |
| 177 | + match_type: contains |
| 178 | + |
| 179 | +# ========================================== |
| 180 | +# 7. Process substitution |
| 181 | +# ========================================== |
| 182 | +- name: '7. PROCESS SUB: diff two commands' |
| 183 | + steps: |
| 184 | + - send_line: diff <(echo hello) <(echo hello); echo $? |
| 185 | + expect_output: '0' |
| 186 | + match_type: contains |
| 187 | + |
| 188 | +- name: '7. PROCESS SUB: paste two streams' |
| 189 | + steps: |
| 190 | + - send_line: paste <(echo a) <(echo b) |
| 191 | + expect_output: a |
| 192 | + match_type: contains |
| 193 | + |
| 194 | +# ========================================== |
| 195 | +# 8. Coprocesses |
| 196 | +# ========================================== |
| 197 | +- name: '8. COPROC: basic brace group' |
| 198 | + steps: |
| 199 | + - send_line: coproc { echo from_coproc; }; read line <&${COPROC[0]}; echo $line |
| 200 | + expect_output: from_coproc |
| 201 | + match_type: contains |
| 202 | + timeout: 5 |
| 203 | + |
| 204 | +# ========================================== |
| 205 | +# 9. Brace expansion with step |
| 206 | +# ========================================== |
| 207 | +- name: '9. BRACE: range with step' |
| 208 | + steps: |
| 209 | + - send_line: echo {1..10..2} |
| 210 | + expect_output: 1 3 5 7 9 |
| 211 | + match_type: contains |
| 212 | + |
| 213 | +- name: '9. BRACE: reverse range' |
| 214 | + steps: |
| 215 | + - send_line: echo {5..1} |
| 216 | + expect_output: 5 4 3 2 1 |
| 217 | + match_type: contains |
| 218 | + |
| 219 | +- name: '9. BRACE: alpha range' |
| 220 | + steps: |
| 221 | + - send_line: echo {a..f} |
| 222 | + expect_output: a b c d e f |
| 223 | + match_type: contains |
| 224 | + |
| 225 | +# ========================================== |
| 226 | +# 10. File tests (previously broken on aarch64) |
| 227 | +# ========================================== |
| 228 | +- name: '10. FILE TESTS: test -f' |
| 229 | + steps: |
| 230 | + - send_line: touch /tmp/fortsh_pty_test_file; test -f /tmp/fortsh_pty_test_file && echo exists |
| 231 | + expect_output: exists |
| 232 | + match_type: contains |
| 233 | + |
| 234 | +- name: '10. FILE TESTS: test -d' |
| 235 | + steps: |
| 236 | + - send_line: test -d /tmp && echo isdir |
| 237 | + expect_output: isdir |
| 238 | + match_type: contains |
| 239 | + |
| 240 | +- name: '10. FILE TESTS: bracket -f' |
| 241 | + steps: |
| 242 | + - send_line: touch /tmp/fortsh_pty_test_file; [ -f /tmp/fortsh_pty_test_file ] && echo exists |
| 243 | + expect_output: exists |
| 244 | + match_type: contains |
| 245 | + |
| 246 | +- name: '10. FILE TESTS: cleanup' |
| 247 | + steps: |
| 248 | + - send_line: rm -f /tmp/fortsh_pty_test_file; echo cleaned |
| 249 | + expect_output: cleaned |
| 250 | + match_type: contains |
| 251 | + |
| 252 | +# ========================================== |
| 253 | +# 11. ANSI-C quoting |
| 254 | +# ========================================== |
| 255 | +- name: '11. ANSI-C: backslash literal' |
| 256 | + steps: |
| 257 | + - send_line: echo $'backslash:\\' |
| 258 | + expect_output: 'backslash:' |
| 259 | + match_type: contains |
| 260 | + |
| 261 | +- name: '11. ANSI-C: double quote in single' |
| 262 | + steps: |
| 263 | + - send_line: echo $'say "hi"' |
| 264 | + expect_output: say "hi" |
| 265 | + match_type: contains |
| 266 | + |
| 267 | +# ========================================== |
| 268 | +# 12. Regex with BASH_REMATCH |
| 269 | +# ========================================== |
| 270 | +- name: '12. REGEX: basic match' |
| 271 | + steps: |
| 272 | + - send_line: '[[ "hello123" =~ ^([a-z]+)([0-9]+)$ ]] && echo "${BASH_REMATCH[1]} ${BASH_REMATCH[2]}"' |
| 273 | + expect_output: hello 123 |
| 274 | + match_type: contains |
| 275 | + |
| 276 | +# ========================================== |
| 277 | +# 13. Here strings |
| 278 | +# ========================================== |
| 279 | +- name: '13. HERE STRING: basic' |
| 280 | + steps: |
| 281 | + - send_line: cat <<< "hello from here" |
| 282 | + expect_output: hello from here |
| 283 | + match_type: contains |
| 284 | + |
| 285 | +- name: '13. HERE STRING: with variable' |
| 286 | + steps: |
| 287 | + - send_line: X=world; cat <<< "hello $X" |
| 288 | + expect_output: hello world |
| 289 | + match_type: contains |