Debian Codegraph @

internal/runtime/cpu_quota_linux_test.go

raw symbols SCIP
1 // Copyright (c) 2022 Uber Technologies, Inc.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20
21 //go:build linux
22 // +build linux
23
24 package runtimescip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/
25
26 import (
27 "errorsscip-go gomod github.com/golang/go/src go1.18 errors/"
28 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
29 "testingscip-go gomod github.com/golang/go/src go1.18 testing/"
30
31 "github.com/prashantv/gostubscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/"
32 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/"
33 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/require`/"
34 "go.uber.org/automaxprocs/internal/cgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/"
35 )
36
37 func TestNewQueryerscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/TestNewQueryer().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
38 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("use v2", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
39 stubs := newStubsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newStubs().(t)
40
41 c2 := new(cgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/.CGroups2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/CGroups2#)
42 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroups2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups2., c2, nil)
43
44 got, err := newQueryerscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newQueryer().()
45 requirescip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/require`/NoError().(t, err)
46 assertscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/.Samescip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/Same().(t, c2, got)
47 })
48
49 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("v2 error", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
50 stubs := newStubsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newStubs().(t)
51
52 giveErr := errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("great sadness")
53 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroups2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups2., nil, giveErr)
54
55 _, err := newQueryerscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newQueryer().()
56 assertscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/ErrorIs().(t, err, giveErr)
57 })
58
59 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("use v1", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
60 stubs := newStubsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newStubs().(t)
61
62 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroups2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups2., nil,
63 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("not v2: %w", cgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/.ErrNotV2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/ErrNotV2.))
64
65 c1 := make(cgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/.CGroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/CGroups#)
66 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups., c1, nil)
67
68 got, err := newQueryerscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newQueryer().()
69 requirescip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/require`/NoError().(t, err)
70 assertscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/.IsTypescip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/IsType().(t, c1, got, "must be a v1 cgroup")
71 })
72
73 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("v1 error", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
74 stubs := newStubsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newStubs().(t)
75
76 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroups2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups2., nil, cgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/.ErrNotV2scip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/cgroups`/ErrNotV2.)
77
78 giveErr := errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("great sadness")
79 stubs.StubFuncscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#StubFunc().(&_newCgroupsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/_newCgroups., nil, giveErr)
80
81 _, err := newQueryerscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newQueryer().()
82 assertscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.7.1 `github.com/stretchr/testify/assert`/ErrorIs().(t, err, giveErr)
83 })
84 }
85
86 func newStubsscip-go gomod go.uber.org/automaxprocs . `go.uber.org/automaxprocs/internal/runtime`/newStubs().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) *gostubscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/.Stubsscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs# {
87 stubs := gostubscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/.Newscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/New().()
88 t.Cleanupscip-go gomod github.com/golang/go/src go1.18 testing/common#Cleanup().(stubs.Resetscip-go gomod github.com/prashantv/gostub v1.1.0 `github.com/prashantv/gostub`/Stubs#Reset().)
89 return stubs
90 }