libct/int: allow subtests

The t.Name() usage in libcontainer/integration prevented subtests
to be used, since in such case it returns a string containing "/",
and thus it can't be used to name a container.

Fix this by replacing slashes with underscores where appropriate.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit af1688a544)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-07-11 14:41:20 -07:00
parent 22b2ff0f34
commit 01cd4b5f3f
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ package integration
import (
"strconv"
"strings"
"testing"
"time"
@@ -215,7 +216,7 @@ func newTemplateConfig(t *testing.T, p *tParam) *configs.Config {
if p.systemd {
id := strconv.FormatInt(-int64(time.Now().Nanosecond()), 36)
config.Cgroups.Name = t.Name() + id
config.Cgroups.Name = strings.ReplaceAll(t.Name(), "/", "_") + id
// do not change Parent (see newContainer)
config.Cgroups.Parent = "system.slice"
config.Cgroups.ScopePrefix = "runc-test"
+1 -1
View File
@@ -151,7 +151,7 @@ func copyBusybox(dest string) error {
}
func newContainer(t *testing.T, config *configs.Config) (libcontainer.Container, error) {
name := t.Name() + strconv.FormatInt(int64(time.Now().Nanosecond()), 35)
name := strings.ReplaceAll(t.Name(), "/", "_") + strconv.FormatInt(-int64(time.Now().Nanosecond()), 35)
root, err := newTestRoot()
if err != nil {
return nil, err