mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
124 lines
3 KiB
Plaintext
124 lines
3 KiB
Plaintext
echo '### Test mutex. This should not mix output'; parallel --semaphore --id mutex -u seq 1 10 '|' pv -qL 20; parallel --semaphore --id mutex -u seq 11 20 '|' pv -qL 100; parallel --semaphore --id mutex --wait; echo done
|
|
### Test mutex. This should not mix output
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
done
|
|
echo '### Test semaphore 2 jobs running simultaneously'
|
|
### Test semaphore 2 jobs running simultaneously
|
|
parallel --semaphore --id 2jobs -u -j2 'echo job1a 1; sleep 1; echo job1b 3'; sleep 0.2; parallel --semaphore --id 2jobs -u -j2 'echo job2a 2; sleep 1; echo job2b 5'; sleep 0.2; parallel --semaphore --id 2jobs -u -j2 'echo job3a 4; sleep 1; echo job3b 6'; parallel --semaphore --id 2jobs --wait; echo done
|
|
job1a 1
|
|
job2a 2
|
|
job1b 3
|
|
job3a 4
|
|
job2b 5
|
|
job3b 6
|
|
done
|
|
echo '### Test if parallel invoked as sem will run parallel --semaphore'
|
|
### Test if parallel invoked as sem will run parallel --semaphore
|
|
sem --id as_sem -u -j2 'echo job1a 1; sleep 1; echo job1b 3'; sleep 0.2; sem --id as_sem -u -j2 'echo job2a 2; sleep 1; echo job2b 5'; sleep 0.2; sem --id as_sem -u -j2 'echo job3a 4; sleep 1; echo job3b 6'; sem --id as_sem --wait; echo done
|
|
job1a 1
|
|
job2a 2
|
|
job1b 3
|
|
job3a 4
|
|
job2b 5
|
|
job3b 6
|
|
done
|
|
echo '### Test similar example as from man page - run 2 jobs simultaneously'
|
|
### Test similar example as from man page - run 2 jobs simultaneously
|
|
echo 'Expect done: 1 2 5 3 4'
|
|
Expect done: 1 2 5 3 4
|
|
for i in 5 1 2 3 4 ; do sleep 0.2; echo Scheduling $i; sem -j2 --id ex2jobs -u echo starting $i ";" sleep $i ";" echo done $i; done; sem --id ex2jobs --wait
|
|
Scheduling 5
|
|
starting 5
|
|
Scheduling 1
|
|
starting 1
|
|
Scheduling 2
|
|
done 1
|
|
starting 2
|
|
Scheduling 3
|
|
done 2
|
|
starting 3
|
|
Scheduling 4
|
|
done 5
|
|
starting 4
|
|
done 3
|
|
done 4
|
|
echo '### Test --fg followed by --bg'
|
|
### Test --fg followed by --bg
|
|
parallel -u --id fgbg --fg --semaphore seq 1 10 '|' pv -qL 30; parallel -u --id fgbg --bg --semaphore seq 11 20 '|' pv -qL 30; parallel -u --id fgbg --fg --semaphore seq 21 30 '|' pv -qL 30; parallel -u --id fgbg --bg --semaphore seq 31 40 '|' pv -qL 30; sem --id fgbg --wait
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
|
40
|
|
echo '### Test bug #33621: --bg -p should give an error message'
|
|
### Test bug #33621: --bg -p should give an error message
|
|
stdout parallel -p --bg echo x{}
|
|
parallel: Error: Jobs running in the background cannot be interactive.
|
|
echo '### Failed on 20141226'
|
|
### Failed on 20141226
|
|
sem --fg --line-buffer --id bugin20141226 echo OK
|
|
OK
|
|
echo '### Test --st +1/-1'
|
|
### Test --st +1/-1
|
|
stdout sem --id st --line-buffer "echo A normal-start;sleep 3;echo C normal-end"; stdout sem --id st --line-buffer --st 1 "echo B st1-start;sleep 3;echo D st1-end"; stdout sem --id st --line-buffer --st -1 "echo ERROR-st-1-start;sleep 3;echo ERROR-st-1-end"; stdout sem --id st --wait
|
|
A normal-start
|
|
parallel: Warning: Semaphore timed out. Stealing the semaphore.
|
|
B st1-start
|
|
C normal-end
|
|
parallel: Warning: Semaphore timed out. Exiting.
|
|
D st1-end
|