summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/context/contexttest/contexttest.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/context/contexttest/contexttest.go')
-rw-r--r--pkg/sentry/context/contexttest/contexttest.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/sentry/context/contexttest/contexttest.go b/pkg/sentry/context/contexttest/contexttest.go
index 193ce3440..b3c6a566b 100644
--- a/pkg/sentry/context/contexttest/contexttest.go
+++ b/pkg/sentry/context/contexttest/contexttest.go
@@ -53,6 +53,14 @@ type testContext struct {
// globalUniqueID tracks incremental unique identifiers for tests.
var globalUniqueID uint64
+// globalUniqueIDProvider implements unix.UniqueIDProvider.
+type globalUniqueIDProvider struct{}
+
+// UniqueID implements unix.UniqueIDProvider.UniqueID.
+func (*globalUniqueIDProvider) UniqueID() uint64 {
+ return atomic.AddUint64(&globalUniqueID, 1)
+}
+
// lastInotifyCookie is a monotonically increasing counter for generating unique
// inotify cookies. Must be accessed using atomic ops.
var lastInotifyCookie uint32
@@ -76,7 +84,9 @@ func (t *testContext) Value(key interface{}) interface{} {
case platform.CtxPlatform:
return t.platform
case uniqueid.CtxGlobalUniqueID:
- return atomic.AddUint64(&globalUniqueID, 1)
+ return (*globalUniqueIDProvider).UniqueID(nil)
+ case uniqueid.CtxGlobalUniqueIDProvider:
+ return &globalUniqueIDProvider{}
case uniqueid.CtxInotifyCookie:
return atomic.AddUint32(&lastInotifyCookie, 1)
case ktime.CtxRealtimeClock: