Skip to content

Commit

Permalink
libct/int: allow subtests
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit af1688a)
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Jul 15, 2021
1 parent 22b2ff0 commit 01cd4b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libcontainer/integration/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01cd4b5

Please sign in to comment.