|
| 1 | + integer :: i, j |
| 2 | + character(len=100) :: msg |
| 3 | + character(len=:), allocatable :: command |
| 4 | + command='notthere' |
| 5 | + |
| 6 | + msg = "" |
| 7 | + |
| 8 | + call execute_command_line ("ls *.f90") |
| 9 | + |
| 10 | + print *, "-----------------------------" |
| 11 | + |
| 12 | + call execute_command_line ("sleep 1 ; ls *.f90", .false.) |
| 13 | + print *, "I'm not waiting" |
| 14 | + call sleep(2) |
| 15 | + |
| 16 | + print *, "-----------------------------" |
| 17 | + |
| 18 | + call execute_command_line ("sleep 1 ; ls *.f90", .true.) |
| 19 | + print *, "I did wait" |
| 20 | + call sleep(2) |
| 21 | + |
| 22 | + print *, "-----------------------------" |
| 23 | + |
| 24 | + call execute_command_line ("ls *.f90", .true., i) |
| 25 | + print *, "Exist status was: ", i |
| 26 | + |
| 27 | + print *, "-----------------------------" |
| 28 | + |
| 29 | + call execute_command_line ("echo foo", .true., i, j) |
| 30 | + print *, "Exist status was: ", i |
| 31 | + print *, "Command status was: ", j |
| 32 | + |
| 33 | + print *, "-----------------------------" |
| 34 | + |
| 35 | + call execute_command_line ("echo foo", .true., i, j, msg) |
| 36 | + print *, "Exist status was: ", i |
| 37 | + print *, "Command status was: ", j |
| 38 | + print *, "Error message is: ", trim(msg) |
| 39 | + |
| 40 | + print *, "-----------------------------" |
| 41 | + |
| 42 | + call execute_command_line ("ls *.doesnotexist", .true., i, j, msg) |
| 43 | + print *, "Exist status was: ", i |
| 44 | + print *, "Command status was: ", j |
| 45 | + print *, "Error message is: ", trim(msg) |
| 46 | + |
| 47 | + print *, "-----------------------------" |
| 48 | + |
| 49 | + print *, "-------------Sync------------" |
| 50 | + msg = '' |
| 51 | + call execute_command_line("notthere", exitstat=i, cmdstat=j, cmdmsg=msg) |
| 52 | + if (j /= 5 .or. msg /= "Command not found with exit code: 127." ) STOP 1 |
| 53 | + call execute_command_line("cat GeneralErrorCommand", exitstat=i, cmdstat=j, cmdmsg=msg) |
| 54 | + if (j /= 3 .or. msg /= "Command line execution failed with exit code: 1." ) STOP 2 |
| 55 | + msg = "remaining buffer not modified XXXXXXXXXXXXXXXXXXX" |
| 56 | + call execute_command_line("touch NotExecutedCommandFile && chmod -x NotExecutedCommandFile && ./NotExecutedCommandFile", exitstat=i, cmdstat=j, cmdmsg=msg) |
| 57 | + if (j /= 4 .or. msg /= "Command cannot be executed with exit code: 126.XX" ) STOP 3 |
| 58 | + msg = '' |
| 59 | + call execute_command_line("notthere", exitstat=i, cmdstat=j ) |
| 60 | + if (j /= 5 .or. msg /= '' ) STOP 4 |
| 61 | + |
| 62 | + print *, "------------Async------------" |
| 63 | + msg = '' |
| 64 | + call execute_command_line("notthere", wait=.false., exitstat=i, cmdstat=j, cmdmsg=msg) |
| 65 | + if (j /= 0 .or. msg /= '') STOP 5 |
| 66 | + j = 123 |
| 67 | + call execute_command_line("notthere", wait=.false., exitstat=i, cmdmsg=msg) |
| 68 | + if (j /= 123 .or. msg /= '') STOP 6 |
| 69 | + call execute_command_line("notthere", wait=.false., exitstat=i, cmdstat=j ) |
| 70 | + if (j /= 0 .or. msg /= '') STOP 7 |
| 71 | + call execute_command_line("notthere", wait=.false., exitstat=i ) |
| 72 | + if (j /= 0 .or. msg /= '') STOP 8 |
| 73 | + |
| 74 | + |
| 75 | + end |
0 commit comments