github.com/coreos/mantle@v0.13.0/kola/tests/util/update.go (about) 1 // Copyright 2018 CoreOS, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package util 16 17 import ( 18 "fmt" 19 "strings" 20 21 "github.com/coreos/mantle/kola/cluster" 22 "github.com/coreos/mantle/platform" 23 ) 24 25 func AssertBootedUsr(c cluster.TestCluster, m platform.Machine, usr string) { 26 usrdev := GetUsrDeviceNode(c, m) 27 target := c.MustSSH(m, "readlink -f /dev/disk/by-partlabel/"+usr) 28 if usrdev != string(target) { 29 c.Fatalf("Expected /usr to be %v (%s) but it is %v", usr, target, usrdev) 30 } 31 } 32 33 func GetUsrDeviceNode(c cluster.TestCluster, m platform.Machine) string { 34 // find /usr dev 35 usrdev := c.MustSSH(m, "findmnt -no SOURCE /usr") 36 37 // XXX: if the /usr dev is /dev/mapper/usr, we're on a verity enabled 38 // image, so use dmsetup to find the real device. 39 if strings.TrimSpace(string(usrdev)) == "/dev/mapper/usr" { 40 usrdev = c.MustSSH(m, "echo -n /dev/$(sudo dmsetup info --noheadings -Co blkdevs_used usr)") 41 } 42 43 return string(usrdev) 44 } 45 46 func InvalidateUsrPartition(c cluster.TestCluster, m platform.Machine, partition string) { 47 if out, stderr, err := m.SSH(fmt.Sprintf("sudo coreos-setgoodroot && sudo wipefs /dev/disk/by-partlabel/%s", partition)); err != nil { 48 c.Fatalf("invalidating %s failed: %s: %v: %s", partition, out, err, stderr) 49 } 50 }