github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/mount/scuzz_mount_test.go (about) 1 // Copyright 2020 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 amd64 6 7 package mount_test 8 9 import ( 10 "testing" 11 12 "github.com/u-root/u-root/pkg/mount/block" 13 "github.com/u-root/u-root/pkg/mount/scuzz" 14 "github.com/u-root/u-root/pkg/testutil" 15 ) 16 17 func TestIdentify(t *testing.T) { 18 testutil.SkipIfNotRoot(t) 19 20 disk, err := scuzz.NewSGDisk("/dev/sda") 21 if err != nil { 22 t.Fatal(err) 23 } 24 defer disk.Close() 25 26 info, err := disk.Identify() 27 if err != nil { 28 t.Fatal(err) 29 } 30 t.Logf("Identify(/dev/sda): %v", info) 31 32 device, err := block.Device("/dev/sda") 33 if err != nil { 34 t.Fatal(err) 35 } 36 size, err := device.Size() 37 if err != nil { 38 t.Fatal(err) 39 } 40 41 if info.NumberSectors != size/512 { 42 t.Errorf("Identify(/dev/sda).NumberSectors = %d, want %d", info.NumberSectors, size/512) 43 } 44 }