commit
88989e66d3
|
@ -2,6 +2,7 @@ package configs
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -43,6 +44,34 @@ func loadConfig(name string) (*Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Check that a config doesn't contain extra fields
|
||||
var configMap, abstractMap map[string]interface{}
|
||||
|
||||
if _, err := f.Seek(0, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(f).Decode(&abstractMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
configData, err := json.Marshal(&container)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(configData, &configMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k := range configMap {
|
||||
delete(abstractMap, k)
|
||||
}
|
||||
|
||||
if len(abstractMap) != 0 {
|
||||
return nil, fmt.Errorf("unknown fields: %s", abstractMap)
|
||||
}
|
||||
|
||||
return container, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -188,8 +188,8 @@ func TestRlimit(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if limit := strings.TrimSpace(out.Stdout.String()); limit != "1024" {
|
||||
t.Fatalf("expected rlimit to be 1024, got %s", limit)
|
||||
if limit := strings.TrimSpace(out.Stdout.String()); limit != "1025" {
|
||||
t.Fatalf("expected rlimit to be 1025, got %s", limit)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ func TestExecInRlimit(t *testing.T) {
|
|||
t.Log(err)
|
||||
}
|
||||
out := buffers.Stdout.String()
|
||||
if limit := strings.TrimSpace(out); limit != "1024" {
|
||||
t.Fatalf("expected rlimit to be 1024, got %s", limit)
|
||||
if limit := strings.TrimSpace(out); limit != "1025" {
|
||||
t.Fatalf("expected rlimit to be 1025, got %s", limit)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ func newTemplateConfig(rootfs string) *configs.Config {
|
|||
Rlimits: []configs.Rlimit{
|
||||
{
|
||||
Type: syscall.RLIMIT_NOFILE,
|
||||
Hard: uint64(1024),
|
||||
Soft: uint64(1024),
|
||||
Hard: uint64(1025),
|
||||
Soft: uint64(1025),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package libcontainer
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
@ -54,8 +55,10 @@ func (p Process) Wait() (*os.ProcessState, error) {
|
|||
|
||||
// Pid returns the process ID
|
||||
func (p Process) Pid() (int, error) {
|
||||
// math.MinInt32 is returned here, because it's invalid value
|
||||
// for the kill() system call.
|
||||
if p.ops == nil {
|
||||
return -1, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
|
||||
return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted)
|
||||
}
|
||||
return p.ops.pid(), nil
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "",
|
||||
"hostname": "nsinit",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "",
|
||||
"hostname": "koye",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "",
|
||||
"hostname": "nsinit",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "",
|
||||
"hostname": "nsinit",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
@ -338,4 +337,4 @@
|
|||
"/proc/irq",
|
||||
"/proc/bus"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "system_u:system_r:svirt_lxc_net_t:s0:c164,c475",
|
||||
"hostname": "nsinit",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
],
|
||||
"mount_label": "",
|
||||
"hostname": "nsinit",
|
||||
"console": "",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "NEWNS",
|
||||
|
|
Loading…
Reference in New Issue