diff options
author | Luca Casonato <hello@lcas.dev> | 2022-03-25 12:29:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-25 12:29:54 +0100 |
commit | 25b73a366f8b114d05add8b93aa52beb321dcb6e (patch) | |
tree | ede00e70b8a2b523c8e8014401b009aa0e8f7bce /cli/tests/unit/ffi_test.ts | |
parent | 3462d8750344743b7b0cdbedcbff6c4b98a383ba (diff) |
fix(ext/ffi): enforce unstable check on ops (#14115)
Diffstat (limited to 'cli/tests/unit/ffi_test.ts')
-rw-r--r-- | cli/tests/unit/ffi_test.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cli/tests/unit/ffi_test.ts b/cli/tests/unit/ffi_test.ts index b7772e8e2..22da88d27 100644 --- a/cli/tests/unit/ffi_test.ts +++ b/cli/tests/unit/ffi_test.ts @@ -23,3 +23,54 @@ Deno.test({ permissions: { ffi: true } }, function dlopenInvalidArguments() { Deno.dlopen(filename); }, TypeError); }); + +Deno.test({ permissions: { ffi: false } }, function ffiPermissionDenied() { + assertThrows(() => { + Deno.dlopen("/usr/lib/libc.so.6", {}); + }, Deno.errors.PermissionDenied); + const ptr = new Deno.UnsafePointer(0n); + const fnptr = new Deno.UnsafeFnPointer( + ptr, + { + parameters: ["u32", "pointer"], + result: "void", + } as const, + ); + assertThrows(() => { + fnptr.call(123, null); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + Deno.UnsafePointer.of(new Uint8Array(0)); + }, Deno.errors.PermissionDenied); + const ptrView = new Deno.UnsafePointerView(ptr); + assertThrows(() => { + ptrView.copyInto(new Uint8Array(0)); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getCString(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getUint8(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getInt8(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getUint16(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getInt16(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getUint32(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getInt32(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getFloat32(); + }, Deno.errors.PermissionDenied); + assertThrows(() => { + ptrView.getFloat64(); + }, Deno.errors.PermissionDenied); +}); |