Skip to content

Commit

Permalink
Add another test case for issue pkujhd#77
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonymous authored and eh-steve committed Jun 10, 2023
1 parent fa7ee6a commit c198962
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ require (

require github.com/opentracing/opentracing-go v1.2.0 // indirect

//replace github.com/eh-steve/goloader => ../
replace github.com/eh-steve/goloader => ../
replace github.com/eh-steve/goloader/jit/testdata => ./testdata
5 changes: 5 additions & 0 deletions jit/jit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ func TestIssue78(t *testing.T) {
}
test2 := symbols["Test2"].(func() int)
fmt.Printf("Reported: 0x%x\n", test2())
test3 := symbols["Test3"].(func() int)
val3 := test3()
if val3 != common.Val {
t.Fatalf("expected %d, got %d", common.Val, val3)
}
err := module.Unload()
if err != nil {
t.Fatal(err)
Expand Down
10 changes: 10 additions & 0 deletions jit/testdata/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import (
"sync"
)

var Val = 99

func Inc() {
Val += 1
}

func Dec() {
Val += 1
}

type SomeStruct struct {
Val1 interface{}
Val2 map[string]interface{}
Expand Down
9 changes: 9 additions & 0 deletions jit/testdata/test_issue78/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test_issue78
import (
"context"
"fmt"
"github.com/eh-steve/goloader/jit/testdata/common"
"unsafe"
)

Expand Down Expand Up @@ -32,3 +33,11 @@ func Test2() int {
}
return 99
}

func Test3() (a int) {
a = common.Val + 1
a = common.Val - 1
common.Inc()
fmt.Println(common.Val)
return common.Val
}

0 comments on commit c198962

Please sign in to comment.