containerd/supervisor/sort_test.go
Kenfe-Mickaël Laventure 8040df4e89 New oom sync (#257)
* Vendor in runc afaa21f79ade3b2e99a68f3f15e7219155aa4662

This updates the Dockerfile to use go 1.6.2 and install pkg-config are
both are now needed by runc.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add support for runc create/start operation

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Remove dependency on runc state directory for OOM handler

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add OOM test

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-09 13:33:26 -07:00

85 lines
1.3 KiB
Go

package supervisor
import (
"os"
"sort"
"testing"
"github.com/docker/containerd/runtime"
"github.com/docker/containerd/specs"
)
type testProcess struct {
id string
}
func (p *testProcess) ID() string {
return p.id
}
func (p *testProcess) Start() error {
return nil
}
func (p *testProcess) CloseStdin() error {
return nil
}
func (p *testProcess) Resize(w, h int) error {
return nil
}
func (p *testProcess) Stdio() runtime.Stdio {
return runtime.Stdio{}
}
func (p *testProcess) SystemPid() int {
return -1
}
func (p *testProcess) ExitFD() int {
return -1
}
func (p *testProcess) ExitStatus() (int, error) {
return -1, nil
}
func (p *testProcess) Container() runtime.Container {
return nil
}
func (p *testProcess) Spec() specs.ProcessSpec {
return specs.ProcessSpec{}
}
func (p *testProcess) Signal(os.Signal) error {
return nil
}
func (p *testProcess) Close() error {
return nil
}
func (p *testProcess) State() runtime.State {
return runtime.Running
}
func (p *testProcess) Wait() {
}
func TestSortProcesses(t *testing.T) {
p := []runtime.Process{
&testProcess{"ls"},
&testProcess{"other"},
&testProcess{"init"},
&testProcess{"other2"},
}
s := &processSorter{p}
sort.Sort(s)
if id := p[len(p)-1].ID(); id != "init" {
t.Fatalf("expected init but received %q", id)
}
}