| 1 |
program test_validation |
| 2 |
use fgof_process, only : & |
| 3 |
FGOF_PROCESS_ERR_INVALID_COMMAND, & |
| 4 |
FGOF_PROCESS_ERR_INVALID_OPTION, & |
| 5 |
FGOF_PROCESS_MODE_ARGV, & |
| 6 |
process_command, & |
| 7 |
process_options, & |
| 8 |
process_result, & |
| 9 |
run, & |
| 10 |
shell |
| 11 |
implicit none |
| 12 |
|
| 13 |
type(process_command) :: argv_cmd |
| 14 |
type(process_command) :: shell_cmd |
| 15 |
type(process_options) :: opts |
| 16 |
type(process_result) :: res |
| 17 |
|
| 18 |
argv_cmd%mode = FGOF_PROCESS_MODE_ARGV |
| 19 |
argv_cmd%program = "" |
| 20 |
allocate(character(len=1) :: argv_cmd%argv(0)) |
| 21 |
|
| 22 |
res = run(argv_cmd) |
| 23 |
if (res%error_code /= FGOF_PROCESS_ERR_INVALID_COMMAND) error stop "empty argv command should be invalid" |
| 24 |
|
| 25 |
shell_cmd = shell("") |
| 26 |
res = run(shell_cmd) |
| 27 |
if (res%error_code /= FGOF_PROCESS_ERR_INVALID_COMMAND) error stop "empty shell command should be invalid" |
| 28 |
|
| 29 |
shell_cmd = shell("printf 'ok'") |
| 30 |
opts%timeout_ms = -1 |
| 31 |
res = run(shell_cmd, opts) |
| 32 |
if (res%error_code /= FGOF_PROCESS_ERR_INVALID_OPTION) error stop "negative timeout should be invalid" |
| 33 |
end program test_validation |
| 34 |
|