added a test on process handling.
Some checks failed
continuous-integration/drone/push Build is failing

used hcl_instantiate() in making process-related objects
This commit is contained in:
2024-09-12 16:08:16 +09:00
parent 8604c6ddf1
commit 6e9e1d35f4
10 changed files with 113 additions and 54 deletions

View File

@ -5,6 +5,7 @@ check_SCRIPTS = \
fun-01.hcl \
insta-01.hcl \
insta-02.hcl \
proc-01.hcl \
ret-01.hcl \
retvar-01.hcl \
va-01.hcl \

View File

@ -477,6 +477,7 @@ check_SCRIPTS = \
fun-01.hcl \
insta-01.hcl \
insta-02.hcl \
proc-01.hcl \
ret-01.hcl \
retvar-01.hcl \
va-01.hcl \

50
t/proc-01.hcl Normal file
View File

@ -0,0 +1,50 @@
z1 := 0
z2 := 0
defun loop1() {
| k |
k := 1
while (< k 100) {
printf "loop1 => %d\n" k
k := (+ k 2)
yield
}
z1 := k
sem-signal s1
}
defun loop2() {
| k |
k := 0
while (< k 100) {
printf "loop2 => %d\n" k
k := (+ k 2)
yield
}
z2 := k
sem-signal s2
}
s1 := (sem-new)
s2 := (sem-new)
p1 := (fork loop1)
p2 := (fork loop2)
##suspend p1
##suspend p2
##resume p1
##resume p2
sem-wait s1
sem-wait s2
if (== z1 101) { printf "OK: z1 is %d\n" z1 } \
else { printf "ERROR: z1 is not 101 - %d\n" z1 }
if (== z2 100) { printf "OK: z2 is %d\n" z2 } \
else { printf "ERROR: z1 is not 100 - %d\n" z2 }