mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
Shell: Move to Userland/Shell/
This commit is contained in:
parent
07c7e35372
commit
c4e2fd8123
35 changed files with 11 additions and 9 deletions
55
Userland/Shell/Tests/backgrounding.sh
Normal file
55
Userland/Shell/Tests/backgrounding.sh
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/Shell
|
||||
|
||||
echo "Not running Shell-backgrounding as it has a high failure rate"
|
||||
exit 0
|
||||
|
||||
setopt --verbose
|
||||
|
||||
fail(msg) {
|
||||
echo FAIL: $msg
|
||||
exit 1
|
||||
}
|
||||
|
||||
last_idx=''
|
||||
block_idx=0
|
||||
block() {
|
||||
block_idx=$(expr 1 + $block_idx)
|
||||
last_idx=$block_idx
|
||||
mkfifo fifo$block_idx
|
||||
cat fifo$block_idx&
|
||||
}
|
||||
|
||||
unblock(idx) {
|
||||
echo unblock $idx > fifo$idx
|
||||
rm -f fifo$idx
|
||||
}
|
||||
|
||||
assert_job_count(count) {
|
||||
ecount=$(jobs | wc -l)
|
||||
shift
|
||||
if test $ecount -ne $count {
|
||||
for $* {
|
||||
unblock $it
|
||||
}
|
||||
fail "expected $ecount == $count"
|
||||
}
|
||||
}
|
||||
|
||||
block
|
||||
i=$last_idx
|
||||
|
||||
assert_job_count 1 $i
|
||||
|
||||
unblock $i
|
||||
wait
|
||||
|
||||
block
|
||||
i=$last_idx
|
||||
block
|
||||
j=$last_idx
|
||||
|
||||
assert_job_count 2 $i $j
|
||||
|
||||
unblock $i
|
||||
unblock $j
|
||||
wait
|
Loading…
Add table
Add a link
Reference in a new issue