Skip to content

Commit

Permalink
gapis/api/test: Add a test for static array command parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-clayton committed Sep 25, 2018
1 parent 008123d commit 27b985e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions gapis/api/test/mutate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,38 @@ func TestOperationsOpCall_3_In_Arrays(t *testing.T) {
}.check(ctx, ml, ml)
}

func TestOperationsOpCall_3_In_StaticArrays(t *testing.T) {
ctx := log.Testing(t)
ctx = database.Put(ctx, database.NewInMemory(ctx))
a := arena.New()
defer a.Dispose()
cb := CommandBuilder{Thread: 0, Arena: a}
ml := device.Little64

u8s := NewU8ː3ᵃ(a, 4, 5, 6)
u32s := NewU32ː3ᵃ(a, 7, 8, 9)

test{
cmds: []api.Cmd{
cb.CmdVoid3InStaticArrays(u8s, u32s, u8s),
},
expected: expected{
constants: []byte{
4, 5, 6,
0, 0, 0, 0, 0, // alignment padding
7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0,
},
opcodes: []interface{}{
opcode.Label{Value: 0},
opcode.PushI{DataType: protocol.Type_ConstantPointer, Value: 0x0},
opcode.PushI{DataType: protocol.Type_ConstantPointer, Value: 0x8},
opcode.PushI{DataType: protocol.Type_ConstantPointer, Value: 0x0}, // Shared constant data (dedupe)
opcode.Call{PushReturn: false, ApiIndex: funcInfoCmdVoid3InStaticArrays.ApiIndex, FunctionID: funcInfoCmdVoid3InStaticArrays.ID},
},
},
}.check(ctx, ml, ml)
}

func TestOperationsOpCall_InArrayOfStrings(t *testing.T) {
ctx := log.Testing(t)
ctx = database.Put(ctx, database.NewInMemory(ctx))
Expand Down
5 changes: 5 additions & 0 deletions gapis/api/test/test_commands.api
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ cmd void cmdVoid3InArrays(u8* a, u32* b, int* c) {
copy(U8s, a[5:25]) // only 10 elements should be copied
}

////////////////////////////////////////////////////////////////
// Commands with static input arrays
////////////////////////////////////////////////////////////////
cmd void cmdVoid3InStaticArrays(u8[3] a, u32[3] b, u8[3] c) {}

////////////////////////////////////////////////////////////////
// Commands with input of arrays of pointers
////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 27b985e

Please sign in to comment.