mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-26 02:52:35 +00:00 
			
		
		
		
	 8fc862f710
			
		
	
	
		8fc862f710
		
	
	
	
	
		
			
			Also make them runnable anywhere. Previously they required $PWD to be the directory containing test-commons.inc, and for $PWD to be writable.
		
			
				
	
	
		
			53 lines
		
	
	
	
		
			725 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
	
		
			725 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/Shell
 | |
| 
 | |
| echo "Not running Shell-backgrounding as it has a high failure rate"
 | |
| echo PASS
 | |
| exit 0
 | |
| 
 | |
| source $(dirname "$0")/test-commons.inc
 | |
| 
 | |
| setopt --verbose
 | |
| 
 | |
| 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
 |