github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/platform/platform_test.go (about)

     1  package platform
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  
     7  	"github.com/bananabytelabs/wazero/internal/testing/require"
     8  )
     9  
    10  func Test_archRequirementsVerified(t *testing.T) {
    11  	switch runtime.GOARCH {
    12  	case "arm64":
    13  		require.True(t, archRequirementsVerified)
    14  	case "amd64":
    15  		// TODO: once we find a way to test no SSE4 platform, use build tag and choose the correct assertion.
    16  		// For now, we assume that all the amd64 machine we are testing are with SSE 4 to avoid
    17  		// accidentally turn off compiler on the modern amd64 platform.
    18  		require.True(t, archRequirementsVerified)
    19  	default:
    20  		require.False(t, archRequirementsVerified)
    21  	}
    22  }
    23  
    24  func Test_isAtLeastGo120(t *testing.T) {
    25  	tests := []struct {
    26  		input    string
    27  		expected bool
    28  	}{
    29  		{input: "go1.18.10", expected: false},
    30  		{input: "go1.19.10", expected: false},
    31  		{input: "go1.20.5", expected: true},
    32  		{input: "devel go1.21-39c50707 Thu Jul 6 23:23:41 2023 +0000", expected: true},
    33  		{input: "go1.21rc2", expected: true},
    34  		{input: "go1.90.10", expected: true},
    35  		{input: "go2.0.0", expected: false},
    36  	}
    37  
    38  	for _, tt := range tests {
    39  		tc := tt
    40  
    41  		require.Equal(t, tc.expected, isAtLeastGo120(tc.input), tc.input)
    42  	}
    43  }