| 1 | metadata: |
| 2 | category: "POSIX Basic Sample" |
| 3 | description: Sample of converted basic POSIX tests |
| 4 | tests: |
| 5 | - name: echo simple |
| 6 | steps: |
| 7 | - send_line: echo hello |
| 8 | expect_output: hello |
| 9 | match_type: contains |
| 10 | |
| 11 | - name: echo with args |
| 12 | steps: |
| 13 | - send_line: echo one two three |
| 14 | expect_output: one two three |
| 15 | match_type: contains |
| 16 | |
| 17 | - name: printf basic |
| 18 | steps: |
| 19 | - send_line: printf 'test\n' |
| 20 | expect_output: test |
| 21 | match_type: contains |
| 22 | |
| 23 | - name: variable in quotes |
| 24 | steps: |
| 25 | - send_line: VAR=test; echo "$VAR" |
| 26 | expect_output: test |
| 27 | match_type: contains |
| 28 | |
| 29 | - name: parameter expansion default |
| 30 | steps: |
| 31 | - send_line: echo "${UNSET:-default}" |
| 32 | expect_output: default |
| 33 | match_type: contains |
| 34 | |
| 35 | - name: string length |
| 36 | steps: |
| 37 | - send_line: VAR=hello; echo "${#VAR}" |
| 38 | expect_output: '5' |
| 39 | match_type: contains |
| 40 | |
| 41 | - name: remove shortest prefix |
| 42 | steps: |
| 43 | - send_line: VAR=foo.bar.baz; echo "${VAR#*.}" |
| 44 | expect_output: bar.baz |
| 45 | match_type: contains |
| 46 | |
| 47 | - name: expr addition |
| 48 | steps: |
| 49 | - send_line: expr 5 + 3 |
| 50 | expect_output: '8' |
| 51 | match_type: contains |
| 52 | |
| 53 | - name: if true |
| 54 | steps: |
| 55 | - send_line: if true; then echo yes; fi |
| 56 | expect_output: 'yes' # Quote to prevent YAML boolean parsing |
| 57 | match_type: contains |
| 58 | |
| 59 | - name: simple function |
| 60 | steps: |
| 61 | - send_line: func() { echo hello; }; func |
| 62 | expect_output: hello |
| 63 | match_type: contains |
| 64 | |
| 65 | - name: function with args |
| 66 | steps: |
| 67 | - send_line: func() { echo $1 $2; }; func foo bar |
| 68 | expect_output: foo bar |
| 69 | match_type: contains |
| 70 | |
| 71 | - name: special var $# count |
| 72 | steps: |
| 73 | - send_line: set -- a b c; echo $# |
| 74 | expect_output: '3' |
| 75 | match_type: contains |
| 76 | |
| 77 | - name: special var $@ all args |
| 78 | steps: |
| 79 | - send_line: set -- a b c; echo $@ |
| 80 | expect_output: a b c |
| 81 | match_type: contains |
| 82 | |
| 83 | - name: true && echo |
| 84 | steps: |
| 85 | - send_line: true && echo success |
| 86 | expect_output: success |
| 87 | match_type: contains |
| 88 | |
| 89 | - name: set positional |
| 90 | steps: |
| 91 | - send_line: set -- a b c; echo $1 $2 $3 |
| 92 | expect_output: a b c |
| 93 | match_type: contains |
| 94 |