OILS / spec / ysh-stdlib-sync.test.sh.DISABLED View on Github | oilshell.org

56 lines, 50 significant
1# spec/ysh-stdlib
2
3## our_shell: ysh
4
5#### semaphore
6source --builtin draft-synch.ysh
7
8sema-new (1, &s)
9fork {
10 sleep 0.5
11 sema-down (s)
12 echo 1
13}
14fork {
15 sleep 1
16 sema-down (s)
17 echo 2
18}
19fork {
20 sleep 1.5
21 sema-down (s)
22 echo 3
23}
24sleep 2
25echo 4
26sema-up (s)
27sleep 0.5
28echo 5
29sema-up (s)
30sema-destroy (s)
31## STDOUT:
321
334
342
355
363
37## END
38
39#### semaphore init and multiple down
40source --builtin draft-synch.ysh
41
42sema-new (3, &s)
43fork {
44 sleep 1
45 sema-up (s)
46}
47sema-down (s)
48sema-down (s)
49sema-down (s)
50sema-down (s)
51echo yes
52## STDOUT:
53yes
54## END
55
56# TODO: add test case for mutex and other sync primitives