Skip to content

Commit 72d8cf5

Browse files
committed
fixed tests that rely on the http subsystem; also skipped tests due to the lack of some public C API.
1 parent 97d15ee commit 72d8cf5

File tree

1 file changed

+48
-43
lines changed

1 file changed

+48
-43
lines changed

t/099-c-api.t

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ __DATA__
2525
local ffi = require "ffi"
2626

2727
ffi.cdef[[
28-
void *ngx_http_lua_find_zone(char *data, size_t len);
28+
void *ngx_stream_lua_find_zone(char *data, size_t len);
2929
]]
3030

3131
local buf = ffi.new("char[?]", 4)
3232
ffi.copy(buf, "foo", 3)
33-
local zone = ffi.C.ngx_http_lua_find_zone(buf, 3)
33+
local zone = ffi.C.ngx_stream_lua_find_zone(buf, 3)
3434
ngx.say("foo zone: ", tonumber(ffi.cast("long", zone)) ~= 0 and "defined" or "undef")
3535

3636
ffi.copy(buf, "dogs", 4)
37-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
37+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
3838
ngx.say("dogs zone: ", tonumber(ffi.cast("long", zone)) ~= 0 and "defined" or "undef")
3939
}
4040
--- stream_response
@@ -67,10 +67,10 @@ dogs zone: defined
6767
ngx_str_t s; /* string */
6868
} value;
6969

70-
} ngx_http_lua_value_t;
70+
} ngx_stream_lua_value_t;
7171

72-
void *ngx_http_lua_find_zone(char *data, size_t len);
73-
intptr_t ngx_http_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_http_lua_value_t *val);
72+
void *ngx_stream_lua_find_zone(char *data, size_t len);
73+
intptr_t ngx_stream_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_stream_lua_value_t *val);
7474
]]
7575

7676
local dogs = ngx.shared.dogs
@@ -80,18 +80,18 @@ dogs zone: defined
8080
local buf = ffi.new("char[?]", 4)
8181

8282
ffi.copy(buf, "dogs", 4)
83-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
83+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
8484

85-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
85+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
8686

8787
ffi.copy(buf, "foo", 3)
88-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
88+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
8989
ngx.say("foo: rc=", tonumber(rc),
9090
", type=", val[0].type,
9191
", val=", tonumber(val[0].value.n))
9292

9393
ffi.copy(buf, "bar", 3)
94-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
94+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
9595
ngx.say("bar: rc=", tonumber(rc),
9696
", type=", val[0].type,
9797
", val=", tonumber(val[0].value.n))
@@ -101,10 +101,12 @@ foo: rc=0, type=3, val=1234567
101101
bar: rc=0, type=3, val=3.14159
102102
--- no_error_log
103103
[error]
104+
--- SKIP
104105

105106

106107

107108
=== TEST 3: boolean typed value
109+
--- SKIP
108110
--- stream_config
109111
lua_shared_dict dogs 1m;
110112
--- stream_server_config
@@ -126,10 +128,10 @@ bar: rc=0, type=3, val=3.14159
126128
ngx_str_t s; /* string */
127129
} value;
128130

129-
} ngx_http_lua_value_t;
131+
} ngx_stream_lua_value_t;
130132

131-
void *ngx_http_lua_find_zone(char *data, size_t len);
132-
intptr_t ngx_http_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_http_lua_value_t *val);
133+
void *ngx_stream_lua_find_zone(char *data, size_t len);
134+
intptr_t ngx_stream_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_stream_lua_value_t *val);
133135
]]
134136

135137
local dogs = ngx.shared.dogs
@@ -139,19 +141,19 @@ bar: rc=0, type=3, val=3.14159
139141
local buf = ffi.new("char[?]", 4)
140142

141143
ffi.copy(buf, "dogs", 4)
142-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
144+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
143145

144-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
146+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
145147

146148
ffi.copy(buf, "foo", 3)
147-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
149+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
148150
ngx.say("foo: rc=", tonumber(rc),
149151
", type=", tonumber(val[0].type),
150152
", val=", tonumber(val[0].value.b))
151153

152-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
154+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
153155
ffi.copy(buf, "bar", 3)
154-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
156+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
155157
ngx.say("bar: rc=", tonumber(rc),
156158
", type=", tonumber(val[0].type),
157159
", val=", tonumber(val[0].value.b))
@@ -186,10 +188,10 @@ bar: rc=0, type=1, val=0
186188
ngx_str_t s; /* string */
187189
} value;
188190

189-
} ngx_http_lua_value_t;
191+
} ngx_stream_lua_value_t;
190192

191-
void *ngx_http_lua_find_zone(char *data, size_t len);
192-
intptr_t ngx_http_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_http_lua_value_t *val);
193+
void *ngx_stream_lua_find_zone(char *data, size_t len);
194+
intptr_t ngx_stream_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_stream_lua_value_t *val);
193195
]]
194196

195197
local dogs = ngx.shared.dogs
@@ -198,24 +200,25 @@ bar: rc=0, type=1, val=0
198200
local buf = ffi.new("char[?]", 4)
199201

