-
Notifications
You must be signed in to change notification settings - Fork 3
/
test-callout.xml
126 lines (115 loc) · 3.56 KB
/
test-callout.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for UNIX (Apple Mac OS X for x86-64) 2012.1 (Build 564U)" ts="2012-05-22 15:41:58">
<Class name="com.intersystems.CalloutTestCase">
<TimeChanged>62599,56250.628168</TimeChanged>
<TimeCreated>62575,69373.365076</TimeCreated>
<Method name="newString">
<ClassMethod>1</ClassMethod>
<FormalSpec>length:%Integer</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
#dim s as %String = ""
#dim i as %Integer
f i = 1:1:length {
s s = s _ "A"
}
q s
]]></Implementation>
</Method>
<Method name="FindStringLengthLimit">
<ClassMethod>1</ClassMethod>
<FormalSpec>fileName:%String,function:%String</FormalSpec>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[
#dim dllId as %Integer
#dim funcId as %Integer
#dim e as %Exception.SystemException
if (##class(%File).Exists(fileName)) {
s dllId = $zf(-4, 1, fileName)
s funcId = $zf(-4, 3, dllId, function)
#dim length as %Integer
#dim j as %Integer = 32767 ; CACHE_MAXSTRLEN
try {
f {
s length = $zf(-5, dllId, funcId, ..newString(j))
i (length '= j) {
; For ZWARRAYP, maximum length is 65535 (unsigned short).
; From Cache perspective, a "rollover" of ZWARRAYP->len will occur.
s j = j - 1 ; decrement j
s length = j ; revert length from 0 to the previous value
q ; quit the for-loop
}
s j = $i(j)
}
} catch (e) {
if ($p($p($ze, ">", 1), "<", 2) '= "OUT OF $ZF HEAP SPACE") {
w e.DisplayString(), !
w $zu(56, 2), !
} else {
s j = j - 1 ; decrement j
}
}
w "Maximum string length for ", function, "() is ", length, !
q length
} else {
w fileName, ": no such file or directory", !
q 0
}
]]></Implementation>
</Method>
<Method name="TestStringLengthSupported">
<ClassMethod>1</ClassMethod>
<FormalSpec>fileName:%String,function:%String,length:%Integer</FormalSpec>
<ReturnType>%Boolean</ReturnType>
<Implementation><![CDATA[
#dim dllId as %Integer
#dim funcId as %Integer
if (##class(%File).Exists(fileName)) {
s dllId = $zf(-4, 1, fileName)
try {
s funcId = $zf(-4, 3, dllId, function)
} catch {
w $ze, !
w $zu(56, 2), !
}
#dim lengthReturned as %Integer = 0
try {
s lengthReturned = $zf(-5, dllId, funcId, ..newString(length))
} catch {
w $ze, !
w $zu(56, 2), !
}
; return true if lengthReturned == j, false otherwise
q $select(lengthReturned = length: 1, 1: 0)
} else {
w fileName, ": no such file or directory", !
q 0
}
]]></Implementation>
</Method>
<Method name="Main">
<ClassMethod>1</ClassMethod>
<Implementation><![CDATA[
#dim dir as %String = "."
#dim bundle as %String = dir _ "/" _ "libtest-callout.bundle"
#dim dylib as %String = dir _ "/" _ "libtest-callout.dylib"
d ..FindStringLengthLimit(bundle, "strlen")
d ..FindStringLengthLimit(dylib, "strlen")
d ..FindStringLengthLimit(dylib, "strlen_w")
d ..FindStringLengthLimit(dylib, "strlen_s")
#dim length as %Integer = 3641144 ; CACHE_MAXLOSTSZ
; Regular strings
w ..TestStringLengthSupported(dylib, "strlen", length), !
w ..TestStringLengthSupported(dylib, "strlen_w", length), !
w ..TestStringLengthSupported(dylib, "strlen_s", length), !
; Long strings
w ..TestStringLengthSupported(dylib, "strlen_j", length), !
; This one (DTLSTR) triggers a <SYSTEM> error at
; $Id: //dev/2012.1.0/kernel/common/src/lost.c#1 $ 259 2
;;w ..TestStringLengthSupported(dylib, "strlen_m", length), !
w ..TestStringLengthSupported(dylib, "strlen_n", length), !
w ..TestStringLengthSupported(dylib, "strlen_r", length), !
]]></Implementation>
</Method>
</Class>
</Export>