-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a70075b
commit 9fa202e
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package api | ||
|
||
// #include "bindings.h" | ||
import "C" | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// LibwasmvmVersion returns the version of the loaded library | ||
// at runtime. This can be used to verify if the loaded version | ||
// matches the expected version. | ||
func LibwasmvmVersion() (string, error) { | ||
version, err := C.version_number() | ||
if err != nil { | ||
return "", err | ||
} | ||
patch := version >> 0 & 0xFFFF | ||
minor := version >> 16 & 0xFFFF | ||
major := version >> 32 & 0xFFFF | ||
error := version >> 48 & 0xFFFF | ||
if error != 0 { | ||
return "", fmt.Errorf("Error code from version_number call: %d", error) | ||
} | ||
return fmt.Sprintf("%d.%d.%d", major, minor, patch), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package api | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLibwasmvmVersion(t *testing.T) { | ||
version, err := LibwasmvmVersion() | ||
require.NoError(t, err) | ||
require.Equal(t, "1.0.0", version) | ||
} |