diff options
-rw-r--r-- | database/database.go | 10 | ||||
-rw-r--r-- | gfxapi/gles/precision_strip_test.go | 2 | ||||
-rw-r--r-- | gfxapi/test/intrinsics_test.go | 12 | ||||
-rw-r--r-- | gfxapi/test/replay_writer_test.go | 42 | ||||
-rw-r--r-- | integration/replay/gles/gles_test.go | 4 | ||||
-rw-r--r-- | integration/replay/postback_test.go | 2 | ||||
-rw-r--r-- | memory/pool_test.go | 2 | ||||
-rw-r--r-- | server/server.go | 7 |
8 files changed, 36 insertions, 45 deletions
diff --git a/database/database.go b/database/database.go index 7ccae50a8..081e5e7f2 100644 --- a/database/database.go +++ b/database/database.go @@ -37,20 +37,14 @@ type Database interface { Close() } -// Create builds a new database. -func Create(path string, maxDataCacheSize, metaDataCompactionSize, maxDerivedCacheSize int, builder builder) Database { +// NewInMemory builds a new in memory database. +func NewInMemory(builder builder) Database { return &database{ records: map[binary.ID]*record{}, builder: builder, } } -func InMemory() Database { - return &database{ - records: map[binary.ID]*record{}, - } -} - type record struct { value binary.Object request binary.Object diff --git a/gfxapi/gles/precision_strip_test.go b/gfxapi/gles/precision_strip_test.go index c44af9b97..08f04bfc2 100644 --- a/gfxapi/gles/precision_strip_test.go +++ b/gfxapi/gles/precision_strip_test.go @@ -38,7 +38,7 @@ func (m *mockWriter) Write(id atom.ID, a atom.Atom) { } func runTest(t *testing.T, src string, expected string) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, diff --git a/gfxapi/test/intrinsics_test.go b/gfxapi/test/intrinsics_test.go index 226d4e459..fac185756 100644 --- a/gfxapi/test/intrinsics_test.go +++ b/gfxapi/test/intrinsics_test.go @@ -32,7 +32,7 @@ func checkBytes(t *testing.T, got, expected []byte) { } func TestClone(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) expected := []byte{0x54, 0x33, 0x42, 0x43, 0x46, 0x34, 0x63, 0x24, 0x14, 0x24} for _, a := range []atom.Atom{ NewCmdClone(0x1234, 10). @@ -45,7 +45,7 @@ func TestClone(t *testing.T) { } func TestMake(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) if s.NextPoolID != 1 { t.Errorf("Expected initial NextPoolID to be 1, instead got %d", s.NextPoolID) } @@ -59,7 +59,7 @@ func TestMake(t *testing.T) { } func TestCopy(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) expected := []byte{0x54, 0x33, 0x42, 0x43, 0x46, 0x34, 0x63, 0x24, 0x14, 0x24} for _, a := range []atom.Atom{ NewCmdMake(10), @@ -73,7 +73,7 @@ func TestCopy(t *testing.T) { } func TestCharsliceToString(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) expected := "ħęľĺő ŵōřŀď" NewCmdCharsliceToString(0x1234, uint32(len(expected))). AddRead(atom.Data(s.Architecture, d, l, 0x1234, expected)). @@ -84,7 +84,7 @@ func TestCharsliceToString(t *testing.T) { } func TestCharptrToString(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) expected := "ħęľĺő ŵōřŀď" NewCmdCharptrToString(0x1234). AddRead(atom.Data(s.Architecture, d, l, 0x1234, expected)). @@ -95,7 +95,7 @@ func TestCharptrToString(t *testing.T) { } func TestSliceCasts(t *testing.T) { - s, d, l := gfxapi.NewState(), database.InMemory(), log.Testing(t) + s, d, l := gfxapi.NewState(), database.NewInMemory(nil), log.Testing(t) s.Architecture.IntegerSize = 6 // non-multiple of u16 addr := memory.Pointer(0x1234) NewCmdSliceCasts(0x1234, 10).Mutate(s, d, l) diff --git a/gfxapi/test/replay_writer_test.go b/gfxapi/test/replay_writer_test.go index 48776e550..b20d70c54 100644 --- a/gfxapi/test/replay_writer_test.go +++ b/gfxapi/test/replay_writer_test.go @@ -135,7 +135,7 @@ func max(a, b int) int { } func TestOperationsOpCall_NoIn_NoOut(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -156,7 +156,7 @@ func TestOperationsOpCall_NoIn_NoOut(t *testing.T) { } func TestOperationsOpCall_Clone(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -185,7 +185,7 @@ func TestOperationsOpCall_Clone(t *testing.T) { } func TestOperationsOpCall_Make(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -208,7 +208,7 @@ func TestOperationsOpCall_Make(t *testing.T) { } func TestOperationsOpCall_Copy(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -237,7 +237,7 @@ func TestOperationsOpCall_Copy(t *testing.T) { } func TestOperationsOpCall_CharSliceToString(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -266,7 +266,7 @@ func TestOperationsOpCall_CharSliceToString(t *testing.T) { } func TestOperationsOpCall_CharPtrToString(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -295,7 +295,7 @@ func TestOperationsOpCall_CharPtrToString(t *testing.T) { } func TestOperationsOpCall_Unknowns(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -331,7 +331,7 @@ func TestOperationsOpCall_Unknowns(t *testing.T) { } func TestOperationsOpCall_SingleInputArg(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -409,7 +409,7 @@ func TestOperationsOpCall_SingleInputArg(t *testing.T) { } func TestOperationsOpCall_3_Strings(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -437,7 +437,7 @@ func TestOperationsOpCall_3_Strings(t *testing.T) { } func TestOperationsOpCall_3_In_Arrays(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 8, PointerSize: 4, @@ -491,7 +491,7 @@ func TestOperationsOpCall_3_In_Arrays(t *testing.T) { } func TestOperationsOpCall_InArrayOfPointers(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -556,7 +556,7 @@ func TestOperationsOpCall_InArrayOfPointers(t *testing.T) { } func TestOperationsOpCall_SinglePointerElementRead(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -679,7 +679,7 @@ func TestOperationsOpCall_SinglePointerElementRead(t *testing.T) { } func TestOperationsOpCall_MultiplePointerElementReads(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 16, PointerSize: 4, @@ -716,7 +716,7 @@ func TestOperationsOpCall_MultiplePointerElementReads(t *testing.T) { } func TestOperationsOpCall_SinglePointerElementWrite(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -789,7 +789,7 @@ func TestOperationsOpCall_SinglePointerElementWrite(t *testing.T) { } func TestOperationsOpCall_MultiplePointerElementWrites(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 16, PointerSize: 4, @@ -813,7 +813,7 @@ func TestOperationsOpCall_MultiplePointerElementWrites(t *testing.T) { } func TestOperationsOpCall_ReturnValue(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -870,7 +870,7 @@ func TestOperationsOpCall_ReturnValue(t *testing.T) { } func TestOperationsOpCall_3Remapped(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -903,7 +903,7 @@ func TestOperationsOpCall_3Remapped(t *testing.T) { } func TestOperationsOpCall_InArrayOfRemapped(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -959,7 +959,7 @@ func TestOperationsOpCall_InArrayOfRemapped(t *testing.T) { } func TestOperationsOpCall_OutArrayOfRemapped(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -1007,7 +1007,7 @@ func TestOperationsOpCall_OutArrayOfRemapped(t *testing.T) { } func TestOperationsOpCall_OutArrayOfUnknownRemapped(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, @@ -1055,7 +1055,7 @@ func TestOperationsOpCall_OutArrayOfUnknownRemapped(t *testing.T) { } func TestOperationsOpCall_Remapped(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) a := device.Architecture{ PointerAlignment: 4, PointerSize: 4, diff --git a/integration/replay/gles/gles_test.go b/integration/replay/gles/gles_test.go index 8e7d80c88..6f198b8aa 100644 --- a/integration/replay/gles/gles_test.go +++ b/integration/replay/gles/gles_test.go @@ -84,7 +84,7 @@ func initContext(a device.Architecture, d database.Database, l log.Logger, width } func TestClear(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) mgr := replay.New(d, l) device := utils.FindLocalDevice(t, mgr) w, h := uint32(64), uint32(64) @@ -118,7 +118,7 @@ func TestClear(t *testing.T) { } func TestDrawTriangle(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) mgr := replay.New(d, l) device := utils.FindLocalDevice(t, mgr) a := device.Info().Architecture() diff --git a/integration/replay/postback_test.go b/integration/replay/postback_test.go index 908ee29dc..84889cb1c 100644 --- a/integration/replay/postback_test.go +++ b/integration/replay/postback_test.go @@ -29,7 +29,7 @@ import ( ) func doReplay(t *testing.T, f func(*builder.Builder)) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) mgr := replay.New(d, l) device := utils.FindLocalDevice(t, mgr) diff --git a/memory/pool_test.go b/memory/pool_test.go index f958af933..d3b241eee 100644 --- a/memory/pool_test.go +++ b/memory/pool_test.go @@ -144,7 +144,7 @@ func TestMemoryBlobWriteReadScattered(t *testing.T) { // └────┴────┴────┴────┴────┴────┴────┴────╚════╝────┴────┴────┘ // func TestMemoryResourceWriteReadScattered(t *testing.T) { - d, l := database.InMemory(), log.Testing(t) + d, l := database.NewInMemory(nil), log.Testing(t) resA, _ := database.StoreBlob([]byte{10, 11, 12}, d, l) resB, _ := database.StoreBlob([]byte{20, 21, 22, 23}, d, l) resC, _ := database.StoreBlob([]byte{30, 31}, d, l) diff --git a/server/server.go b/server/server.go index 0df5c5ea0..063f28ff2 100644 --- a/server/server.go +++ b/server/server.go @@ -39,10 +39,7 @@ const ( capturesRoute = "/captures/" schemaRoute = "/schema/" - maxDataCacheSize = 2 << 30 // 2 gigabytes - maxDerivedCacheSize = 1 << 29 // 0.5 gigabytes - metaDataCompactionSize = 100 << 20 // 100 metabytes - mtu = 1024 + mtu = 1024 ) // Run listens on the HTTP and RPC TCP ports given in config, initializes the resource database, @@ -59,7 +56,7 @@ func Run(config Config, rpcReady chan<- struct{}) { // Initialize the resource database and replay manager for RPC requests. b := builder.New() - database := database.Create(config.DataPath, maxDataCacheSize, metaDataCompactionSize, maxDerivedCacheSize, b) + database := database.NewInMemory(b) replayManager := replay.New(database, logger) b.SetReplayManager(replayManager) |