sys-self-test.int.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <stdio.h>
  11. #include <stdlib.h>
  12. #include "tss2_sys.h"
  13. #define LOGMODULE test
  14. #include "util/log.h"
  15. #include "test.h"
  16. /*
  17. * This program contains integration test for SYS Tss2_Sys_SelfTest
  18. * that perform test of its capabilities. This program is calling
  19. * SelfTest SYS and make sure the response code are success
  20. * when fullTest set as YES and when it is set as NO.
  21. */
  22. int
  23. test_invoke (TSS2_SYS_CONTEXT *sys_context)
  24. {
  25. TSS2_RC rc;
  26. LOG_INFO( "SelfTest tests started." );
  27. rc = Tss2_Sys_SelfTest( sys_context, 0, YES, 0);
  28. if (rc != TSS2_RC_SUCCESS) {
  29. LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
  30. exit(1);
  31. }
  32. rc = Tss2_Sys_SelfTest( sys_context, 0, NO, 0);
  33. if (rc != TSS2_RC_SUCCESS) {
  34. LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
  35. exit(1);
  36. }
  37. rc = Tss2_Sys_SelfTest(sys_context, 0, YES, 0);
  38. if (rc != TSS2_RC_SUCCESS) {
  39. LOG_ERROR("SelfTest FAILED! Response Code : 0x%x", rc);
  40. exit(1);
  41. }
  42. LOG_INFO("SelfTest tests passed.");
  43. return 0;
  44. }