refactor: call function

This commit is contained in:
debugtalk
2022-01-06 18:01:23 +08:00
parent cfad6cee59
commit 014e53cef4
4 changed files with 142 additions and 139 deletions

View File

@@ -7,7 +7,6 @@ import (
"fmt"
"os"
"os/exec"
"plugin"
"testing"
"github.com/stretchr/testify/assert"
@@ -27,14 +26,11 @@ func TestMain(m *testing.M) {
}
func TestCallPluginFunction(t *testing.T) {
pluginLoader, err := plugin.Open("examples/debugtalk.so")
if err != nil {
t.Fatalf(err.Error())
}
parser := newParser()
parser.loadPlugin("examples/debugtalk.so")
// call function without arguments
f1, _ := getMappingFunction("Concatenate", pluginLoader)
result, err := callFunc(f1, 1, "2", 3.14)
result, err := parser.callFunc("Concatenate", 1, "2", 3.14)
if !assert.NoError(t, err) {
t.Fail()
}