Skip to content

Commit f50b6d6

Browse files
committed
Adjust tests
1 parent a0ef6b7 commit f50b6d6

File tree

9 files changed

+55
-58
lines changed

9 files changed

+55
-58
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ jobs:
4949
./opencl-installer.exe --s --x --f ocl
5050
cp "./ocl/w_opencl_runtime_p_2025.1.0.972.msi" "./opencl-rt.msi"
5151
touch install.log
52-
# echo "Start Msiexec"
53-
# msiexec /i "opencl-rt.msi" /qn /passive /quiet
54-
# echo "End Msiexec"
5552
5653
- name: Install OpenCL - Windows 2
5754
shell: pwsh

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ The API directly reflects the low-level **OpenCL** interface. There are minor ch
1919
similar to how WebGL is different from OpenGL.
2020
* All `cl*` methods are available as `cl.*` starting lowercase,
2121
e.g: `clCreateKernel -> cl.createKernel`.
22-
* All `CL_*` constants are available as `cl.*`, e.g.: `CL_SUCCESS -> cl.SUCCESS`.
22+
* All `CL_*` constants are available as `cl.*`, e.g.: `CL_TRUE -> cl.TRUE`.
2323
* The CL resource pointers are wrapped in JS objects, such as `TClPlatform`, `TClContext`, `TClEvent`.
2424
* For `cl.enqueue*()` methods, you can pass `hasEvent = true`, in that case a `TClEvent` is returned.
25+
* The CL status is not returned, instead a JS exception is thrown in case of a CL error.
2526

2627
Most of the method arguments comply to the original C-style spec, some parameters are omitted
2728
due to JS specifics. For example, passing an array, you don't need to specify its length.

