Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test
  • Loading branch information
perazz committed Mar 7, 2025
commit 103cf9b79f7529090a913b8f9909da5aa2ecbc8e
25 changes: 23 additions & 2 deletions test/system/test_os.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module test_os
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
use stdlib_system, only: get_runtime_os, OS_WINDOWS, OS_UNKNOWN, OS_TYPE, is_windows
use stdlib_system, only: get_runtime_os, OS_WINDOWS, OS_UNKNOWN, OS_TYPE, is_windows, null_device

implicit none

Expand All @@ -13,7 +13,8 @@ subroutine collect_suite(testsuite)

testsuite = [ &
new_unittest('test_get_runtime_os', test_get_runtime_os), &
new_unittest('test_is_windows', test_is_windows) &
new_unittest('test_is_windows', test_is_windows), &
new_unittest('test_null_device', test_null_device) &
]
end subroutine collect_suite

Expand All @@ -38,6 +39,26 @@ subroutine test_is_windows(error)

end subroutine test_is_windows

!> Test that the null_device is valid by writing something to it
subroutine test_null_device(error)
type(error_type), allocatable, intent(out) :: error
integer :: unit, ios
character(len=512) :: iomsg

! Try opening the null device for writing
open(newunit=unit, file=null_device(), status='old', action='write', iostat=ios, iomsg=iomsg)
call check(error, ios==0, 'Cannot open null_device unit: '//trim(iomsg))
if (allocated(error)) return

write(unit, *, iostat=ios, iomsg=iomsg) 'Hello, World!'
call check(error, ios==0, 'Cannot write to null_device unit: '//trim(iomsg))
if (allocated(error)) return

close(unit, iostat=ios, iomsg=iomsg)
call check(error, ios==0, 'Cannot close null_device unit: '//trim(iomsg))
if (allocated(error)) return

end subroutine test_null_device

end module test_os

Expand Down