1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
;
; Under GNU GPL V3 or later
;
; https://github.com/gnudatalanguage/gdl/issues/1709
; AC 2024-Jan-05
;
; Several bugs related to FILE_READLINK() found,
; https://github.com/gnudatalanguage/gdl/issues/1709
;
; ---------------------------------
;
; Modifications history :
;
; - 2024-01-05 : AC. creation. Ideas welcome since I don't have
; MSwin and *BSD around ...
;
; ---------------------------------
;
pro TEST_BSD_READLINK, cumul_errors, test=test
;
nb_errors=0
;
MESSAGE, /continue, "No idea for tests under *BSD. Please contribute"
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, 'TEST_BSD_READLINK', nb_errors, /short
ERRORS_CUMUL, cumul_errors, nb_errors
if KEYWORD_set(test) then STOP
;
end
;
; ---------------------------------
;
pro TEST_MSWIN_READLINK, cumul_errors, test=test
;
nb_errors=0
;
MESSAGE, /continue, "No idea for tests under MSwin. Please contribute"
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, 'TEST_MSWIN_READLINK', nb_errors, /short
ERRORS_CUMUL, cumul_errors, nb_errors
if KEYWORD_set(test) then STOP
;
end
;
; ---------------------------------
;
pro TEST_OSX_READLINK, cumul_errors, test=test
;
nb_errors=0
;
expected='private/etc'
res=FILE_READLINK('/etc')
mess= "error for /etc vs private/etc"
if (expected NE res) then ERRORS_ADD, nb_errors, mess
;
expected='/var/db/timezone/zoneinfo/'
res=FILE_READLINK('/etc/localtime')
res=STRMID(res,0,26)
mess="error for localtime vs timezone"
if (expected NE res) then ERRORS_ADD, nb_errors, mess
;
expected='/System/Volumes/Data/home'
res=FILE_READLINK('/home')
mess="error for /home vs Volume ..."
if (expected NE res) then ERRORS_ADD, nb_errors, mess
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, 'TEST_OSX_READLINK', nb_errors, /short
ERRORS_CUMUL, cumul_errors, nb_errors
if KEYWORD_set(test) then STOP
;
end
;
; ---------------------------------
;
pro TEST_LINUX_READLINK, cumul_errors, test=test
;
nb_errors=0
;
; see discussion in issue #1706
if FILE_TEST('/proc/sys/kernel/pid_max') then begin
GET_LUN, nlun
OPENR, nlun, '/proc/sys/kernel/pid_max'
pid_max=0L
;; temporary using a format ... see #1712 :(
READF, nlun, pid_max, format='(i)'
CLOSE, nlun
FREE_LUN, nlun
endif else begin
print, "assuming old Linux system ..."
pid_max=32767
endelse
pid_min=2 ; (0 scheduler, 1 init)
;
pid=FILE_READLINK('/proc/self')
; when the conversion cannot be done, result is "0"
pid=LONG(pid)
mess= "error for /proc/self"
if (pid LT pid_min) or (pid GT pid_max) then ERRORS_ADD, nb_errors, mess
;
expected='/usr/share/zoneinfo/'
res=FILE_READLINK('/etc/localtime')
res=STRMID(res,0,20)
mess="error for localtime vs timezone"
if (expected NE res) then ERRORS_ADD, nb_errors, mess
;
expected='share/man'
res=FILE_READLINK('/usr/local/man')
mess="error for man pages ... not sure it is portable"
if (expected NE res) then ERRORS_ADD, nb_errors, mess
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, 'TEST_LINUX_READLINK', nb_errors, /short
ERRORS_CUMUL, cumul_errors, nb_errors
if KEYWORD_set(test) then STOP
;
end
;
; ---------------------------------
;
pro TEST_FILE_READLINK, help=help, test=test, no_exit=no_exit, verbose=verbose
;
if KEYWORD_SET(help) then begin
print, 'pro TEST_FILE_READLINK, help=help, test=test, $'
print, ' no_exit=no_exit, verbose=verbose'
return
endif
;
cumul_errors=0
;
; specific tests for OSX
;
if (!version.os EQ STRLOWCASE('darwin')) then begin
TEST_OSX_READLINK, cumul_errors, test=test
endif
;
; specific tests for Linux
;
if (!version.os EQ STRLOWCASE('linux')) then begin
TEST_LINUX_READLINK, cumul_errors, test=test
endif
;
; specific tests for MSwin
;
if (!version.os EQ STRLOWCASE('window')) then begin
TEST_MSWIN_READLINK, cumul_errors, test=test
endif
;
; specific tests for *BSD systems
;
if (STRPOS(STRlowCASE(!version.os), 'bsd') GE 0) then begin
TEST_BSD_READLINK, cumul_errors, test=test
endif
;
; ----------------- final message ----------
;
BANNER_FOR_TESTSUITE, 'TEST_FILE_READLINK', cumul_errors
;
if (cumul_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1
;
if KEYWORD_SET(test) then STOP
;
end
|