2010-08-16 14:16:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-08-16 22:25:11 +00:00
|
|
|
echo '### Test mutex. This should not mix output'
|
|
|
|
parallel -u --semaphore seq 1 10 '|' pv -qL 20
|
|
|
|
parallel -u --semaphore seq 11 20 '|' pv -qL 100
|
|
|
|
parallel --semaphore --wait
|
|
|
|
echo done
|
|
|
|
|
2010-08-17 06:53:46 +00:00
|
|
|
echo '### Test default id = --id `tty` and --semaphorename'
|
2010-08-16 22:25:11 +00:00
|
|
|
parallel --id `tty` -u --semaphore seq 1 10 '|' pv -qL 20
|
|
|
|
parallel -u --semaphore seq 11 20 '|' pv -qL 100
|
2010-08-17 06:53:46 +00:00
|
|
|
parallel --semaphorename `tty` --semaphore --wait
|
2010-08-16 22:25:11 +00:00
|
|
|
echo done
|
2010-08-16 14:16:56 +00:00
|
|
|
|
2010-08-16 22:25:11 +00:00
|
|
|
echo '### Test semaphore 2 jobs running simultaneously'
|
2011-07-29 11:45:34 +00:00
|
|
|
parallel -u -j2 --semaphore 'echo job1a; sleep 1; echo job1b'
|
|
|
|
sleep 0.1
|
|
|
|
parallel -u -j2 --semaphore 'echo job2a; sleep 1; echo job2b'
|
|
|
|
sleep 0.1
|
|
|
|
parallel -u -j2 --semaphore 'echo job3a; sleep 1; echo job3b'
|
2010-08-16 22:25:11 +00:00
|
|
|
parallel --semaphore --wait
|
|
|
|
echo done
|
2010-08-16 14:16:56 +00:00
|
|
|
|
2010-08-16 22:25:11 +00:00
|
|
|
echo '### Test if parallel invoked as sem will run parallel --semaphore'
|
2011-07-29 11:45:34 +00:00
|
|
|
sem -u -j2 'echo job1a; sleep 1; echo job1b'
|
|
|
|
sleep 0.1
|
|
|
|
sem -u -j2 'echo job2a; sleep 1; echo job2b'
|
|
|
|
sleep 0.1
|
|
|
|
sem -u -j2 'echo job3a; sleep 1; echo job3b'
|
2010-08-16 22:25:11 +00:00
|
|
|
sem --wait
|
|
|
|
echo done
|
|
|
|
|
2010-08-21 23:29:26 +00:00
|
|
|
echo '### Test similar example as from man page - run 2 jobs simultaneously'
|
|
|
|
echo 'Expect done: 1 2 5 3 4'
|
|
|
|
for i in 5 1 2 3 4 ; do
|
|
|
|
echo Scheduling $i
|
|
|
|
sem -j2 -u echo starting $i ";" sleep $i ";" echo done $i
|
2010-08-16 22:25:11 +00:00
|
|
|
done
|
|
|
|
sem --wait
|
2010-08-17 06:53:46 +00:00
|
|
|
|
2010-08-21 23:29:26 +00:00
|
|
|
echo '### Test --fg followed by --bg'
|
|
|
|
parallel -u --fg --semaphore seq 1 10 '|' pv -qL 30
|
|
|
|
parallel -u --bg --semaphore seq 11 20 '|' pv -qL 30
|
|
|
|
parallel -u --fg --semaphore seq 21 30 '|' pv -qL 30
|
|
|
|
parallel -u --bg --semaphore seq 31 40 '|' pv -qL 30
|
|
|
|
sem --wait
|
2011-06-22 22:12:16 +00:00
|
|
|
|
|
|
|
echo '### Test bug #33621: --bg -p should give an error message'
|
|
|
|
stdout parallel -p --bg echo x{}
|