MCPcopy Index your code
hub / github.com/containerd/containerd / TestContainerPTY

Function TestContainerPTY

integration/client/container_test.go:2731–2799  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2729}
2730
2731func TestContainerPTY(t *testing.T) {
2732 t.Parallel()
2733
2734 client, err := newClient(t, address)
2735 if err != nil {
2736 t.Fatal(err)
2737 }
2738 defer client.Close()
2739
2740 var (
2741 image Image
2742 ctx, cancel = testContext(t)
2743 id = t.Name()
2744 )
2745 defer cancel()
2746
2747 image, err = client.GetImage(ctx, testImage)
2748 if err != nil {
2749 t.Fatal(err)
2750 }
2751
2752 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), oci.WithTTY, withProcessArgs("echo", "hello")))
2753 if err != nil {
2754 t.Fatal(err)
2755 }
2756 defer container.Delete(ctx, WithSnapshotCleanup)
2757
2758 buf := bytes.NewBuffer(nil)
2759 task, err := container.NewTask(ctx, cio.NewCreator(withStdout(buf), withProcessTTY()))
2760 if err != nil {
2761 t.Fatal(err)
2762 }
2763 defer task.Delete(ctx)
2764
2765 statusC, err := task.Wait(ctx)
2766 if err != nil {
2767 t.Error(err)
2768 }
2769
2770 if err := task.Start(ctx); err != nil {
2771 t.Fatal(err)
2772 }
2773
2774 <-statusC
2775
2776 if _, err := task.Delete(ctx); err != nil {
2777 t.Fatal(err)
2778 }
2779
2780 tries := 1
2781 if runtime.GOOS == "windows" {
2782 // TODO: Fix flakiness on Window by checking for race in writing to buffer
2783 tries += 2
2784 }
2785
2786 for {
2787 out := buf.String()
2788 if strings.ContainsAny(fmt.Sprintf("%#q", out), `\x00`) {

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
NewCreatorFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
withStdoutFunction · 0.85
withProcessTTYFunction · 0.85
FatalMethod · 0.80
withProcessArgsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…