mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
Integration tests: use simulated TPM in debug coordinator
Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
parent
bcd8c36777
commit
4c73c5076e
@ -43,3 +43,31 @@ func (t nopTPM) Write(p []byte) (int, error) {
|
||||
func (t nopTPM) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type simulatedTPM struct {
|
||||
openSimulatedTPM io.ReadWriteCloser
|
||||
}
|
||||
|
||||
// NewSimulatedTPMOpenFunc returns a TPMOpenFunc that opens a simulated TPM.
|
||||
func NewSimulatedTPMOpenFunc() (TPMOpenFunc, io.Closer) {
|
||||
tpm, err := OpenSimulatedTPM()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return func() (io.ReadWriteCloser, error) {
|
||||
return &simulatedTPM{tpm}, nil
|
||||
}, tpm
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Read(p []byte) (int, error) {
|
||||
return t.openSimulatedTPM.Read(p)
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Write(p []byte) (int, error) {
|
||||
return t.openSimulatedTPM.Write(p)
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Close() error {
|
||||
// never close the underlying simulated TPM to allow calling the TPMOpenFunc again
|
||||
return nil
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
Loading…
Reference in New Issue
Block a user