Files
sausage/userland/brush/source/brush-shell/tests/cases/compat/builtins/ulimit.yaml
T
2026-11-11 22:04:16 +00:00

163 lines
4.5 KiB
YAML

name: "Builtins: ulimit"
cases:
- name: "ulimit -c"
stdin: |
ulimit -c
- name: "ulimit -d"
stdin: |
ulimit -d
- name: "ulimit -f"
stdin: |
ulimit -f
- name: "ulimit -l"
stdin: |
ulimit -l
- name: "ulimit -m"
stdin: |
ulimit -m
- name: "ulimit -n"
stdin: |
ulimit -n
- name: "ulimit -s"
stdin: |
ulimit -s
- name: "ulimit -t"
stdin: |
ulimit -t
- name: "ulimit -u"
stdin: |
ulimit -u
- name: "ulimit -v"
stdin: |
ulimit -v
- name: "ulimit -p"
known_failure: true # TODO(ulimit): brush reports a pipe size of 5 blocks, where bash reports 8 (4096 bytes)
incompatible_platforms: ["macos"] # the pipe size differs there
stdin: |
ulimit -p
- name: "ulimit -d unlimited"
stdin: |
ulimit -d unlimited
- name: "ulimit -f unlimited"
stdin: |
ulimit -f unlimited
- name: "ulimit -m unlimited"
stdin: |
ulimit -m unlimited
- name: "ulimit with an invalid number fails with status 1"
known_failure: true # TODO(ulimit): fails with status 2, where bash fails with 1
ignore_stderr: true
stdin: |
ulimit -n abc
echo "ulimit: $?"
- name: "ulimit in a subshell stays there"
known_failure: true # TODO(ulimit): a subshell runs in the shell's own process, so its limits are the shell's
stdin: |
ulimit -S -n 512
( ulimit -S -n 256 )
echo "after a subshell: $(ulimit -S -n)"
ulimit -S -n 256 | true
echo "after a pipeline stage: $(ulimit -S -n)"
- name: "ulimit with no options reports the file size limit"
stdin: |
ulimit
- name: "ulimit -S and -H report the soft and hard limits"
stdin: |
ulimit -Sn
ulimit -Hn
ulimit -S -n
- name: "ulimit sets a limit given as a separate or attached value"
stdin: |
ulimit -n 100; ulimit -n
ulimit -n99; ulimit -n
ulimit -Sn 98; ulimit -Sn
ulimit -c 0; ulimit -c
- name: "ulimit sets the file size limit from an operand"
# Large enough not to stop the shell writing, e.g., coverage data at exit.
stdin: |
ulimit 100000000; ulimit -f
ulimit -- 90000000; echo "ulimit -- 90000000: $?"; ulimit -f
- name: "ulimit sets a limit to its soft limit"
stdin: |
ulimit -n soft; echo "ulimit -n soft: $?"; ulimit -n
- name: "ulimit sets several limits at once"
stdin: |
ulimit -n 100 -c 0; ulimit -n; ulimit -c
- name: "ulimit ignores operands after the first value"
stdin: |
ulimit -n 100 200; echo "ulimit -n 100 200: $?"; ulimit -n
- name: "ulimit rejects an unknown option and a negative limit"
ignore_stderr: true
stdin: |
ulimit -Z; echo "ulimit -Z: $?"
ulimit -n -1; echo "ulimit -n -1: $?"
- name: "ulimit lists several resources in the order given"
known_failure: true # TODO(ulimit): brush lists them in a fixed order, with its own labels and widths
stdin: |
ulimit -n -c
ulimit -s -t
- name: "ulimit labels a resource it reports alongside one it sets"
known_failure: true # TODO(ulimit): brush prints the bare value
stdin: |
ulimit -c 0 -n
- name: "ulimit takes a limit's value after --"
known_failure: true # TODO(ulimit): brush reports the limit and ignores the value
stdin: |
ulimit -n -- 100; echo "ulimit -n -- 100: $?"; ulimit -n
- name: "ulimit rejects a resource this platform lacks with status 2"
known_failure: true # TODO(ulimit): brush takes each and fails with "unsupported resource", status 1
incompatible_platforms: ["macos"] # which of these exist differs there
ignore_stderr: true
stdin: |
ulimit -b; echo "ulimit -b: $?"
ulimit -k; echo "ulimit -k: $?"
ulimit -P; echo "ulimit -P: $?"
ulimit -T; echo "ulimit -T: $?"
- name: "ulimit --help fails with status 2"
stdin: |
ulimit --help >/dev/null 2>&1; echo "ulimit --help: $?"
- name: "ulimit rejects an unknown long option with status 2"
ignore_stderr: true
stdin: |
ulimit --bogus; echo "ulimit --bogus: $?"
- name: "ulimit -a lists every limit"
known_failure: true # TODO(ulimit): brush's labels, widths and order differ, e.g. `(block, -c)` for `(blocks, -c)`
stdin: |
ulimit -a
- name: "ulimit -a with another resource lists each limit once"
known_failure: true # TODO(ulimit): brush lists the other resource a second time
stdin: |
a=$(ulimit -a); an=$(ulimit -a -n)
[[ $a == "$an" ]] && echo same || echo differs