github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/integration/generic-tests/tcz_test.go (about) 1 // Copyright 2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !race 6 // +build !race 7 8 package integration 9 10 import ( 11 "regexp" 12 "testing" 13 14 "github.com/mvdan/u-root-coreutils/pkg/qemu" 15 "github.com/mvdan/u-root-coreutils/pkg/uroot" 16 "github.com/mvdan/u-root-coreutils/pkg/vmtest" 17 ) 18 19 func TestTczclient(t *testing.T) { 20 // TODO: support arm 21 if vmtest.TestArch() != "amd64" && vmtest.TestArch() != "arm64" { 22 t.Skipf("test not supported on %s", vmtest.TestArch()) 23 } 24 25 t.Skip("This test is flaky, and must be fixed") 26 27 network := qemu.NewNetwork() 28 // TODO: On the next iteration, this will serve and provide a missing tcz. 29 var sb wc 30 if true { 31 q, scleanup := vmtest.QEMUTest(t, &vmtest.Options{ 32 Name: "TestTczclient_Server", 33 BuildOpts: uroot.Opts{ 34 ExtraFiles: []string{ 35 "./testdata/tczserver:tcz", 36 }, 37 }, 38 TestCmds: []string{ 39 "dmesg", 40 "ip l", 41 "echo NOW DO IT", 42 "ip addr add 192.168.0.1/24 dev eth0", 43 "ip link set eth0 up", 44 "ip route add 255.255.255.255/32 dev eth0", 45 "ip l", 46 "ip a", 47 "echo NOW SERVER IT", 48 "srvfiles -h 192.168.0.1 -d /", 49 "echo The Server Completes", 50 "shutdown -h", 51 }, 52 QEMUOpts: qemu.Options{ 53 SerialOutput: &sb, 54 Devices: []qemu.Device{ 55 network.NewVM(), 56 }, 57 }, 58 }) 59 if err := q.Expect("shutdown"); err != nil { 60 t.Logf("got %v", err) 61 } 62 defer scleanup() 63 64 t.Logf("Server SerialOutput: %s", sb.String()) 65 } 66 67 var b wc 68 tczClient, ccleanup := vmtest.QEMUTest(t, &vmtest.Options{ 69 Name: "TestTczclient_Client", 70 BuildOpts: uroot.Opts{ 71 ExtraFiles: []string{ 72 "testdata/tczclient:tcz", 73 }, 74 }, 75 TestCmds: []string{ 76 "ip addr add 192.168.0.2/24 dev eth0", 77 "ip link set eth0 up", 78 //"ip route add 255.255.255.255/32 dev eth0", 79 "ip a", 80 "ls -l /", 81 "ls -l /dev", 82 "cat /proc/devices", 83 "cat /proc/filesystems", 84 "ip l", 85 "echo let us do this now", 86 "tcz -d -h 192.168.0.1 -p 8080 libXcomposite libXdamage libXinerama libxshmfence", 87 "tcz -d -h 192.168.0.1 -p 8080 libXdmcp", 88 "ls -l /proc/mounts", 89 "cat /proc/mounts", 90 "echo HI THERE", 91 "ls /TinyCorePackages/tcloop", 92 "shutdown -h", 93 }, 94 QEMUOpts: qemu.Options{ 95 SerialOutput: &b, 96 }, 97 }) 98 defer ccleanup() 99 100 // The directory list is the last thing we get. At that point, 101 // b will have the output we care about and the VM will have shut 102 // down. We can do the rest of the RE matching on b.String() 103 // This is a bit of a hack but it frees us from worrying 104 // about the order in which things appear. 105 tczs := []string{"libXcomposite", "libXdamage", "libXinerama", "libxshmfence"} 106 for _, s := range tczs { 107 if err := tczClient.Expect(s); err != nil { 108 t.Logf("Client SerialOutput: %s", b.String()) 109 t.Errorf("got %v, want nil", err) 110 } 111 t.Logf("Matched %s", s) 112 } 113 114 if false { 115 for _, s := range tczs { 116 re, err := regexp.Compile(".*loop.*" + s) 117 if err != nil { 118 t.Errorf("Check loop device re %s: got %v, want nil", s, err) 119 continue 120 } 121 if ok := re.MatchString(b.String()); !ok { 122 t.Errorf("Check loop device %s: got no match, want match", s) 123 continue 124 } 125 } 126 } 127 }