github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/imports/wasi_snapshot_preview1/sched_test.go (about)

     1  package wasi_snapshot_preview1_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	wazero "github.com/wasilibs/wazerox"
     7  	"github.com/wasilibs/wazerox/internal/testing/require"
     8  	"github.com/wasilibs/wazerox/internal/wasip1"
     9  )
    10  
    11  func Test_schedYield(t *testing.T) {
    12  	var yielded bool
    13  	mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().
    14  		WithOsyield(func() {
    15  			yielded = true
    16  		}))
    17  	defer r.Close(testCtx)
    18  	requireErrnoResult(t, wasip1.ErrnoSuccess, mod, wasip1.SchedYieldName)
    19  	require.Equal(t, `
    20  ==> wasi_snapshot_preview1.sched_yield()
    21  <== errno=ESUCCESS
    22  `, "\n"+log.String())
    23  	require.True(t, yielded)
    24  }