src/cpp/memobj.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ JS_METHOD(createBuffer) { NAPI_ENV;
3434
JS_METHOD(createSubBuffer) { NAPI_ENV;
3535
REQ_CL_ARG(0, buffer, cl_mem);
3636
REQ_OFFS_ARG(1, flags);
37-
REQ_OFFS_ARG(1, origin);
38-
REQ_OFFS_ARG(1, size);
37+
REQ_OFFS_ARG(2, origin);
38+
REQ_OFFS_ARG(3, size);
3939

4040
cl_buffer_region buffer_create_info;
4141
buffer_create_info.origin = origin;

src/cpp/program.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ JS_METHOD(linkProgram) { NAPI_ENV;
252252
}
253253
}
254254

255-
256255
std::string options;
257256
if (!IS_ARG_EMPTY(2)) {
258257
REQ_STR_ARG(2, str);

test/program.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ describe('Program', async () => {
3030
it('builds using a valid program and a given device', () => {
3131
const prg = cl.createProgramWithSource(context, squareKern);
3232
const ret = cl.buildProgram(prg, [device]);
33-
assert.strictEqual(ret, cl.SUCCESS);
33+
assert.strictEqual(ret, undefined);
3434
cl.releaseProgram(prg);
3535
});
3636

3737
it('builds using a valid program', () => {
3838
const prg = cl.createProgramWithSource(context, squareKern);
3939
const ret = cl.buildProgram(prg);
40-
assert.strictEqual(ret, cl.SUCCESS);
40+
assert.strictEqual(ret, undefined);
4141
cl.releaseProgram(prg);
4242
});
4343

@@ -50,13 +50,13 @@ describe('Program', async () => {
5050
};
5151
const prg = cl.createProgramWithSource(context, squareKern);
5252
const ret = cl.buildProgram(prg, undefined, undefined, cb, { done });
53-
assert.strictEqual(ret, cl.SUCCESS);
53+
assert.strictEqual(ret, undefined);
5454
});
5555

5656
it('builds using a valid program and options', () => {
5757
const prg = cl.createProgramWithSource(context, squareKern);
5858
const ret = cl.buildProgram(prg, null, '-D NOCL_TEST=5');
59-
assert.strictEqual(ret, cl.SUCCESS);
59+
assert.strictEqual(ret, undefined);
6060
cl.releaseProgram(prg);
6161
});
6262

@@ -144,7 +144,7 @@ describe('Program', async () => {
144144
it('compiles a program', () => {
145145
const prg = cl.createProgramWithSource(context, squareKern);
146146
const ret = cl.compileProgram(prg);
147-
assert.strictEqual(ret, cl.SUCCESS);
147+
assert.strictEqual(ret, undefined);
148148
cl.releaseProgram(prg);
149149
});
150150

@@ -165,15 +165,15 @@ describe('Program', async () => {
165165
cb,
166166
{ done }
167167
);
168-
assert.strictEqual(ret, cl.SUCCESS);
168+
assert.strictEqual(ret, undefined);
169169
});
170170

171171
it('compiles a program with header', () => {
172172
const prg = cl.createProgramWithSource(context, squareKern);
173173
const prg2 = cl.createProgramWithSource(context, squareKern);
174174

175175
const ret = cl.compileProgram(prg, null, null, [prg2], ['prg2.h']);
176-
assert.strictEqual(ret, cl.SUCCESS);
176+
assert.strictEqual(ret, undefined);
177177
cl.releaseProgram(prg);
178178
});
179179

test/queues-buffer.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('CommandQueue - Buffer', () => {
1818
const nbuffer = Buffer.alloc(5);
1919
const ret = cl.enqueueReadBuffer(cq, buffer, true, 0, 8, nbuffer);
2020
cl.releaseMemObject(buffer);
21-
assert.strictEqual(ret, cl.SUCCESS);
21+
assert.strictEqual(ret, undefined);
2222
});
2323

2424
it('fails if buffer is null', () => {
@@ -77,7 +77,7 @@ describe('CommandQueue - Buffer', () => {
7777
);
7878

7979
cl.releaseMemObject(buffer);
80-
assert.strictEqual(ret, cl.SUCCESS);
80+
assert.strictEqual(ret, undefined);
8181
});
8282

8383
it('fails if buffer is null', () => {
@@ -130,7 +130,7 @@ describe('CommandQueue - Buffer', () => {
130130
const ret = cl.enqueueWriteBuffer(cq, buffer, true, 0, 8, nbuffer);
131131

132132
cl.releaseMemObject(buffer);
133-
assert.strictEqual(ret, cl.SUCCESS);
133+
assert.strictEqual(ret, undefined);
134134
});
135135

136136
it('fails if buffer is null', () => {
@@ -163,7 +163,7 @@ describe('CommandQueue - Buffer', () => {
163163
);
164164

165165
cl.releaseMemObject(buffer);
166-
assert.strictEqual(ret, cl.SUCCESS);
166+
assert.strictEqual(ret, undefined);
167167
});
168168

169169
it('fails if buffer is null', () => {
@@ -217,15 +217,15 @@ describe('CommandQueue - Buffer', () => {
217217
const ret = cl.enqueueFillBuffer(cq, buffer, 2, 0, 16);
218218

219219
cl.releaseMemObject(buffer);
220-
assert.strictEqual(ret, cl.SUCCESS);
220+
assert.strictEqual(ret, undefined);
221221
});
222222

223223
it('fills a buffer with a scallar float pattern', () => {
224224
const array = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0]);
225225
const buffer = cl.createBuffer(context, cl.MEM_USE_HOST_PTR, 32, array);
226226
const ret = cl.enqueueFillBuffer(cq, buffer, 2.5, 0, 16);
227227
cl.releaseMemObject(buffer);
228-
assert.strictEqual(ret, cl.SUCCESS);
228+
assert.strictEqual(ret, undefined);
229229
});
230230

231231
it('fills a buffer with a vector pattern', () => {
@@ -235,7 +235,7 @@ describe('CommandQueue - Buffer', () => {
235235
const buffer = cl.createBuffer(context, cl.MEM_USE_HOST_PTR, 32, array);
236236
const ret = cl.enqueueFillBuffer(cq, buffer, pattern, 0, 16);
237237
cl.releaseMemObject(buffer);
238-
assert.strictEqual(ret, cl.SUCCESS);
238+
assert.strictEqual(ret, undefined);
239239
});
240240

241241
it('fills a buffer with a vector pattern', () => {
@@ -245,7 +245,7 @@ describe('CommandQueue - Buffer', () => {
245245
const buffer = cl.createBuffer(context, cl.MEM_USE_HOST_PTR, 32, array);
246246
const ret = cl.enqueueFillBuffer(cq, buffer, pattern, 0, 16);
247247
cl.releaseMemObject(buffer);
248-
assert.strictEqual(ret, cl.SUCCESS);
248+
assert.strictEqual(ret, undefined);
249249
});
250250
});
251251

@@ -256,7 +256,7 @@ describe('CommandQueue - Buffer', () => {
256256
const ret = cl.enqueueCopyBuffer(cq, buffer, dst, 0, 0, 8);
257257

258258
cl.releaseMemObject(buffer);
259-
assert.strictEqual(ret, cl.SUCCESS);
259+
assert.strictEqual(ret, undefined);
260260
});
261261

262262
it('works with write buffers', () => {
@@ -265,7 +265,7 @@ describe('CommandQueue - Buffer', () => {
265265
const ret = cl.enqueueCopyBuffer(cq, buffer, dst, 0, 0, 8);
266266

267267
cl.releaseMemObject(buffer);
268-
assert.strictEqual(ret, cl.SUCCESS);
268+
assert.strictEqual(ret, undefined);
269269
});
270270

271271
});
@@ -282,7 +282,7 @@ describe('CommandQueue - Buffer', () => {
282282
);
283283

284284
cl.releaseMemObject(buffer);
285-
assert.strictEqual(ret, cl.SUCCESS);
285+
assert.strictEqual(ret, undefined);
286286
});
287287

288288
it('works with write-only buffers', () => {
@@ -296,7 +296,7 @@ describe('CommandQueue - Buffer', () => {
296296
);
297297

298298
cl.releaseMemObject(buffer);
299-
assert.strictEqual(ret, cl.SUCCESS);
299+
assert.strictEqual(ret, undefined);
300300
});
301301

302302
it('works with different buffer origin values', () => {
@@ -308,7 +308,7 @@ describe('CommandQueue - Buffer', () => {
308308
0, 0,
309309
0, 0,
310310
);
311-
assert.strictEqual(ret, cl.SUCCESS);
311+
assert.strictEqual(ret, undefined);
312312

313313
ret = cl.enqueueCopyBufferRect(
314314
cq, buffer, dst,
@@ -317,7 +317,7 @@ describe('CommandQueue - Buffer', () => {
317317
0, 0,
318318
);
319319
cl.releaseMemObject(buffer);
320-
assert.strictEqual(ret, cl.SUCCESS);
320+
assert.strictEqual(ret, undefined);
321321
});
322322

323323
it('works with different host origin values', () => {
@@ -329,15 +329,15 @@ describe('CommandQueue - Buffer', () => {
329329
0, 0,
330330
0, 0,
331331
);
332-
assert.strictEqual(ret, cl.SUCCESS);
332+
assert.strictEqual(ret, undefined);
333333

334334
ret = cl.enqueueCopyBufferRect(
335335
cq, buffer, dst,
336336
[0, 0, 0], [2, 2, 0], [4, 4, 1],
337337
0, 0,
338338
0, 0,
339339
);
340-
assert.strictEqual(ret, cl.SUCCESS);
340+
assert.strictEqual(ret, undefined);
341341

342342
ret = cl.enqueueCopyBufferRect(
343343
cq, buffer, dst,
@@ -347,7 +347,7 @@ describe('CommandQueue - Buffer', () => {
347347
);
348348

349349
cl.releaseMemObject(buffer);
350-
assert.strictEqual(ret, cl.SUCCESS);
350+
assert.strictEqual(ret, undefined);
351351
});
352352

353353
it('works with different region values', () => {
@@ -359,15 +359,15 @@ describe('CommandQueue - Buffer', () => {
359359
0, 0,
360360
0, 0,
361361
);
362-
assert.strictEqual(ret, cl.SUCCESS);
362+
assert.strictEqual(ret, undefined);
363363

364364
ret = cl.enqueueCopyBufferRect(
365365
cq, buffer, dst,
366366
[0, 0, 0], [0, 0, 0], [1, 4, 1],
367367
0, 0,
368368
0, 0,
369369
);
370-
assert.strictEqual(ret, cl.SUCCESS);
370+
assert.strictEqual(ret, undefined);
371371

372372
ret = cl.enqueueCopyBufferRect(
373373
cq, buffer, dst,
@@ -378,7 +378,7 @@ describe('CommandQueue - Buffer', () => {
378378

379379
cl.releaseMemObject(buffer);
380380

381-
assert.strictEqual(ret, cl.SUCCESS);
381+
assert.strictEqual(ret, undefined);
382382
});
383383

384384
it('works with different row pitch values', () => {
@@ -390,7 +390,7 @@ describe('CommandQueue - Buffer', () => {
390390
1, 0,
391391
0, 0,
392392
);
393-
assert.strictEqual(ret, cl.SUCCESS);
393+
assert.strictEqual(ret, undefined);
394394

395395
ret = cl.enqueueCopyBufferRect(
396396
cq, buffer, dst,
@@ -401,7 +401,7 @@ describe('CommandQueue - Buffer', () => {
401401

402402
cl.releaseMemObject(buffer);
403403

404-
assert.strictEqual(ret, cl.SUCCESS);
404+
assert.strictEqual(ret, undefined);
405405
});
406406

407407
it('works with different splice pitch values', () => {
@@ -413,7 +413,7 @@ describe('CommandQueue - Buffer', () => {
413413
1, 2,
414414
0, 0,
415415
);
416-
assert.strictEqual(ret, cl.SUCCESS);
416+
assert.strictEqual(ret, undefined);
417417

418418
ret = cl.enqueueCopyBufferRect(
419419
cq, buffer, dst,
@@ -424,7 +424,7 @@ describe('CommandQueue - Buffer', () => {
424424

425425
cl.releaseMemObject(buffer);
426426

427-
assert.strictEqual(ret, cl.SUCCESS);
427+
assert.strictEqual(ret, undefined);
428428
});
429429

430430
it('works with different host pointer values', () => {
@@ -435,7 +435,7 @@ describe('CommandQueue - Buffer', () => {
435435
0, 0,
436436
0, 0,
437437
);
438-
assert.strictEqual(ret, cl.SUCCESS);
438+
assert.strictEqual(ret, undefined);
439439

440440
const buffer2 = cl.createBuffer(context, cl.MEM_USE_HOST_PTR, 64, Buffer.alloc(64));
441441
ret = cl.enqueueCopyBufferRect(cq, buffer2, dst,
@@ -447,11 +447,11 @@ describe('CommandQueue - Buffer', () => {
447447
cl.releaseMemObject(buffer1);
448448
cl.releaseMemObject(dst);
449449

450-
assert.strictEqual(ret, cl.SUCCESS);
450+
assert.strictEqual(ret, undefined);
451451
});
452452
});
453453

454-
describe('# enqueueMapBuffer', () => {
454+
describe('#enqueueMapBuffer', () => {
455455
it('returns a valid buffer', () => {
456456
const buf = cl.createBuffer(context, cl.MEM_READ_WRITE, 8, null);
457457
const ret = cl.enqueueMapBuffer(cq, buf, true, cl.MAP_READ, 0, 8);

0 commit comments

Comments
 (0)