| /*********************************************************************** |
| * Copyright (c) 2017-2018, Intel Corporation |
| * |
| * All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are met: |
| * |
| * 1. Redistributions of source code must retain the above copyright notice, |
| * this list of conditions and the following disclaimer. |
| * |
| * 2. Redistributions in binary form must reproduce the above copyright notice, |
| * this list of conditions and the following disclaimer in the documentation |
| * and/or other materials provided with the distribution. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| * THE POSSIBILITY OF SUCH DAMAGE. |
| ***********************************************************************/ |
| #include <stdlib.h> |
| |
| #include "tss2_sys.h" |
| |
| #include <stdio.h> |
| #define LOGMODULE test |
| #include "util/log.h" |
| #include "test.h" |
| |
| #define TSSWG_INTEROP 1 |
| #define TSS_SAPI_FIRST_FAMILY 2 |
| #define TSS_SAPI_FIRST_LEVEL 1 |
| #define TSS_SAPI_FIRST_VERSION 108 |
| |
| /** |
| */ |
| int |
| test_invoke (TSS2_SYS_CONTEXT *sapi_context) |
| { |
| TSS2_RC rc; |
| UINT32 contextSize; |
| TSS2_TCTI_CONTEXT *tcti_context = NULL; |
| TSS2_ABI_VERSION tstAbiVersion = { TSSWG_INTEROP, TSS_SAPI_FIRST_FAMILY, TSS_SAPI_FIRST_LEVEL, TSS_SAPI_FIRST_VERSION }; |
| |
| LOG_INFO( "ABI NEGOTIATION TESTS" ); |
| |
| /* Get the size needed for sapi context structure. */ |
| contextSize = Tss2_Sys_GetContextSize( 0 ); |
| |
| rc = Tss2_Sys_GetTctiContext (sapi_context, &tcti_context); |
| if( rc != TSS2_RC_SUCCESS ) |
| { |
| LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc); |
| exit(1); |
| } |
| |
| /* Initialize the system context structure. */ |
| tstAbiVersion.tssCreator = 0xF0000000; |
| rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion ); |
| if( rc != TSS2_SYS_RC_ABI_MISMATCH ) |
| { |
| LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc); |
| exit(1); |
| } |
| |
| tstAbiVersion.tssCreator = TSSWG_INTEROP; |
| tstAbiVersion.tssFamily = 0xF0000000; |
| rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion ); |
| if( rc != TSS2_SYS_RC_ABI_MISMATCH ) |
| { |
| LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc); |
| exit(1); |
| } |
| |
| tstAbiVersion.tssFamily = TSS_SAPI_FIRST_FAMILY; |
| tstAbiVersion.tssLevel = 0xF0000000; |
| rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion ); |
| if( rc != TSS2_SYS_RC_ABI_MISMATCH ) |
| { |
| LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc); |
| exit(1); |
| } |
| |
| tstAbiVersion.tssLevel = TSS_SAPI_FIRST_LEVEL; |
| tstAbiVersion.tssVersion = 0xF0000000; |
| rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion ); |
| if( rc != TSS2_SYS_RC_ABI_MISMATCH ) |
| { |
| LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc); |
| } |
| |
| |
| LOG_INFO("ABIVersion Test Passed!"); |
| return 0; |
| } |