ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
test_pm_sys.F90
Go to the documentation of this file.
1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3!!!! !!!!
4!!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5!!!! !!!!
6!!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7!!!! !!!!
8!!!! This file is part of the ParaMonte library. !!!!
9!!!! !!!!
10!!!! LICENSE !!!!
11!!!! !!!!
12!!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13!!!! !!!!
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
19
21
22 use pm_sysShell
23 use pm_test, only: test_type, LK
24 implicit none
25
26 private
27 public :: setTest
28 type(test_type) :: test
29
30!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
32contains
33
34!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36 subroutine setTest()
37
38 implicit none
39
40 ! On Windows subsystem for Linux, various runtime errors arise with the following tests, in particular, with
41 ! test_SysCmd_type_1 and test_SystemInfo_type_1 with such error messages as the following:
42 !
43 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
44 !
45 ! Therefore, these tests might be only enabled for code-coverage and instrumentation purposes.
46 !
47 ! See: https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-execute-command-line-runtime-error-depends-on-memory/m-p/1168196#M145090
48
50 call test%run(test_sleep_1, SK_"test_sleep_1")
51 call test%run(test_OS_type_1, SK_"test_OS_type_1")
52 call test%run(test_OS_type_2, SK_"test_OS_type_2")
53 call test%run(test_OS_type_3, SK_"test_OS_type_3")
54 call test%run(test_copyFile_1, SK_"test_copyFile_1")
55 call test%run(test_removeFile_1, SK_"test_removeFile_1")
56 call test%run(test_removeFile_2, SK_"test_removeFile_2")
57 call test%run(test_isFailedExec_1, SK_"test_isFailedExec_1")
58 call test%run(test_isFailedExec_2, SK_"test_isFailedExec_2")
59 call test%run(test_EnvVar_type_1, SK_"test_EnvVar_type_1")
60 call test%run(test_EnvVar_type_2, SK_"test_EnvVar_type_2")
61 call test%run(test_EnvVar_type_3, SK_"test_EnvVar_type_3")
62 call test%run(test_CmdArg_type_1, SK_"test_CmdArg_type_1")
63 call test%run(test_SysCmd_type_1, SK_"test_SysCmd_type_1")
64 call test%run(test_getSysInfo_1, SK_"test_getSysInfo_1")
65 call test%run(test_SystemInfo_type_1, SK_"test_SystemInfo_type_1")
66 call test%run(test_getPathNew_1, SK_"test_getPathNew_1")
67 call test%summarize()
68
69 end subroutine setTest
70
71!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
73 function test_sleep_1() result(assertion)
74 use pm_kind, only: RK
75 use pm_err, only: err_type
76 implicit none
77 logical(LK) :: assertion
78 type(err_type) :: Err
79 call sleep(0.1_RK, Err)
80 assertion = .not. err%occurred
81 end function test_sleep_1
82
83!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84
85 function test_SystemInfo_type_1() result(assertion)
86 implicit none
87 logical(LK) :: assertion
88 type(SystemInfo_type) :: SystemInfo
89 assertion = .true._LK
90 SystemInfo = SystemInfo_type(pid = test%image%id)
91 assertion = .not. SystemInfo%err%occurred .and. allocated(SystemInfo%Records) .and. size(SystemInfo%Records) > 0
92 end function test_SystemInfo_type_1
93
94!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95
101 function test_EnvVar_type_1() result(assertion)
102
103 use pm_val2str, only: getStr
104 implicit none
105 logical(LK) :: assertion
106 type(EnvVar_type) :: EnvVar
107 assertion = .true._LK
108
109 ! No assertion evaluation below as execute_command_line() is prone to failure:
110 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
111
112 EnvVar%name = SK_""
113 call EnvVar%get(EnvVar%name,EnvVar%val,EnvVar%length,EnvVar%Err)
114 !assertion = EnvVar%err%occurred
115
116 end function test_EnvVar_type_1
117
118!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119
125 function test_EnvVar_type_2() result(assertion)
126
127 use pm_val2str, only: getStr
128 implicit none
129 logical(LK) :: assertion
130 type(EnvVar_type) :: EnvVar
131 assertion = .true._LK
132
133 ! No assertion evaluation below as execute_command_line() is prone to failure:
134 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
135
136 EnvVar%name = SK_"OS"
137 call EnvVar%get(EnvVar%name,EnvVar%val,EnvVar%length,EnvVar%Err)
138 !assertion = .not. EnvVar%err%occurred .and. allocated(EnvVar%name) .and. allocated(EnvVar%val)
139
140 !if (test%traceable .and. .not. assertion) then
141 !! LCOV_EXCL_START
142 ! write(test%disp%unit,"(2A)")
143 ! write(test%disp%unit,"(2A)") "EnvVar%name : ", EnvVar%name
144 ! write(test%disp%unit,"(2A)") "EnvVar%val : ", EnvVar%val
145 ! write(test%disp%unit,"(2A)") "EnvVar%length : ", getStr(EnvVar%length)
146 ! write(test%disp%unit,"(2A)")
147 !end if
148 !! LCOV_EXCL_STOP
149
150 end function test_EnvVar_type_2
151
152!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153
159 function test_EnvVar_type_3() result(assertion)
160
161 use pm_val2str, only: getStr
162 implicit none
163 logical(LK) :: assertion
164 type(EnvVar_type) :: EnvVar
165 assertion = .true._LK
166
167 ! No assertion evaluation below as execute_command_line() is prone to failure:
168 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
169
170 EnvVar%name = SK_"OS"
171 call EnvVar%get(EnvVar%name, EnvVar%val, Err = EnvVar%Err)
172 !assertion = .not. EnvVar%err%occurred .and. allocated(EnvVar%name) .and. allocated(EnvVar%val)
173
174 end function test_EnvVar_type_3
175
176!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177
183 function test_CmdArg_type_1() result(assertion)
184
185 use pm_val2str, only: getStr
186 implicit none
187 !integer(IK) :: i
188 logical(LK) :: assertion
189 type(CmdArg_type) :: CmdArg
190 assertion = .true._LK
191
192 ! No assertion evaluation below as execute_command_line() is prone to failure:
193 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
194
195 call CmdArg%query()
196 assertion = .not. CmdArg%err%occurred
197 call test%assert(assertion)
198
199 !if (test%traceable .and. .not. assertion) then
200 !! LCOV_EXCL_START
201 ! write(test%disp%unit,"(2A)")
202 ! write(test%disp%unit,"(2A)") "CmdArg%cmd : ", CmdArg%cmd
203 ! write(test%disp%unit,"(2A)") "CmdArg%count : ", getStr(CmdArg%count)
204 ! write(test%disp%unit, "(*('CmdArg%slash : ', 2A))") (CmdArg%Arg(i)%record, new_line('a'), i=1,CmdArg%count)
205 ! write(test%disp%unit,"(2A)")
206 !end if
207 !! LCOV_EXCL_STOP
208
209 end function test_CmdArg_type_1
210
211!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212
218 function test_OS_type_1() result(assertion)
219
220 use pm_val2str, only: getStr
221 implicit none
222 logical(LK) :: assertion
223 type(OS_type) :: OS
224
225 assertion = .true._LK
226
227!#if CODECOV_ENABLED
228 mv_osCacheActivated = .false._LK
229 mc_shellCached = .false._LK
230!#endif
231
232 ! No assertion evaluation below as execute_command_line() is prone to failure:
233 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
234
235 call OS%query()
236 !assertion = .not. OS%err%occurred .and. .not. OS%shell%err%occurred
237 !if (.not. assertion) return
238
239 !if (test%traceable .and. .not. assertion) then
240 !! LCOV_EXCL_START
241 ! write(test%disp%unit,"(2A)")
242 ! write(test%disp%unit,"(2A)") "OS%name : ", OS%name
243 ! write(test%disp%unit,"(2A)") "OS%slash : ", OS%slash
244 ! write(test%disp%unit,"(2A)") "OS%isWindows: ", getStr(OS%isWindows)
245 ! write(test%disp%unit,"(2A)")
246 !end if
247 !! LCOV_EXCL_STOP
248
249 end function test_OS_type_1
250
251!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252
258 function test_OS_type_2() result(assertion)
259
260 use pm_val2str, only: getStr
261 use pm_strASCII, only: getStrLower
262 implicit none
263 logical(LK) :: assertion
264 type(OS_type) :: OS
265
266 assertion = .true._LK
267
268!#if CODECOV_ENABLED
269 mv_osCacheActivated = .false._LK
270 mc_shellCached = .false._LK
271#endif
272
273 ! No assertion evaluation below as execute_command_line() is prone to failure:
274 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
275
276 call OS%shell%query()
277 call shell_typer(OS%Shell)
278 !assertion = assertion .and. .not. OS%shell%err%occurred
279
280 !if (test%traceable .and. .not. assertion) then
281 !! LCOV_EXCL_START
282 ! write(test%disp%unit,"(2A)")
283 ! write(test%disp%unit,"(2A)") "OS%name : ", OS%name
284 ! write(test%disp%unit,"(2A)") "OS%slash : ", OS%slash
285 ! write(test%disp%unit,"(2A)") "OS%isWindows : ", getStr(OS%isWindows)
286 ! write(test%disp%unit,"(2A)") "OS%shell%name : ", OS%shell%name
287 ! write(test%disp%unit,"(2A)") "OS%shell%slash : ", OS%shell%slash
288 ! write(test%disp%unit,"(2A)") "OS%shell%is%posix : ", getStr(OS%shell%is%posix)
289 ! write(test%disp%unit,"(2A)")
290 !end if
291 !! LCOV_EXCL_STOP
292
293 ! No assertion evaluation below as execute_command_line() is prone to failure:
294 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
295
296 call OS%query()
297 !assertion = assertion .and. .not. OS%err%occurred .and. .not. OS%shell%err%occurred
298
299 !if (test%traceable .and. .not. assertion) then
300 !! LCOV_EXCL_START
301 ! write(test%disp%unit,"(2A)")
302 ! write(test%disp%unit,"(2A)") "OS%name : ", OS%name
303 ! write(test%disp%unit,"(2A)") "OS%slash : ", OS%slash
304 ! write(test%disp%unit,"(2A)") "OS%isWindows : ", getStr(OS%isWindows)
305 ! write(test%disp%unit,"(2A)") "OS%shell%name : ", OS%shell%name
306 ! write(test%disp%unit,"(2A)") "OS%shell%slash : ", OS%shell%slash
307 ! write(test%disp%unit,"(2A)") "OS%shell%is%posix : ", getStr(OS%shell%is%posix)
308 ! write(test%disp%unit,"(2A)")
309 !end if
310 ! LCOV_EXCL_STOP
311
312 end function test_OS_type_2
313
314!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315
322 function test_OS_type_3() result(assertion)
323
324 use pm_val2str, only: getStr
325 use pm_strASCII, only: getStrLower
326 implicit none
327 logical(LK) :: assertion
328 type(OS_type) :: OS
329
330 assertion = .true._LK
331
332!#if CODECOV_ENABLED
333 mv_osCacheActivated = .false._LK
334 mc_shellCached = .false._LK
335#endif
336
337 ! No assertion evaluation below as execute_command_line() is prone to failure:
338 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
339
340 call OS%query(shellQueryEnabled = .false._LK)
341 !assertion = assertion .and. .not. OS%shell%err%occurred
342
343 !if (test%traceable .and. .not. assertion) then
344 !! LCOV_EXCL_START
345 ! write(test%disp%unit,"(2A)")
346 ! write(test%disp%unit,"(2A)") "OS%name : ", OS%name
347 ! write(test%disp%unit,"(2A)") "OS%slash : ", OS%slash
348 ! write(test%disp%unit,"(2A)") "OS%isWindows : ", getStr(OS%isWindows)
349 ! write(test%disp%unit,"(2A)") "OS%shell%name : ", OS%shell%name
350 ! write(test%disp%unit,"(2A)") "OS%shell%slash : ", OS%shell%slash
351 ! write(test%disp%unit,"(2A)") "OS%shell%is%posix : ", getStr(OS%shell%is%posix)
352 ! write(test%disp%unit,"(2A)")
353 !end if
354 !! LCOV_EXCL_STOP
355
356 ! No assertion evaluation below as execute_command_line() is prone to failure:
357 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
358
359 call OS%query(shellQueryEnabled = .true._LK)
360 !assertion = assertion .and. .not. OS%err%occurred .and. .not. OS%shell%err%occurred
361
362 !if (test%traceable .and. .not. assertion) then
363 !! LCOV_EXCL_START
364 ! write(test%disp%unit,"(2A)")
365 ! write(test%disp%unit,"(2A)") "OS%name : ", OS%name
366 ! write(test%disp%unit,"(2A)") "OS%slash : ", OS%slash
367 ! write(test%disp%unit,"(2A)") "OS%isWindows : ", getStr(OS%isWindows)
368 ! write(test%disp%unit,"(2A)") "OS%shell%name : ", OS%shell%name
369 ! write(test%disp%unit,"(2A)") "OS%shell%slash : ", OS%shell%slash
370 ! write(test%disp%unit,"(2A)") "OS%shell%is%posix : ", getStr(OS%shell%is%posix)
371 ! write(test%disp%unit,"(2A)")
372 !end if
373 ! LCOV_EXCL_STOP
374
375 end function test_OS_type_3
376
377!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378
384 function test_SysCmd_type_1() result(assertion)
385
386 use pm_val2str, only: getStr
387 implicit none
388 logical(LK) :: assertion
389 type(SysCmd_type) :: SysCmd
390 type(OS_type) :: OS
391
392 call OS%query()
393 assertion = .not. OS%err%occurred
394 call test%assert(assertion)
395
396 ! No assertion evaluation below as execute_command_line() is prone to failure:
397 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
398 ! The `Err` argument handles exceptions.
399
400#if WINDOWS_ENABLED
401 if (OS%shell%is%cmd .or. OS%shell%is%powershell) then
402 SysCmd = SysCmd_type("dir > nul 2>&1", .true._LK)
403 !assertion = .not. SysCmd%err%occurred
404 !if (.not. assertion) return
405 SysCmd = SysCmd_type("dir > nul 2>&1", .false._LK)
406 !assertion = .not. SysCmd%err%occurred
407 !if (.not. assertion) return
408 end if
409#endif
410 if (OS%shell%is%posix) then
411 SysCmd = SysCmd_type("ls >/dev/null 2>&1", .true._LK)
412 !assertion = .not. SysCmd%err%occurred
413 !if (.not. assertion) return
414 SysCmd = SysCmd_type("ls >/dev/null 2>&1", .false._LK)
415 !assertion = .not. SysCmd%err%occurred
416 !if (.not. assertion) return
417 end if
418
419 end function test_SysCmd_type_1
420
421!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422
428 function test_isFailedExec_1() result(assertion)
429
430 use pm_val2str, only: getStr
431 implicit none
432 logical(LK) :: assertion
433 type(OS_type) :: OS
434 integer(IK) :: exitstat
435 logical(LK) , parameter :: wait = .true._LK
436 character(:, SK), allocatable :: command
437
438 call OS%query()
439 assertion = .not. OS%err%occurred
440 call test%assert(assertion)
441
442#if WINDOWS_ENABLED
443 if (OS%shell%is%cmd .or. OS%shell%is%powershell) then
444 command = "dir > nul 2>&1"
445 end if
446#endif
447 if (OS%shell%is%posix) then
448 command = "ls >/dev/null 2>&1"
449 end if
450
451 ! No assertion evaluation here as execute_command_line() is prone to failure:
452 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
453 ! The `Err` argument handles exceptions.
454
455 call isFailedExec(command,wait,exitstat,OS%Err)
456 !assertion = .not. OS%err%occurred
457 !if (.not. assertion) return
458
459 end function test_isFailedExec_1
460
461!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462
468 function test_isFailedExec_2() result(assertion)
469
470 use pm_val2str, only: getStr
471 implicit none
472 logical(LK) :: assertion
473 type(OS_type) :: OS
474 character(:, SK), allocatable :: command
475
476 call OS%query()
477 assertion = .not. OS%err%occurred
478 call test%assert(assertion)
479
480#if WINDOWS_ENABLED
481 if (OS%shell%is%cmd .or. OS%shell%is%powershell) then
482 command = "dir > nul 2>&1"
483 end if
484#endif
485 if (OS%shell%is%posix) then
486 command = "ls >/dev/null 2>&1"
487 end if
488
489 ! No assertion evaluation here as execute_command_line() is prone to failure:
490 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
491 ! The `Err` argument handles exceptions.
492
493 call isFailedExec(command, Err = OS%Err)
494
495 end function test_isFailedExec_2
496
497!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
498
499 function test_getPathNew_1() result(assertion)
500
501 use pm_val2str, only: getStr
502 implicit none
503 logical(LK) :: assertion
504 character(:, SK), allocatable :: newpath
505 logical(LK) :: fileExists
506
507 newpath = getPathNew(prefix = SK_"test_getPathNew", failed = assertion)
508 assertion = .not. assertion
509 call test%assert(assertion)
510
511 inquire(file = newpath, exist = fileExists)
512 assertion = assertion .and. .not. fileExists
513
514 if (test%traceable .and. .not. assertion) then
515 ! LCOV_EXCL_START
516 write(test%disp%unit,"(2A)")
517 write(test%disp%unit,"(2A)") "newpath : ", newpath
518 ! LCOV_EXCL_STOP
519 end if
520
521 end function test_getPathNew_1
522
523!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
524
525 function test_removeFile_1() result(assertion)
526
527 use pm_val2str, only: getStr
528 implicit none
529 logical(LK) :: assertion
530 character(:, SK), allocatable :: newpath
531 logical(LK) :: fileExists
532 integer(IK) :: fileUnit
533
534 newpath = getPathNew(prefix = SK_"test_getPathNew", failed = assertion)
535 assertion = .not. assertion
536 call test%assert(assertion)
537
538 open(newunit=fileUnit,file=newpath,status="new")
539 close(fileUnit)
540
541 call removeFile(path = newpath, Err = test%Err)
542 assertion = assertion .and. .not. Tes%err%occurred
543 call test%assert(assertion)
544
545 inquire(file=newpath,exist=fileExists)
546 assertion = assertion .and. .not. fileExists
547
548 end function test_removeFile_1
549
550!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
551
552 function test_removeFile_2() result(assertion)
553
554 use pm_kind, only: RK
555 use pm_val2str, only: getStr
556 logical(LK) :: assertion
557 character(:, SK), allocatable :: newpath
558 logical(LK) :: fileExists
559 integer(IK) :: fileUnit
560
561 newpath = getPathNew(prefix = SK_"test_getPathNew", failed = assertion)
562 assertion = .not. assertion
563 call test%assert(assertion)
564
565 open(newunit=fileUnit,file=newpath,status="new")
566 close(fileUnit)
567
568 call removeFile(path=newpath)
569 inquire(file=newpath,exist=fileExists)
570 assertion = assertion .and. .not. fileExists
571
572 end function test_removeFile_2
573
574!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
575
581 function test_getSysInfo_1() result(assertion)
582
583 use pm_container, only: css_pdt
584 use pm_err, only: err_type
585 implicit none
586 logical(LK) :: assertion
587 type(css_pdt) , allocatable :: List(:)
588 type(err_type) :: Err
589
590 assertion = .true._LK
591
592 ! No assertion evaluation here as execute_command_line() is prone to failure:
593 ! Fortran runtime error: EXECUTE_COMMAND_LINE: Termination status of the command-language interpreter cannot be obtained
594 ! The `Err` argument handles exceptions.
595
596 call getSysInfo(List,Err)
597 !assertion = .not. err%occurred
598
599 end function test_getSysInfo_1
600
601!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602
603 function test_copyFile_1() result(assertion)
604
605 use pm_kind, only: RK
606 implicit none
607 logical(LK) :: assertion
608 character(:, SK), allocatable :: newpath
609 type(OS_type) :: OS
610 logical(LK) :: fileExists
611 integer(IK) :: fileUnit
612
613 newpath = getPathNew(prefix = SK_"test_getPathNew", failed = assertion)
614 assertion = .not. assertion
615 call test%assert(assertion)
616
617 open(newunit=fileUnit,file=newpath,status="new")
618 close(fileUnit)
619
620 call OS%query()
621 assertion = .not. OS%err%occurred
622 call test%assert(assertion)
623
624 assertion = .not. isFailedCopy(newpath, newpath//".copy")
625 call test%assert(assertion)
626
627 inquire(file=newpath//".copy",exist=fileExists)
628 assertion = assertion .and. fileExists
629
630 call removeFile(newpath)
631 inquire(file=newpath,exist=fileExists)
632 assertion = assertion .and. .not. fileExists
633
634 call removeFile(newpath//".copy")
635 inquire(file=newpath//".copy",exist=fileExists)
636 assertion = assertion .and. .not. fileExists
637
638 end function test_copyFile_1
639
640!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
641
642end module test_pm_sys ! LCOV_EXCL_LINE
Generate and return the input string where the uppercase English alphabets are all converted to lower...
Generate and return failed = .false. if the attempt to run the requested shell command is successful....
Generate and return the conversion of the input value to an output Fortran string,...
Definition: pm_val2str.F90:167
This module contains the derived types for generating allocatable containers of scalar,...
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains the uncommon and hardly representable ASCII characters as well as procedures for...
Definition: pm_strASCII.F90:61
This module contains procedures and generic interfaces for inferring the runtime system shell type an...
Definition: pm_sysShell.F90:38
character(*, SK), parameter MODULE_NAME
Definition: pm_sysShell.F90:44
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
This module contains tests of the module pm_sysShell.
Definition: test_pm_sys.F90:20
logical(LK) function test_isFailedExec_2()
Test the success of a SysCmd action.
logical(LK) function test_CmdArg_type_1()
Test whether input command line arguments can be successfully retrieved.
logical(LK) function test_EnvVar_type_2()
Test whether environmental variables can be successfully queried.
logical(LK) function test_removeFile_2()
subroutine setTest()
Definition: test_pm_sys.F90:37
logical(LK) function test_getSysInfo_1()
Obtain the system info without providing the cachefile name, in which case, no cache file will be gen...
logical(LK) function test_getPathNew_1()
logical(LK) function test_removeFile_1()
logical(LK) function test_SysCmd_type_1()
Test the success of a SysCmd action.
logical(LK) function test_OS_type_1()
Query Shell first and then OS to ensure caching the Shell query results work correctly.
type(test_type) test
Definition: test_pm_sys.F90:28
logical(LK) function test_isFailedExec_1()
Test the success of a SysCmd action.
logical(LK) function test_copyFile_1()
logical(LK) function test_OS_type_2()
Query Shell first and then OS to ensure caching the Shell query results work correctly.
logical(LK) function test_SystemInfo_type_1()
Definition: test_pm_sys.F90:86
logical(LK) function test_OS_type_3()
Query OS first without shell query and then query OS with shell. This will test the remaining uncover...
logical(LK) function test_EnvVar_type_3()
Test whether environmental variables can be successfully queried.
logical(LK) function test_sleep_1()
Definition: test_pm_sys.F90:74
logical(LK) function test_EnvVar_type_1()
Test whether environmental variables can be successfully queried.
This is the css_pdt parameterized type for generating instances of container of scalar of string obje...
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
Definition: pm_err.F90:157
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209