Skip to content

Commit

Permalink
Merge pull request #558 from flatcar/chewi/tpm-event-log
Browse files Browse the repository at this point in the history
kola/tests: Add new cl.tpm.eventlog test for the TPM Event log
  • Loading branch information
chewi authored Sep 17, 2024
2 parents 183aeea + e147f08 commit be36186
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions kola/tests/misc/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ func init() {
Distros: []string{"cl"},
MinVersion: semver.Version{Major: 3913, Minor: 0, Patch: 1},
})

register.Register(&register.Test{
Run: eventLogTest,
ClusterSize: 0,
Platforms: []string{"qemu"},
Name: "cl.tpm.eventlog",
Distros: []string{"cl"},
MinVersion: semver.Version{Major: 4082},
})
}

func tpmTest(c cluster.TestCluster, userData *conf.UserData, mountpoint string, variant string) {
Expand Down Expand Up @@ -359,3 +368,27 @@ func tpmTest(c cluster.TestCluster, userData *conf.UserData, mountpoint string,
checkIfMountpointIsEncrypted(c, m, "/")
}
}

func eventLogTest(c cluster.TestCluster) {
options := platform.MachineOptions{EnableTPM: true}
var (
m platform.Machine
err error
)
switch pc := c.Cluster.(type) {
// These cases have to be separated because otherwise the golang compiler doesn't type-check
// the case bodies using the proper subtype of `pc`.
case *qemu.Cluster:
m, err = pc.NewMachineWithOptions(nil, options)
case *unprivqemu.Cluster:
m, err = pc.NewMachineWithOptions(nil, options)
default:
c.Fatal("unknown cluster type")
}
if err != nil {
c.Fatal(err)
}

// Verify that the TPM event log is working.
_ = c.MustSSH(m, "sudo tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements")
}
1 change: 1 addition & 0 deletions platform/machine/unprivqemu/flight.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (qf *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
}

func (qf *flight) Destroy() {
qf.BaseFlight.Destroy()
if qf.diskImageFile != nil {
qf.diskImageFile.Close()
}
Expand Down

0 comments on commit be36186

Please sign in to comment.