@@ -287,7 +287,7 @@ func interrupt(ctx context.Context, t *testing.T, started <-chan int) {
287287 }
288288}
289289
290- // dummySleepRunc creates s simple script that just runs `sleep 10` to replace
290+ // dummySleepRunc creates a simple script that just runs `sleep 10` to replace
291291// runc for testing process that are longer running.
292292func dummySleepRunc () (_ string , err error ) {
293293 fh , err := os .CreateTemp ("" , "*.sh" )
@@ -314,6 +314,42 @@ func dummySleepRunc() (_ string, err error) {
314314 return fh .Name (), nil
315315}
316316
317+ func TestRuncCheckpoint (t * testing.T ) {
318+ ctx , cancel := context .WithCancel (context .Background ())
319+ defer cancel ()
320+
321+ okRunc := & Runc {
322+ Command : "/bin/true" ,
323+ }
324+
325+ opts := & CheckpointOpts {
326+ AutoDedup : true ,
327+ }
328+ err := okRunc .Checkpoint (ctx , "fake-id" , opts )
329+ if err != nil {
330+ t .Fatalf ("unexpected error from Checkpoint: %v" , err )
331+ }
332+ }
333+
334+ func TestRuncRestore (t * testing.T ) {
335+ ctx , cancel := context .WithCancel (context .Background ())
336+ defer cancel ()
337+
338+ okRunc := & Runc {
339+ Command : "/bin/true" ,
340+ }
341+
342+ opts := & RestoreOpts {
343+ CheckpointOpts : CheckpointOpts {
344+ AutoDedup : true ,
345+ },
346+ }
347+ _ , err := okRunc .Restore (ctx , "fake-id" , "fake-bundle" , opts )
348+ if err != nil {
349+ t .Fatalf ("unexpected error from Checkpoint: %v" , err )
350+ }
351+ }
352+
317353func TestCreateArgs (t * testing.T ) {
318354 o := & CreateOpts {}
319355 args , err := o .args ()
@@ -336,6 +372,24 @@ func TestCreateArgs(t *testing.T) {
336372 }
337373}
338374
375+ func TestCheckpointArgs (t * testing.T ) {
376+ o := & CheckpointOpts {}
377+ args := o .args ()
378+ if len (args ) != 0 {
379+ t .Fatal ("args should be empty" )
380+ }
381+ o = & CheckpointOpts {
382+ AutoDedup : true ,
383+ }
384+ args = o .args ()
385+ if len (args ) != 1 {
386+ t .Fatal ("args should have 1 arg" )
387+ }
388+ if actual := args [0 ]; actual != "--auto-dedup" {
389+ t .Fatalf ("arg should be --auto-dedup but got %s" , actual )
390+ }
391+ }
392+
339393func TestRuncFeatures (t * testing.T ) {
340394 ctx := context .Background ()
341395 if _ , err := exec .LookPath (DefaultCommand ); err != nil {
0 commit comments