Skip to content

Commit 0a71587

Browse files
yiwu0b11tblah
andauthored
update Fortran tests for execute_command_line (#137)
Co-authored-by: Tom Eccles <[email protected]> --------- Co-authored-by: Tom Eccles <[email protected]>
1 parent 14af6cc commit 0a71587

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

Fortran/UnitTests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file should only contain add_subdirectory(...) one for each test
22
add_subdirectory(hello)
33
add_subdirectory(assign-goto)
4+
add_subdirectory(execute_command_line)
45
add_subdirectory(fcvs21_f95) # NIST Fortran Compiler Validation Suite
56
add_subdirectory(finalization)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
llvm_singlesource()
2+
3+
file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config.traditional_output = True
2+
config.single_source = True

Fortran/gfortran/regression/DisabledFiles.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ file(GLOB UNIMPLEMENTED_FILES CONFIGURE_DEPENDS
331331
erf_2.F90
332332
erf_3.F90
333333

334+
# Test is not conformant as it expects different value of cmdstat and cmdmsg
335+
# Similar test added: UnitTests/execute_command_line
336+
execute_command_line_1.f90
337+
execute_command_line_3.f90
338+
334339
# unimplemented: intrinsic: failed_images
335340
coarray_failed_images_1.f08
336341

0 commit comments

Comments
 (0)