github.com/containerd/containerd@v22.0.0-20200918172823-438c87b8e050+incompatible/helpers_windows_test.go (about) 1 // +build windows 2 3 /* 4 Copyright The containerd Authors. 5 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 17 */ 18 19 package containerd 20 21 import ( 22 "context" 23 "strconv" 24 25 "github.com/containerd/containerd/containers" 26 "github.com/containerd/containerd/oci" 27 specs "github.com/opencontainers/runtime-spec/specs-go" 28 ) 29 30 const newLine = "\r\n" 31 32 func withExitStatus(es int) oci.SpecOpts { 33 return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error { 34 s.Process.Args = []string{"cmd", "/c", "exit", strconv.Itoa(es)} 35 return nil 36 } 37 } 38 39 func withProcessArgs(args ...string) oci.SpecOpts { 40 return oci.WithProcessArgs(append([]string{"cmd", "/c"}, args...)...) 41 } 42 43 func withCat() oci.SpecOpts { 44 return oci.WithProcessArgs("cmd", "/c", "more") 45 } 46 47 func withTrue() oci.SpecOpts { 48 return oci.WithProcessArgs("cmd", "/c") 49 } 50 51 func withExecExitStatus(s *specs.Process, es int) { 52 s.Args = []string{"cmd", "/c", "exit", strconv.Itoa(es)} 53 } 54 55 func withExecArgs(s *specs.Process, args ...string) { 56 s.Args = append([]string{"cmd", "/c"}, args...) 57 }