MCPcopy Create free account
hub / github.com/google/gapid / TestCommitCommand

Function TestCommitCommand

gapis/replay/builder/builder_test.go:31–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestCommitCommand(t *testing.T) {
32 ctx := log.Testing(t)
33 for _, test := range []struct {
34 name string
35 f func(*Builder)
36 expected []asm.Instruction
37 }{
38 {
39 "Call with used return value",
40 func(b *Builder) {
41 b.BeginCommand(10, 0)
42 b.Push(value.U8(1))
43 b.Call(FunctionInfo{0, 123, protocol.Type_Uint8, 1})
44 b.Store(value.AbsolutePointer(0x10000))
45 b.CommitCommand()
46 },
47 []asm.Instruction{
48 asm.Label{Value: 10},
49 asm.Push{Value: value.U8(1)},
50 asm.Call{PushReturn: true, ApiIndex: 0, FunctionID: 123},
51 asm.Store{Destination: value.AbsolutePointer(0x10000)},
52 },
53 },
54 {
55 "Call with unused return value",
56 func(b *Builder) {
57 b.BeginCommand(10, 0)
58 b.Push(value.U8(1))
59 b.Call(FunctionInfo{1, 123, protocol.Type_Uint8, 1})
60 b.CommitCommand()
61 },
62 []asm.Instruction{
63 asm.Label{Value: 10},
64 asm.Push{Value: value.U8(1)},
65 asm.Call{PushReturn: false, ApiIndex: 1, FunctionID: 123},
66 },
67 },
68 {
69 "Remove unused push",
70 func(b *Builder) {
71 b.BeginCommand(10, 0)
72 b.Push(value.U32(12))
73 b.CommitCommand()
74 },
75 []asm.Instruction{
76 asm.Label{Value: 10},
77 },
78 },
79 {
80 "Unused pushes",
81 func(b *Builder) {
82 b.BeginCommand(10, 0)
83 b.Push(value.U32(12))
84 b.Push(value.U32(34))
85 b.Push(value.U32(56))
86 b.CommitCommand()
87 },
88 []asm.Instruction{

Callers

nothing calls this directly

Calls 12

BeginCommandMethod · 0.80
CommitCommandMethod · 0.80
ThatSliceMethod · 0.80
ForMethod · 0.80
NewFunction · 0.70
PushMethod · 0.65
CallMethod · 0.65
StoreMethod · 0.65
CloneMethod · 0.65
EqualsMethod · 0.65
U8Method · 0.45
U32Method · 0.45

Tested by

no test coverage detected