mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-13 03:03:56 +08:00
TestCheckpoint: skip on ErrCriuMissingFeatures
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
@@ -28,6 +28,8 @@ import (
|
|||||||
|
|
||||||
var criuFeatures *criurpc.CriuFeatures
|
var criuFeatures *criurpc.CriuFeatures
|
||||||
|
|
||||||
|
var ErrCriuMissingFeatures = errors.New("criu is missing features")
|
||||||
|
|
||||||
func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuOpts, criuFeat *criurpc.CriuFeatures) error {
|
func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuOpts, criuFeat *criurpc.CriuFeatures) error {
|
||||||
t := criurpc.CriuReqType_FEATURE_CHECK
|
t := criurpc.CriuReqType_FEATURE_CHECK
|
||||||
|
|
||||||
@@ -50,14 +52,14 @@ func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuO
|
|||||||
return errors.New("CRIU feature check failed")
|
return errors.New("CRIU feature check failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
missingFeatures := false
|
var missingFeatures []string
|
||||||
|
|
||||||
// The outer if checks if the fields actually exist
|
// The outer if checks if the fields actually exist
|
||||||
if (criuFeat.MemTrack != nil) &&
|
if (criuFeat.MemTrack != nil) &&
|
||||||
(criuFeatures.MemTrack != nil) {
|
(criuFeatures.MemTrack != nil) {
|
||||||
// The inner if checks if they are set to true
|
// The inner if checks if they are set to true
|
||||||
if *criuFeat.MemTrack && !*criuFeatures.MemTrack {
|
if *criuFeat.MemTrack && !*criuFeatures.MemTrack {
|
||||||
missingFeatures = true
|
missingFeatures = append(missingFeatures, "MemTrack")
|
||||||
logrus.Debugf("CRIU does not support MemTrack")
|
logrus.Debugf("CRIU does not support MemTrack")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,13 +69,13 @@ func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuO
|
|||||||
if (criuFeat.LazyPages != nil) &&
|
if (criuFeat.LazyPages != nil) &&
|
||||||
(criuFeatures.LazyPages != nil) {
|
(criuFeatures.LazyPages != nil) {
|
||||||
if *criuFeat.LazyPages && !*criuFeatures.LazyPages {
|
if *criuFeat.LazyPages && !*criuFeatures.LazyPages {
|
||||||
missingFeatures = true
|
missingFeatures = append(missingFeatures, "LazyPages")
|
||||||
logrus.Debugf("CRIU does not support LazyPages")
|
logrus.Debugf("CRIU does not support LazyPages")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if missingFeatures {
|
if len(missingFeatures) != 0 {
|
||||||
return errors.New("CRIU is missing features")
|
return fmt.Errorf("%w: %v", ErrCriuMissingFeatures, missingFeatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@@ -3,6 +3,7 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -112,6 +113,9 @@ func testCheckpoint(t *testing.T, userns bool) {
|
|||||||
|
|
||||||
if err := container.Checkpoint(preDumpOpts); err != nil {
|
if err := container.Checkpoint(preDumpOpts); err != nil {
|
||||||
showFile(t, preDumpLog)
|
showFile(t, preDumpLog)
|
||||||
|
if errors.Is(err, libcontainer.ErrCriuMissingFeatures) {
|
||||||
|
t.Skip(err)
|
||||||
|
}
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user