1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /***********************************************************************
3  * Copyright (c) 2017-2018, Intel Corporation
4  *
5  * All rights reserved.
6  ***********************************************************************/
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 
14 #include "tss2_sys.h"
15 
16 #define LOGMODULE test
17 #include "util/log.h"
18 #include "test.h"
19 
20 /*
21  * This program contains integration test for SAPI Tss2_Sys_SelfTest
22  * that perform test of its capabilities. This program is calling
23  * SelfTest SAPI and make sure the response code are success
24  * when fullTest set as YES and when it is set as NO.
25  */
26 int
test_invoke(TSS2_SYS_CONTEXT * sapi_context)27 test_invoke (TSS2_SYS_CONTEXT *sapi_context)
28 {
29     TSS2_RC rc;
30     LOG_INFO( "SelfTest tests started." );
31     rc = Tss2_Sys_SelfTest( sapi_context, 0, YES, 0);
32     if (rc != TSS2_RC_SUCCESS) {
33         LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
34         exit(1);
35     }
36     rc = Tss2_Sys_SelfTest( sapi_context, 0, NO, 0);
37     if (rc != TSS2_RC_SUCCESS) {
38         LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
39         exit(1);
40     }
41     rc = Tss2_Sys_SelfTest(sapi_context, 0, YES, 0);
42     if (rc != TSS2_RC_SUCCESS) {
43         LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
44         exit(1);
45     }
46     LOG_INFO("SelfTest tests passed.");
47     return 0;
48 }
49