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