diff options
author | Ian Gudger <igudger@google.com> | 2018-10-15 17:47:24 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-15 17:48:11 -0700 |
commit | 167f2401c4abb1ebda1f4536a04d9854e9008e0b (patch) | |
tree | dc9c7d33f0635039bf3ba45e912fb693f3a99812 /pkg/sentry/context/contexttest/contexttest.go | |
parent | ecd94ea7a693d49a0edce8607241a8e2ac22bfe0 (diff) |
Merge host.endpoint into host.ConnectedEndpoint
host.endpoint contained duplicated logic from the sockerpair implementation and
host.ConnectedEndpoint. Remove host.endpoint in favor of a
host.ConnectedEndpoint wrapped in a socketpair end.
PiperOrigin-RevId: 217240096
Change-Id: I4a3d51e3fe82bdf30e2d0152458b8499ab4c987c
Diffstat (limited to 'pkg/sentry/context/contexttest/contexttest.go')
-rw-r--r-- | pkg/sentry/context/contexttest/contexttest.go | 12 |
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: |