gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/pkg/cpio/newc_test.go (about) 1 // Copyright 2012 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 package cpio 6 7 import ( 8 "bytes" 9 "io" 10 "io/ioutil" 11 "reflect" 12 "syscall" 13 "testing" 14 15 "github.com/u-root/u-root/pkg/uio" 16 ) 17 18 /* 19 TODO(#935): This test should really compare against []Records, not the string 20 formatted []Records. 21 22 func TestSimple(t *testing.T) { 23 r := Newc.Reader(bytes.NewReader(testCPIO)) 24 files, err := ReadAllRecords(r) 25 if err != nil { 26 t.Fatal(err) 27 } 28 29 for i, f := range files { 30 if f.String() != testResult[i] { 31 t.Errorf("Value %d: got \n%s, want \n%s", i, f.String(), testResult[i]) 32 } 33 t.Logf("Value %d: got \n%s, want \n%s", i, f.String(), testResult[i]) 34 } 35 } 36 */ 37 38 func TestWriteRead(t *testing.T) { 39 contents := []byte("LANAAAAAAAAAA") 40 rec := StaticRecord(contents, Info{ 41 Ino: 1, 42 Mode: syscall.S_IFREG | 2, 43 UID: 3, 44 GID: 4, 45 NLink: 5, 46 MTime: 6, 47 FileSize: 7, 48 Major: 8, 49 Minor: 9, 50 Rmajor: 10, 51 Rminor: 11, 52 Name: "foobar", 53 }) 54 55 buf := &bytes.Buffer{} 56 w := Newc.Writer(buf) 57 if err := w.WriteRecord(rec); err != nil { 58 t.Errorf("Could not write record %q: %v", rec.Name, err) 59 } 60 61 if err := WriteTrailer(w); err != nil { 62 t.Errorf("Could not write trailer: %v", err) 63 } 64 65 r := Newc.Reader(bytes.NewReader(buf.Bytes())) 66 rec2, err := r.ReadRecord() 67 if err != nil { 68 t.Errorf("Could not read record: %v", err) 69 } 70 71 if rec2.Info != rec.Info { 72 t.Errorf("Records not equal:\n%#v\n%#v", rec.Info, rec2.Info) 73 } 74 75 contents2, err := ioutil.ReadAll(uio.Reader(rec2)) 76 if err != nil { 77 t.Errorf("Could not read %q: %v", rec2.Name, err) 78 } 79 80 if !bytes.Equal(contents2, contents) { 81 t.Errorf("Read(%q) = %s, want %s", rec2.Name, string(contents2), contents) 82 } 83 } 84 85 func TestReadWrite(t *testing.T) { 86 r := Newc.Reader(bytes.NewReader(testCPIO)) 87 files, err := ReadAllRecords(r) 88 if err != nil { 89 t.Fatalf("Reading testCPIO reader: %v", err) 90 } 91 92 buf := &bytes.Buffer{} 93 w := Newc.Writer(buf) 94 if err := WriteRecords(w, files); err != nil { 95 t.Fatalf("WriteRecords: %v", err) 96 } 97 98 if err := WriteTrailer(w); err != nil { 99 t.Fatalf("WriteTrailer: %v", err) 100 } 101 102 r = Newc.Reader(bytes.NewReader(testCPIO)) 103 files, err = ReadAllRecords(r) 104 if err != nil { 105 t.Fatalf("Reading testCPIO reader: %v", err) 106 } 107 108 r = Newc.Reader(bytes.NewReader(buf.Bytes())) 109 filesReadBack, err := ReadAllRecords(r) 110 if err != nil { 111 t.Fatalf("TestReadWrite: reading generated data: %v", err) 112 } 113 114 // Now check a few things: arrays should be same length, Headers should match, 115 // names should be the same, and data should be the same. If this all works, 116 // it means we read in serialized data, wrote it out, read it in, and the 117 // structs all matched. 118 if len(files) != len(filesReadBack) { 119 t.Fatalf("[]file len from testCPIO %v and generated %v are not the same and should be", len(files), len(filesReadBack)) 120 } 121 for i := range files { 122 f1 := files[i] 123 f2 := filesReadBack[i] 124 125 if f1.Info != f2.Info { 126 t.Errorf("index %d: testCPIO Info\n%v\ngenerated Info\n%v\n", i, f1.Info, f2.Info) 127 } 128 129 contents1, err := ioutil.ReadAll(uio.Reader(f1)) 130 if err != nil { 131 t.Errorf("index %d(%q): can't read from the source: %v", i, f1.Name, err) 132 } 133 contents2, err := ioutil.ReadAll(uio.Reader(f2)) 134 if err != nil { 135 t.Errorf("index %d(%q): can't read from the dest: %v", i, f2.Name, err) 136 } 137 if !bytes.Equal(contents1, contents2) { 138 t.Errorf("index %d content: file 1 (%q) is %v, file 2 (%q) wanted %v", i, f1.Name, contents1, f2.Name, contents2) 139 } 140 } 141 } 142 143 func TestBad(t *testing.T) { 144 r := Newc.Reader(bytes.NewReader(badCPIO)) 145 if _, err := r.ReadRecord(); err != io.EOF { 146 t.Errorf("ReadRecord(badCPIO) got %v, want %v", err, io.EOF) 147 } 148 149 r = Newc.Reader(bytes.NewReader(badMagicCPIO)) 150 if _, err := r.ReadRecord(); err == nil { 151 t.Errorf("Wanted bad magic err, got nil") 152 } 153 } 154 155 /* 156 drwxrwxr-x 9 rminnich rminnich 0 Jan 22 22:18 . 157 drwxr-xr-x 2 root root 0 Jan 22 22:18 etc 158 -rw-r--r-- 1 root root 118 Jan 22 22:18 etc/localtime 159 -rw-r--r-- 1 root root 81 Jan 22 22:18 etc/resolv.conf 160 drwxr-xr-x 2 root root 0 Jan 22 22:18 lib64 161 drwxr-xr-x 2 root root 0 Jan 22 22:18 tcz 162 drwxr-xr-x 2 root root 0 Jan 22 22:18 bin 163 drwxr-xr-x 2 root root 0 Jan 22 22:18 tmp 164 drwxr-xr-x 2 root root 0 Jan 22 22:18 dev 165 crw-r--r-- 1 root root 5, 1 Jan 22 22:18 dev/console 166 crw-r--r-- 1 root root 4, 64 Jan 22 22:18 dev/ttyS0 167 brw-rw---- 1 root root 7, 2 Jan 22 22:18 dev/loop2 168 crw------- 1 root root 10, 237 Jan 22 22:18 dev/loop-control 169 brw-rw---- 1 root root 7, 7 Jan 22 22:18 dev/loop7 170 brw-rw---- 1 root root 7, 6 Jan 22 22:18 dev/loop6 171 brw-rw---- 1 root root 7, 4 Jan 22 22:18 dev/loop4 172 brw-rw---- 1 root root 7, 1 Jan 22 22:18 dev/loop1 173 brw-rw---- 1 root root 7, 5 Jan 22 22:18 dev/loop5 174 crw-r--r-- 1 root root 1, 3 Jan 22 22:18 dev/null 175 brw-rw---- 1 root root 7, 0 Jan 22 22:18 dev/loop0 176 brw-rw---- 1 root root 7, 3 Jan 22 22:18 dev/loop3 177 drwxr-xr-x 3 root root 0 Jan 22 22:18 usr 178 drwxr-xr-x 2 root root 0 Jan 22 22:18 usr/lib 179 */ 180 var ( 181 badCPIO = []byte{} 182 badMagicCPIO = []byte{0, 0, 0, 0, 0, 0} 183 testCPIO = []byte{ 184 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 185 0x43, 0x31, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x46, 0x44, 0x30, 0x30, 186 0x30, 0x30, 0x30, 0x33, 0x45, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 187 0x45, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x39, 0x35, 0x38, 188 0x38, 0x35, 0x41, 0x30, 0x34, 0x45, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 189 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 190 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 191 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 192 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 193 0x30, 0x30, 0x2e, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 194 0x33, 0x30, 0x45, 0x33, 0x43, 0x35, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 195 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 196 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 197 0x30, 0x32, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 198 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 199 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 200 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 201 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 202 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x65, 0x74, 0x63, 0x00, 0x00, 0x00, 203 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x43, 0x32, 204 0x30, 0x43, 0x30, 0x30, 0x30, 0x30, 0x38, 0x31, 0x41, 0x34, 0x30, 0x30, 205 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 206 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x35, 0x38, 207 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 208 0x37, 0x36, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 209 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 210 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 211 0x30, 0x30, 0x30, 0x30, 0x30, 0x45, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 212 0x30, 0x30, 0x65, 0x74, 0x63, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x74, 213 0x69, 0x6d, 0x65, 0x00, 0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 215 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 218 0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 220 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 221 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 222 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 0x0a, 0x55, 0x54, 0x43, 223 0x30, 0x0a, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 224 0x33, 0x30, 0x37, 0x42, 0x30, 0x44, 0x30, 0x30, 0x30, 0x30, 0x38, 0x31, 225 0x41, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 226 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 227 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 228 0x30, 0x30, 0x30, 0x30, 0x35, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 229 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 230 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 231 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30, 0x30, 0x30, 232 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x65, 0x74, 0x63, 0x2f, 0x72, 0x65, 233 0x73, 0x6f, 0x6c, 0x76, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x00, 0x00, 0x00, 234 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31, 235 0x39, 0x32, 0x2e, 0x31, 0x36, 0x38, 0x2e, 0x31, 0x2e, 0x31, 0x30, 0x0a, 236 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x20, 0x48, 0x6f, 0x6d, 0x65, 0x2e, 237 0x0a, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x73, 0x69, 0x6e, 238 0x67, 0x6c, 0x65, 0x2d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x20, 239 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x3a, 0x31, 0x20, 0x61, 0x74, 240 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x3a, 0x35, 0x0a, 0x00, 0x00, 0x00, 241 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 242 0x43, 0x42, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x45, 0x44, 0x30, 0x30, 243 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 244 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x35, 0x38, 245 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 246 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 247 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 248 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 249 0x30, 0x30, 0x30, 0x30, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 250 0x30, 0x30, 0x6c, 0x69, 0x62, 0x36, 0x34, 0x00, 0x30, 0x37, 0x30, 0x37, 251 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 0x43, 0x34, 0x30, 0x30, 252 0x30, 0x30, 0x34, 0x31, 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 253 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 254 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 255 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 256 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 257 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 258 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 259 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x74, 0x63, 260 0x7a, 0x00, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 261 0x33, 0x30, 0x45, 0x33, 0x43, 0x43, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 262 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 263 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 264 0x30, 0x32, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 265 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 266 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 267 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 268 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 269 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x62, 0x69, 0x6e, 0x00, 0x00, 0x00, 270 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 271 0x43, 0x44, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x45, 0x44, 0x30, 0x30, 272 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 273 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x35, 0x38, 274 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 275 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 276 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 277 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 278 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 279 0x30, 0x30, 0x74, 0x6d, 0x70, 0x00, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 280 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 0x43, 0x36, 0x30, 0x30, 281 0x30, 0x30, 0x34, 0x31, 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 282 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 283 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 284 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 285 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 286 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 287 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 288 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 289 0x76, 0x00, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 290 0x33, 0x30, 0x43, 0x43, 0x32, 0x31, 0x30, 0x30, 0x30, 0x30, 0x32, 0x31, 291 0x41, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 292 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 293 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 294 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 295 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 296 0x30, 0x30, 0x30, 0x30, 0x30, 0x35, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 297 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x43, 0x30, 0x30, 298 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x6f, 299 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 300 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x43, 0x43, 0x32, 0x32, 0x30, 0x30, 301 0x30, 0x30, 0x32, 0x31, 0x41, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 302 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 303 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 304 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 305 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 306 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 307 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 308 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 309 0x76, 0x2f, 0x74, 0x74, 0x79, 0x53, 0x30, 0x00, 0x30, 0x37, 0x30, 0x37, 310 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x43, 0x43, 0x32, 0x33, 0x30, 0x30, 311 0x30, 0x30, 0x36, 0x31, 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 312 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 313 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 314 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 315 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 316 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 317 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 318 0x30, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 319 0x76, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x32, 0x00, 0x30, 0x37, 0x30, 0x37, 320 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x43, 0x43, 0x31, 0x46, 0x30, 0x30, 321 0x30, 0x30, 0x32, 0x31, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 322 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 323 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 324 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 325 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 326 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 327 0x30, 0x30, 0x30, 0x30, 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 328 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 329 0x76, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 330 0x6f, 0x6c, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 331 0x33, 0x30, 0x43, 0x43, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 332 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 333 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 334 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 335 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 336 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 337 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 338 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 339 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 340 0x6f, 0x70, 0x37, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 341 0x33, 0x30, 0x43, 0x43, 0x31, 0x37, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 342 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 343 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 344 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 345 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 346 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 347 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 348 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 349 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 350 0x6f, 0x70, 0x36, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 351 0x33, 0x30, 0x43, 0x43, 0x31, 0x42, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 352 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 353 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 354 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 355 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 356 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 357 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 358 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 359 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 360 0x6f, 0x70, 0x34, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 361 0x33, 0x30, 0x43, 0x43, 0x31, 0x44, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 362 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 363 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 364 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 365 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 366 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 367 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 368 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 369 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 370 0x6f, 0x70, 0x31, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 371 0x33, 0x30, 0x43, 0x43, 0x31, 0x45, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 372 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 373 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 374 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 375 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 376 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 377 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 378 0x30, 0x35, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 379 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 380 0x6f, 0x70, 0x35, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 381 0x33, 0x30, 0x43, 0x43, 0x32, 0x34, 0x30, 0x30, 0x30, 0x30, 0x32, 0x31, 382 0x41, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 383 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 384 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 385 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 386 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 387 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 388 0x30, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x39, 0x30, 0x30, 389 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x75, 390 0x6c, 0x6c, 0x00, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 391 0x33, 0x30, 0x43, 0x43, 0x31, 0x38, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 392 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 393 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 394 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 395 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 396 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 397 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 398 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 399 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 400 0x6f, 0x70, 0x30, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 401 0x33, 0x30, 0x43, 0x43, 0x31, 0x43, 0x30, 0x30, 0x30, 0x30, 0x36, 0x31, 402 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 403 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 404 0x30, 0x31, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 405 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 406 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 407 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 408 0x30, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x41, 0x30, 0x30, 409 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x6f, 410 0x6f, 0x70, 0x33, 0x00, 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 411 0x33, 0x30, 0x45, 0x33, 0x43, 0x39, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 412 0x45, 0x44, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 413 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 414 0x30, 0x33, 0x35, 0x38, 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 415 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 416 0x46, 0x43, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 417 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 418 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 419 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x75, 0x73, 0x72, 0x00, 0x00, 0x00, 420 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x33, 0x30, 0x45, 0x33, 421 0x43, 0x41, 0x30, 0x30, 0x30, 0x30, 0x34, 0x31, 0x45, 0x44, 0x30, 0x30, 422 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 423 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x35, 0x38, 424 0x38, 0x35, 0x41, 0x30, 0x34, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 425 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x46, 0x43, 0x30, 0x30, 426 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 427 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 428 0x30, 0x30, 0x30, 0x30, 0x30, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 429 0x30, 0x30, 0x75, 0x73, 0x72, 0x2f, 0x6c, 0x69, 0x62, 0x00, 0x00, 0x00, 430 0x30, 0x37, 0x30, 0x37, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 431 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 432 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 433 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30, 0x30, 434 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 435 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 436 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 437 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 438 0x30, 0x30, 0x30, 0x30, 0x30, 0x42, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 439 0x30, 0x30, 0x54, 0x52, 0x41, 0x49, 0x4c, 0x45, 0x52, 0x21, 0x21, 0x21, 440 0, 0, 0, 0, 441 } 442 443 testResult = []string{ 444 ".: Ino 3204033 Mode 040775 UID 1000 GID 1000 NLink 9 MTime 2017-01-23 06:18:54 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 445 "etc: Ino 3204037 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 446 "etc/localtime: Ino 3195404 Mode 0100644 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 118 Major 252 Minor 0 Rmajor 0 Rminor 0", 447 "etc/resolv.conf: Ino 3177229 Mode 0100644 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 81 Major 252 Minor 0 Rmajor 0 Rminor 0", 448 "lib64: Ino 3204043 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 449 "tcz: Ino 3204036 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 450 "bin: Ino 3204044 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 451 "tmp: Ino 3204045 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 452 "dev: Ino 3204038 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 453 "dev/console: Ino 3197985 Mode 020644 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 5 Rminor 1", 454 "dev/ttyS0: Ino 3197986 Mode 020644 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 4 Rminor 64", 455 "dev/loop2: Ino 3197987 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 2", 456 "dev/loop-control: Ino 3197983 Mode 020600 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 10 Rminor 237", 457 "dev/loop7: Ino 3197984 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 7", 458 "dev/loop6: Ino 3197975 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 6", 459 "dev/loop4: Ino 3197979 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 4", 460 "dev/loop1: Ino 3197981 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 1", 461 "dev/loop5: Ino 3197982 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 5", 462 "dev/null: Ino 3197988 Mode 020644 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 1 Rminor 3", 463 "dev/loop0: Ino 3197976 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 0", 464 "dev/loop3: Ino 3197980 Mode 060660 UID 0 GID 0 NLink 1 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 7 Rminor 3", 465 "usr: Ino 3204041 Mode 040755 UID 0 GID 0 NLink 3 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 466 "usr/lib: Ino 3204042 Mode 040755 UID 0 GID 0 NLink 2 MTime 2017-01-23 06:18:50 +0000 UTC FileSize 0 Major 252 Minor 0 Rmajor 0 Rminor 0", 467 } 468 ) 469 470 // testReproducible verifies that we can produce reproducible cpio archives for newc format. 471 func TestReproducible(t *testing.T) { 472 contents := []byte("LANAAAAAAAAAA") 473 rec := []Record{StaticRecord(contents, Info{ 474 Ino: 1, 475 Mode: syscall.S_IFREG | 2, 476 UID: 3, 477 GID: 4, 478 NLink: 5, 479 MTime: 6, 480 FileSize: 7, 481 Major: 8, 482 Minor: 9, 483 Rmajor: 10, 484 Rminor: 11, 485 Name: "foobar", 486 }), 487 } 488 489 // First test that it fails unless we make it reproducible 490 491 b1 := &bytes.Buffer{} 492 w := Newc.Writer(b1) 493 if err := WriteRecords(w, rec); err != nil { 494 t.Errorf("Could not write record %q: %v", rec[0].Name, err) 495 } 496 rec[0].ReaderAt = bytes.NewReader(contents) 497 b2 := &bytes.Buffer{} 498 w = Newc.Writer(b2) 499 rec[0].MTime++ 500 if err := WriteRecords(w, rec); err != nil { 501 t.Errorf("Could not write record %q: %v", rec[0].Name, err) 502 } 503 504 if reflect.DeepEqual(b1.Bytes()[:], b2.Bytes()[:]) { 505 t.Error("Reproducible: compared as same, wanted different") 506 } 507 508 // Second test that it works if we make it reproducible 509 // It does indeed fail without the second call. 510 511 b1 = &bytes.Buffer{} 512 w = Newc.Writer(b1) 513 rec[0].ReaderAt = bytes.NewReader([]byte(contents)) 514 MakeAllReproducible(rec) 515 if err := WriteRecords(w, rec); err != nil { 516 t.Errorf("Could not write record %q: %v", rec[0].Name, err) 517 } 518 519 b2 = &bytes.Buffer{} 520 w = Newc.Writer(b2) 521 rec[0].MTime++ 522 rec[0].ReaderAt = bytes.NewReader([]byte(contents)) 523 MakeAllReproducible(rec) 524 if err := WriteRecords(w, rec); err != nil { 525 t.Errorf("Could not write record %q: %v", rec[0].Name, err) 526 } 527 528 if len(b1.Bytes()) != len(b2.Bytes()) { 529 t.Fatalf("Reproducible \n%v,\n%v: len is different, wanted same", b1.Bytes()[:], b2.Bytes()[:]) 530 } 531 if !reflect.DeepEqual(b1.Bytes()[:], b2.Bytes()[:]) { 532 t.Error("Reproducible: compared different, wanted same") 533 for i := range b1.Bytes() { 534 a := b1.Bytes()[i] 535 b := b2.Bytes()[i] 536 if a != b { 537 t.Errorf("\tb1[%d] is %v, b2[%d] is %v", i, a, i, b) 538 } 539 } 540 } 541 }