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