| 1 |
//go:build !windows |
| 2 |
|
| 3 |
package linuxudstpm |
| 4 |
|
| 5 |
import ( |
| 6 |
"flag" |
| 7 |
"os" |
| 8 |
"syscall" |
| 9 |
"testing" |
| 10 |
|
| 11 |
"github.com/google/go-tpm/tpm2/transport" |
| 12 |
testhelper "github.com/google/go-tpm/tpm2/transport/test" |
| 13 |
) |
| 14 |
|
| 15 |
var tpmSocket = flag.String("tpm_socket", "/dev/tpm0", "path to the TPM simulator UDS") |
| 16 |
|
| 17 |
func TestMain(m *testing.M) { |
| 18 |
flag.Parse() |
| 19 |
os.Exit(m.Run()) |
| 20 |
} |
| 21 |
|
| 22 |
func open() func() (transport.TPMCloser, error) { |
| 23 |
return func() (transport.TPMCloser, error) { |
| 24 |
return Open(*tpmSocket) |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
func TestLocalUDSTPM(t *testing.T) { |
| 29 |
testhelper.RunTest(t, []error{os.ErrNotExist, os.ErrPermission, ErrFileIsNotSocket, syscall.ECONNREFUSED}, open()) |
| 30 |
} |