mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-11-13 09:00:38 -05: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
2 changed files with 29 additions and 0 deletions
|
|
@ -43,3 +43,31 @@ func (t nopTPM) Write(p []byte) (int, error) {
|
||||||
func (t nopTPM) Close() error {
|
func (t nopTPM) Close() error {
|
||||||
return nil
|
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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue