sys-abi-version.int.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include <stdlib.h>
  11. #include "tss2_sys.h"
  12. #include <stdio.h>
  13. #define LOGMODULE test
  14. #include "util/log.h"
  15. #include "test.h"
  16. #define TSSWG_INTEROP 1
  17. #define TSS_SYS_FIRST_FAMILY 2
  18. #define TSS_SYS_FIRST_LEVEL 1
  19. #define TSS_SYS_FIRST_VERSION 108
  20. /**
  21. */
  22. int
  23. test_invoke (TSS2_SYS_CONTEXT *sys_context)
  24. {
  25. TSS2_RC rc;
  26. UINT32 contextSize;
  27. TSS2_TCTI_CONTEXT *tcti_context = NULL;
  28. TSS2_ABI_VERSION tstAbiVersion = { TSSWG_INTEROP, TSS_SYS_FIRST_FAMILY, TSS_SYS_FIRST_LEVEL, TSS_SYS_FIRST_VERSION };
  29. LOG_INFO( "ABI NEGOTIATION TESTS" );
  30. /* Get the size needed for sys context structure. */
  31. contextSize = Tss2_Sys_GetContextSize( 0 );
  32. rc = Tss2_Sys_GetTctiContext (sys_context, &tcti_context);
  33. if( rc != TSS2_RC_SUCCESS )
  34. {
  35. LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
  36. exit(1);
  37. }
  38. /* Initialize the system context structure. */
  39. tstAbiVersion.tssCreator = 0xF0000000;
  40. rc = Tss2_Sys_Initialize( sys_context, contextSize, tcti_context, &tstAbiVersion );
  41. if( rc != TSS2_SYS_RC_ABI_MISMATCH )
  42. {
  43. LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
  44. exit(1);
  45. }
  46. tstAbiVersion.tssCreator = TSSWG_INTEROP;
  47. tstAbiVersion.tssFamily = 0xF0000000;
  48. rc = Tss2_Sys_Initialize( sys_context, contextSize, tcti_context, &tstAbiVersion );
  49. if( rc != TSS2_SYS_RC_ABI_MISMATCH )
  50. {
  51. LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
  52. exit(1);
  53. }
  54. tstAbiVersion.tssFamily = TSS_SYS_FIRST_FAMILY;
  55. tstAbiVersion.tssLevel = 0xF0000000;
  56. rc = Tss2_Sys_Initialize( sys_context, contextSize, tcti_context, &tstAbiVersion );
  57. if( rc != TSS2_SYS_RC_ABI_MISMATCH )
  58. {
  59. LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
  60. exit(1);
  61. }
  62. tstAbiVersion.tssLevel = TSS_SYS_FIRST_LEVEL;
  63. tstAbiVersion.tssVersion = 0xF0000000;
  64. rc = Tss2_Sys_Initialize( sys_context, contextSize, tcti_context, &tstAbiVersion );
  65. if( rc != TSS2_SYS_RC_ABI_MISMATCH )
  66. {
  67. LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
  68. }
  69. LOG_INFO("ABIVersion Test Passed!");
  70. return 0;
  71. }