mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
Shell: Add some basic tests for backgrounding
This commit is contained in:
parent
6e2a383f25
commit
2d6d1ca67f
Notes:
sideshowbarker
2024-07-19 01:39:41 +09:00
Author: https://github.com/alimpfard
Commit: 2d6d1ca67f
Pull-request: https://github.com/SerenityOS/serenity/pull/3858
1 changed files with 53 additions and 0 deletions
53
Shell/Tests/backgrounding.sh
Normal file
53
Shell/Tests/backgrounding.sh
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/Shell
|
||||
|
||||
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