TPM tests using swtpm are flaky
We now spawn an swtpm process for tpm unit tests, and that occasionally fails. Example failure:
--- FAIL: TestInfo (0.00s)
tpm_test.go:48:
Error Trace: tpm_test.go:48
Error: Received unexpected error:
tpm2.GetCapability(PT_VENDOR_STRING_1) failed: interrupted system call
Test: TestInfo
SWTPM_NVRAM_Lock_Dir: Could not open lockfile: No such file or directory
Error: Could not initialize libtpms.
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x63609e]
There are several errors here. The SIGSEGV/panic is due to a bug in tpm_test.go, it should terminate the test after the first error.
Then there appears to be two errors, ENOEXIST from swtpm, unclear why, probably from this line https://github.com/stefanberger/swtpm/blob/a4347aff215fb5ff80b13ba2b6b56d2b63c116c0/src/swtpm/swtpm_nvstore_dir.c#L136
Then there's an EINTR that's not handled properly (user code is supposed to retry the failing syscall). It's unclear if that is in the swtpm process, which appears to not handle EINTR, or if it is the tpm2 go library.