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

Function TestOperationsOpCall_ReadAndConditionalWrite

gapis/api/test/mutate_test.go:1544–1648  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1542}
1543
1544func TestOperationsOpCall_ReadAndConditionalWrite(t *testing.T) {
1545 ctx := log.Testing(t)
1546 ctx = database.Put(ctx, database.NewInMemory(ctx))
1547 a := arena.New()
1548 defer a.Dispose()
1549 cb := CommandBuilder{Thread: 0, Arena: a}
1550 ml := device.Little32
1551 rRng, rID := memory.Store(ctx, ml, p(0x100000), uint32(3)) // read for all cases
1552 awcRng, awcID := memory.Store(ctx, ml, p(0x100000), uint32(2)) // write to count for Case 1
1553 bwcRng, bwcID := memory.Store(ctx, ml, p(0x100000), uint32(3)) // write to count for Case 2
1554 bwhRng, bwhID := memory.Store(ctx, ml, p(0x200000), []Remapped{10, 20, 30}) // write to handles for Case 2
1555 cwcRng, cwcID := memory.Store(ctx, ml, p(0x100000), uint32(1)) // write to count for Case 3
1556 cwhRng, cwhID := memory.Store(ctx, ml, p(0x300000), []Remapped{40}) // write to handles for Case 3
1557
1558 test{
1559 cmds: []api.Cmd{
1560 // Case 1: only update the count. So we pass null to pHandles.
1561 cb.CmdVoidReadAndConditionalWrite(p(0x100000), p(0x0)).
1562 AddRead(rRng, rID).
1563 AddWrite(awcRng, awcID),
1564 // Case 2: update handles up to the count provided. pHandles is at 0x200000.
1565 cb.CmdVoidReadAndConditionalWrite(p(0x100000), p(0x200000)).
1566 AddRead(rRng, rID).
1567 AddWrite(bwcRng, bwcID).
1568 AddWrite(bwhRng, bwhID),
1569 // Case 3: update handles less than the count provided. pHandles is at 0x300000.
1570 cb.CmdVoidReadAndConditionalWrite(p(0x100000), p(0x300000)).
1571 AddRead(rRng, rID).
1572 AddWrite(cwcRng, cwcID).
1573 AddWrite(cwhRng, cwhID),
1574 // Let's use some of the handles generated.
1575 cb.CmdVoid3Remapped(10, 20, 40),
1576 },
1577 expected: expected{
1578 resources: []id.ID{rID},
1579 opcodes: []interface{}{
1580
1581 // 0x00: remapped pHandles[0] for Case 2
1582 // 0x04: remapped pHandles[1] for Case 2
1583 // 0x08: remapped pHandles[2] for Case 2
1584
1585 // 0x0c: remapped pHandles[0] for Case 3
1586
1587 // 0x10: uint32(3)
1588
1589 // 0x14: pHandles[0] for Case 2 -> 0x00
1590 // 0x18: pHandles[1] for Case 2 -> 0x04
1591 // 0x1c: pHandles[2] for Case 2 -> 0x08
1592
1593 // 0x20: pHandles[0] for Case 3 -> 0x0c
1594
1595 // Case 1
1596 opcode.Label{Value: 0},
1597 opcode.PushI{DataType: protocol.Type_VolatilePointer, Value: 0x10},
1598 opcode.Resource{ID: 0},
1599 opcode.PushI{DataType: protocol.Type_VolatilePointer, Value: 0x10},
1600 opcode.PushI{DataType: protocol.Type_AbsolutePointer, Value: 0x00},
1601 opcode.Call{

Callers

nothing calls this directly

Calls 8

pFunction · 0.85
NewMethod · 0.65
DisposeMethod · 0.65
StoreMethod · 0.65
checkMethod · 0.65
PutMethod · 0.45
AddWriteMethod · 0.45
AddReadMethod · 0.45

Tested by

no test coverage detected