mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-03 06:24:21 +01:00
When imported, the vc files carried in the 'full style' apache license text, but the standard for kata is to use SPDX style. Update the relevant files to SPDX. Fixes: #227 Signed-off-by: Graham whaley <graham.whaley@intel.com>
91 lines
1.5 KiB
Go
91 lines
1.5 KiB
Go
// Copyright (c) 2017 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package virtcontainers
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCCProxyStart(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
tmpdir, err := ioutil.TempDir("", "")
|
|
assert.NoError(err)
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
proxy := &ccProxy{}
|
|
|
|
type testData struct {
|
|
sandbox Sandbox
|
|
expectedURI string
|
|
expectError bool
|
|
}
|
|
|
|
invalidPath := filepath.Join(tmpdir, "enoent")
|
|
expectedSocketPath := filepath.Join(runStoragePath, testSandboxID, "proxy.sock")
|
|
expectedURI := fmt.Sprintf("unix://%s", expectedSocketPath)
|
|
|
|
data := []testData{
|
|
{Sandbox{}, "", true},
|
|
{
|
|
Sandbox{
|
|
config: &SandboxConfig{
|
|
ProxyType: "invalid",
|
|
},
|
|
}, "", true,
|
|
},
|
|
{
|
|
Sandbox{
|
|
config: &SandboxConfig{
|
|
ProxyType: CCProxyType,
|
|
ProxyConfig: ProxyConfig{
|
|
// invalid - no path
|
|
},
|
|
},
|
|
}, "", true,
|
|
},
|
|
{
|
|
Sandbox{
|
|
config: &SandboxConfig{
|
|
ProxyType: CCProxyType,
|
|
ProxyConfig: ProxyConfig{
|
|
Path: invalidPath,
|
|
},
|
|
},
|
|
}, "", true,
|
|
},
|
|
{
|
|
Sandbox{
|
|
id: testSandboxID,
|
|
config: &SandboxConfig{
|
|
ProxyType: CCProxyType,
|
|
ProxyConfig: ProxyConfig{
|
|
Path: "echo",
|
|
},
|
|
},
|
|
}, expectedURI, false,
|
|
},
|
|
}
|
|
|
|
for _, d := range data {
|
|
pid, uri, err := proxy.start(d.sandbox, proxyParams{})
|
|
if d.expectError {
|
|
assert.Error(err)
|
|
continue
|
|
}
|
|
|
|
assert.NoError(err)
|
|
assert.True(pid > 0)
|
|
assert.Equal(d.expectedURI, uri)
|
|
}
|
|
}
|