mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct/utils: ResolveRootfs: remove
Since commit8850636eb3(February 2015) this function is no longer used (replaced by (*ConfigValidator).rootfs), so let's remove it, together with its unit tests (which were added by commit917c1f6d6in April 2016). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -33,16 +33,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveRootfs ensures that the current working directory is
|
|
||||||
// not a symlink and returns the absolute path to the rootfs
|
|
||||||
func ResolveRootfs(uncleanRootfs string) (string, error) {
|
|
||||||
rootfs, err := filepath.Abs(uncleanRootfs)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return filepath.EvalSymlinks(rootfs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExitStatus returns the correct exit status for a process based on if it
|
// ExitStatus returns the correct exit status for a process based on if it
|
||||||
// was signaled or exited cleanly
|
// was signaled or exited cleanly
|
||||||
func ExitStatus(status unix.WaitStatus) int {
|
func ExitStatus(status unix.WaitStatus) int {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@@ -30,51 +28,6 @@ func TestSearchLabels(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResolveRootfs(t *testing.T) {
|
|
||||||
dir := "rootfs"
|
|
||||||
if err := os.Mkdir(dir, 0o600); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(dir)
|
|
||||||
|
|
||||||
path, err := ResolveRootfs(dir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
pwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if path != pwd+"/rootfs" {
|
|
||||||
t.Errorf("expected rootfs to be abs and was %s", path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestResolveRootfsWithSymlink(t *testing.T) {
|
|
||||||
dir := "rootfs"
|
|
||||||
tmpDir, _ := filepath.EvalSymlinks(os.TempDir())
|
|
||||||
if err := os.Symlink(tmpDir, dir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(dir)
|
|
||||||
|
|
||||||
path, err := ResolveRootfs(dir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if path != tmpDir {
|
|
||||||
t.Errorf("expected rootfs to be the real path %s and was %s", path, os.TempDir())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestResolveRootfsWithNonExistingDir(t *testing.T) {
|
|
||||||
_, err := ResolveRootfs("foo")
|
|
||||||
if err == nil {
|
|
||||||
t.Error("expected error to happen but received nil")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExitStatus(t *testing.T) {
|
func TestExitStatus(t *testing.T) {
|
||||||
status := unix.WaitStatus(0)
|
status := unix.WaitStatus(0)
|
||||||
ex := ExitStatus(status)
|
ex := ExitStatus(status)
|
||||||
|
|||||||
Reference in New Issue
Block a user