Fortran · 4081 bytes Raw Blame History
1 program test_scaffold
2 use fgof_jobs, only : &
3 FGOF_JOBS_SIGNAL_SCOPE_GROUP, &
4 FGOF_JOBS_TERMINAL_HANDOFF_FOREGROUND, &
5 clear_job_handle, &
6 clear_job_member, &
7 clear_job_result, &
8 clear_job_spec, &
9 jobs_backend_name
10 use fgof_jobs_types, only : job_handle, job_member, job_result, job_spec
11 implicit none
12
13 type(job_spec) :: spec
14 type(job_handle) :: handle
15 type(job_member) :: member
16 type(job_result) :: result_value
17
18 spec = clear_job_spec()
19 if (allocated(spec%command)) error stop "job spec should not allocate command by default"
20 if (allocated(spec%argv)) error stop "job spec should not allocate argv by default"
21 if (spec%background) error stop "job spec should start in foreground mode"
22 if (.not. spec%new_process_group) error stop "job spec should default to a new process group"
23 if (spec%signal_scope /= FGOF_JOBS_SIGNAL_SCOPE_GROUP) error stop "job spec should default to group-wide signal forwarding"
24 if (spec%terminal_handoff /= FGOF_JOBS_TERMINAL_HANDOFF_FOREGROUND) then
25 error stop "job spec should default to foreground terminal handoff"
26 end if
27 if (.not. spec%resume_sends_sigcont) error stop "job spec should default to resuming with SIGCONT"
28
29 member = clear_job_member()
30 if (member%pid /= 0) error stop "job member should start with pid zero"
31 if (member%running) error stop "job member should not start running"
32 if (member%stopped) error stop "job member should not start stopped"
33 if (member%finished) error stop "job member should not start finished"
34 if (member%result%available) error stop "job member result should start unavailable"
35
36 handle = clear_job_handle()
37 if (allocated(handle%spec%command)) error stop "job handle should clear embedded spec command"
38 if (allocated(handle%spec%argv)) error stop "job handle should clear embedded spec argv"
39 if (allocated(handle%members)) error stop "job handle should not allocate pipeline members by default"
40 if (handle%pid /= 0) error stop "job handle should start with pid zero"
41 if (handle%process_group /= 0) error stop "job handle should start with process group zero"
42 if (handle%signal_scope /= FGOF_JOBS_SIGNAL_SCOPE_GROUP) error stop "job handle should default to group-wide signal forwarding"
43 if (handle%terminal_handoff /= FGOF_JOBS_TERMINAL_HANDOFF_FOREGROUND) then
44 error stop "job handle should default to foreground terminal handoff"
45 end if
46 if (handle%configured) error stop "job handle should not start configured"
47 if (handle%running) error stop "job handle should not start running"
48 if (handle%stopped) error stop "job handle should not start stopped"
49 if (handle%finished) error stop "job handle should not start finished"
50 if (handle%background) error stop "job handle should not start as background"
51 if (handle%owns_process) error stop "job handle should not own a process by default"
52 if (handle%owns_process_group) error stop "job handle should not own a process group by default"
53 if (handle%cleanup_needed) error stop "job handle should not need cleanup by default"
54 if (.not. handle%resume_sends_sigcont) error stop "job handle should default to resuming with SIGCONT"
55
56 result_value = clear_job_result()
57 if (result_value%pid /= 0) error stop "job result should start with pid zero"
58 if (result_value%process_group /= 0) error stop "job result should start with process group zero"
59 if (result_value%exit_code /= 0) error stop "job result should start with exit code zero"
60 if (result_value%signal /= 0) error stop "job result should start with signal zero"
61 if (result_value%exited) error stop "job result should not start exited"
62 if (result_value%signaled) error stop "job result should not start signaled"
63 if (result_value%stopped) error stop "job result should not start stopped"
64 if (result_value%continued) error stop "job result should not start continued"
65 if (result_value%available) error stop "job result should not start available"
66
67 if (jobs_backend_name() /= "posix") error stop "jobs backend should report the planned POSIX-first backend"
68 end program test_scaffold
69