Skip to content

update Fortran tests for execute_command_line #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Fortran/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file should only contain add_subdirectory(...) one for each test
add_subdirectory(hello)
add_subdirectory(assign-goto)
add_subdirectory(execute_command_line)
add_subdirectory(fcvs21_f95) # NIST Fortran Compiler Validation Suite
add_subdirectory(finalization)
3 changes: 3 additions & 0 deletions Fortran/UnitTests/execute_command_line/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
llvm_singlesource()

file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
75 changes: 75 additions & 0 deletions Fortran/UnitTests/execute_command_line/execute_command_line.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
integer :: i, j
character(len=100) :: msg
character(len=:), allocatable :: command
command='notthere'

msg = ""

call execute_command_line ("ls *.f90")

print *, "-----------------------------"

call execute_command_line ("sleep 1 ; ls *.f90", .false.)
print *, "I'm not waiting"
call sleep(2)

print *, "-----------------------------"

call execute_command_line ("sleep 1 ; ls *.f90", .true.)
print *, "I did wait"
call sleep(2)

print *, "-----------------------------"

call execute_command_line ("ls *.f90", .true., i)
print *, "Exist status was: ", i

print *, "-----------------------------"

call execute_command_line ("echo foo", .true., i, j)
print *, "Exist status was: ", i
print *, "Command status was: ", j

print *, "-----------------------------"

call execute_command_line ("echo foo", .true., i, j, msg)
print *, "Exist status was: ", i
print *, "Command status was: ", j
print *, "Error message is: ", trim(msg)

print *, "-----------------------------"

call execute_command_line ("ls *.doesnotexist", .true., i, j, msg)
print *, "Exist status was: ", i
print *, "Command status was: ", j
print *, "Error message is: ", trim(msg)

print *, "-----------------------------"

print *, "-------------Sync------------"
msg = ''
call execute_command_line("notthere", exitstat=i, cmdstat=j, cmdmsg=msg)
if (j /= 5 .or. msg /= "Command not found with exit code: 127." ) STOP 1
call execute_command_line("cat GeneralErrorCommand", exitstat=i, cmdstat=j, cmdmsg=msg)
if (j /= 3 .or. msg /= "Command line execution failed with exit code: 1." ) STOP 2
msg = "remaining buffer not modified XXXXXXXXXXXXXXXXXXX"
call execute_command_line("touch NotExecutedCommandFile && chmod -x NotExecutedCommandFile && ./NotExecutedCommandFile", exitstat=i, cmdstat=j, cmdmsg=msg)
if (j /= 4 .or. msg /= "Command cannot be executed with exit code: 126.XX" ) STOP 3
msg = ''
call execute_command_line("notthere", exitstat=i, cmdstat=j )
if (j /= 5 .or. msg /= '' ) STOP 4

print *, "------------Async------------"
msg = ''
call execute_command_line("notthere", wait=.false., exitstat=i, cmdstat=j, cmdmsg=msg)
if (j /= 0 .or. msg /= '') STOP 5
j = 123
call execute_command_line("notthere", wait=.false., exitstat=i, cmdmsg=msg)
if (j /= 123 .or. msg /= '') STOP 6
call execute_command_line("notthere", wait=.false., exitstat=i, cmdstat=j )
if (j /= 0 .or. msg /= '') STOP 7
call execute_command_line("notthere", wait=.false., exitstat=i )
if (j /= 0 .or. msg /= '') STOP 8


end
2 changes: 2 additions & 0 deletions Fortran/UnitTests/execute_command_line/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.traditional_output = True
config.single_source = True
5 changes: 5 additions & 0 deletions Fortran/gfortran/regression/DisabledFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
erf_2.F90
erf_3.F90

# Test is not conformant as it expects different value of cmdstat and cmdmsg
# Similar test added: UnitTests/execute_command_line
execute_command_line_1.f90
execute_command_line_3.f90

# unimplemented: intrinsic: failed_images
coarray_failed_images_1.f08

Expand Down