Andreas Fuchs | a0eda36 | 2018-03-28 11:56:42 +0200 | [diff] [blame] | 1 | #include <stdbool.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | #include "tss2_sys.h" |
| 5 | |
| 6 | #define LOGMODULE test |
| 7 | #include "util/log.h" |
| 8 | #include "test-options.h" |
| 9 | #include "context-util.h" |
| 10 | |
| 11 | int |
| 12 | main (int argc, char *argv[]) |
| 13 | { |
| 14 | TSS2_RC rc; |
| 15 | TSS2_SYS_CONTEXT *sapi_context; |
| 16 | |
| 17 | test_opts_t opts = { |
| 18 | .tcti_type = TCTI_DEFAULT, |
| 19 | .device_file = DEVICE_PATH_DEFAULT, |
| 20 | .socket_address = HOSTNAME_DEFAULT, |
| 21 | .socket_port = PORT_DEFAULT, |
| 22 | }; |
| 23 | |
| 24 | get_test_opts_from_env (&opts); |
| 25 | if (sanity_check_test_opts (&opts) != 0) |
| 26 | exit (1); |
| 27 | |
| 28 | sapi_context = sapi_init_from_opts (&opts); |
| 29 | if (sapi_context == NULL) |
| 30 | exit (1); |
| 31 | |
| 32 | rc = Tss2_Sys_Startup(sapi_context, TPM2_SU_CLEAR); |
| 33 | if (rc != TSS2_RC_SUCCESS && rc != TPM2_RC_INITIALIZE) { |
| 34 | LOG_ERROR("TPM Startup FAILED! Response Code : 0x%x", rc); |
| 35 | exit(1); |
| 36 | } |
| 37 | |
| 38 | sapi_teardown_full (sapi_context); |
| 39 | return 0; |
| 40 | } |