MCPcopy Create free account
hub / github.com/buke/quickjs-go / TestRuntimeContextBootstrapOwnerDenied

Function TestRuntimeContextBootstrapOwnerDenied

runtime_test.go:1392–1417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1390}
1391
1392func TestRuntimeContextBootstrapOwnerDenied(t *testing.T) {
1393 oldGIDHook := ownerCheckCurrentGoroutineID
1394 oldThreadHook := ownerCheckCurrentThreadID
1395 defer func() {
1396 ownerCheckCurrentGoroutineID = oldGIDHook
1397 ownerCheckCurrentThreadID = oldThreadHook
1398 }()
1399
1400 var gid atomic.Uint64
1401 gid.Store(71)
1402 ownerCheckCurrentGoroutineID = func() uint64 { return gid.Load() }
1403 ownerCheckCurrentThreadID = func() uint64 { return 1 }
1404
1405 rt := NewRuntime()
1406 defer rt.Close()
1407
1408 ctx := rt.NewBareContext()
1409 require.NotNil(t, ctx)
1410
1411 gid.Store(72)
1412 require.False(t, ctx.BootstrapStdOS())
1413 require.False(t, ctx.BootstrapTimers())
1414
1415 gid.Store(71)
1416 ctx.Close()
1417}
1418
1419func TestRuntimeContextBootstrapHooks(t *testing.T) {
1420 oldStdOSHook := runtimeBootstrapStdOSHook

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
NewBareContextMethod · 0.95
NewRuntimeFunction · 0.85
StoreMethod · 0.80
LoadMethod · 0.80
BootstrapStdOSMethod · 0.80
BootstrapTimersMethod · 0.80

Tested by

no test coverage detected