200202
ffi.copy(buf, "dogs", 4)
201-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
203+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
202204

203-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
205+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
204206

205207
ffi.copy(buf, "foo", 3)
206-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
208+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
207209
ngx.say("foo: rc=", tonumber(rc))
208210

209-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
211+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
210212
ffi.copy(buf, "bar", 3)
211-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
213+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
212214
ngx.say("bar: rc=", tonumber(rc))
213215
}
214216
--- stream_response
215217
foo: rc=-5
216218
bar: rc=-5
217219
--- no_error_log
218220
[error]
221+
--- SKIP
219222

220223

221224

@@ -241,10 +244,10 @@ bar: rc=-5
241244
ngx_str_t s; /* string */
242245
} value;
243246

244-
} ngx_http_lua_value_t;
247+
} ngx_stream_lua_value_t;
245248

246-
void *ngx_http_lua_find_zone(char *data, size_t len);
247-
intptr_t ngx_http_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_http_lua_value_t *val);
249+
void *ngx_stream_lua_find_zone(char *data, size_t len);
250+
intptr_t ngx_stream_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_stream_lua_value_t *val);
248251
]]
249252

250253
local dogs = ngx.shared.dogs
@@ -254,27 +257,27 @@ bar: rc=-5
254257
local buf = ffi.new("char[?]", 4)
255258

256259
ffi.copy(buf, "dogs", 4)
257-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
260+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
258261

259262
local s = ffi.new("char[?]", 20)
260263
261-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
264+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
262265
val[0].value.s.len = 20
263266
val[0].value.s.data = s
264267

265268
ffi.copy(buf, "foo", 3)
266-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
269+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
267270
ngx.say("foo: rc=", tonumber(rc),
268271
", type=", tonumber(val[0].type),
269272
", val=", ffi.string(val[0].value.s.data, val[0].value.s.len),
270273
", len=", tonumber(val[0].value.s.len))
271274

272-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
275+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
273276
val[0].value.s.len = 20
274277
val[0].value.s.data = s
275278

276279
ffi.copy(buf, "bar", 3)
277-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
280+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
278281
ngx.say("bar: rc=", tonumber(rc),
279282
", type=", tonumber(val[0].type),
280283
", val=", ffi.string(val[0].value.s.data, val[0].value.s.len),
@@ -285,6 +288,7 @@ foo: rc=0, type=4, val=hello world, len=11
285288
bar: rc=0, type=4, val=, len=0
286289
--- no_error_log
287290
[error]
291+
--- SKIP
288292

289293

290294

@@ -310,10 +314,10 @@ bar: rc=0, type=4, val=, len=0
310314
ngx_str_t s; /* string */
311315
} value;
312316

313-
} ngx_http_lua_value_t;
317+
} ngx_stream_lua_value_t;
314318

315-
void *ngx_http_lua_find_zone(char *data, size_t len);
316-
intptr_t ngx_http_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_http_lua_value_t *val);
319+
void *ngx_stream_lua_find_zone(char *data, size_t len);
320+
intptr_t ngx_stream_lua_shared_dict_get(void *zone, char *kdata, size_t klen, ngx_stream_lua_value_t *val);
317321
]]
318322

319323
local dogs = ngx.shared.dogs
@@ -322,18 +326,19 @@ bar: rc=0, type=4, val=, len=0
322326
local buf = ffi.new("char[?]", 4)
323327

324328
ffi.copy(buf, "dogs", 4)
325-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
329+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
326330

327-
local val = ffi.new("ngx_http_lua_value_t[?]", 1)
331+
local val = ffi.new("ngx_stream_lua_value_t[?]", 1)
328332

329333
ffi.copy(buf, "foo", 3)
330-
local rc = ffi.C.ngx_http_lua_shared_dict_get(zone, buf, 3, val)
334+
local rc = ffi.C.ngx_stream_lua_shared_dict_get(zone, buf, 3, val)
331335
ngx.say("foo: rc=", tonumber(rc))
332336
}
333337
--- stream_response
334338
foo: rc=-5
335339
--- no_error_log
336340
[error]
341+
--- SKIP
337342

338343

339344

@@ -346,16 +351,16 @@ foo: rc=-5
346351
local ffi = require "ffi"
347352

348353
ffi.cdef[[
349-
void *ngx_http_lua_find_zone(char *data, size_t len);
354+
void *ngx_stream_lua_find_zone(char *data, size_t len);
350355
]]
351356

352357
local buf = ffi.new("char[?]", 4)
353358
ffi.copy(buf, "cats", 4)
354-
local zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
359+
local zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
355360
local cats = tostring(zone)
356361

357362
ffi.copy(buf, "dogs", 4)
358-
zone = ffi.C.ngx_http_lua_find_zone(buf, 4)
363+
zone = ffi.C.ngx_stream_lua_find_zone(buf, 4)
359364
local dogs = tostring(zone)
360365

361366
ngx.say("dogs == cats ? ", dogs == cats)

0 commit comments

Comments
 (0)