runtime: Move mockfs control global into mockfs.go

virtcontainers/persist/fs/mockfs.go defines a mock filesystem type for
testing.  A global variable in virtcontainers/persist/manager.go is used to
force use of the mock fs rather than a normal one.

This patch moves the global, and the EnableMockTesting() function which
sets it into mockfs.go.  This is slightly cleaner to begin with, and will
allow some further enhancements.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson
2022-04-06 14:46:44 +10:00
parent 963d03ea8a
commit 5d8438e939
5 changed files with 51 additions and 23 deletions

View File

@@ -15,7 +15,6 @@ import (
"syscall"
"testing"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/fs"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
"github.com/sirupsen/logrus"
@@ -108,7 +107,7 @@ func setupClh() {
func TestMain(m *testing.M) {
var err error
persist.EnableMockTesting()
fs.EnableMockTesting()
flag.Parse()