Skip to content

Commit

Permalink
IWYU: Convert SYS tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Fuchs <[email protected]>
  • Loading branch information
AndreasFuchsTPM committed May 3, 2024
1 parent a2c2cfa commit d7e5c33
Show file tree
Hide file tree
Showing 35 changed files with 316 additions and 277 deletions.
28 changes: 12 additions & 16 deletions test/helper/tpm_cmd_tcti_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include <unistd.h>

#include "tss2_sys.h"
#include "tss2_mu.h"

#include "tcti-common.h"
#include "tcti-cmd-test.h"
#include <errno.h> // for errno, EINTR
#include <inttypes.h> // for uint8_t, PRIu32
#include <stdbool.h> // for true, bool, false
#include <stdio.h> // for ferror, fread, setvbuf, stdin, size_t
#include <stdlib.h> // for exit, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strcmp, strerror, memcmp
#include <unistd.h> // for getpid

#include "tcti-cmd-test.h" // for getcap_command, getcap_good_resp
#include "tcti-common.h" // for tpm_header_t, TPM_HEADER_SIZE, header_unm...
#include "tss2_common.h" // for TSS2_RC, TSS2_RC_SUCCESS

#define LOGMODULE test
#include "util/log.h"
#include "util/log.h" // for LOG_ERROR, LOG_DEBUG, LOGBLOB_DEBUG

/*
* A malformed header response. The header reports smaller than the actual
Expand Down
14 changes: 5 additions & 9 deletions test/integration/main-sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdbool.h>
#include <stdlib.h>

#define LOGMODULE test
#include "tss2_tctildr.h"
#include "tss2_sys.h"
#include "util/log.h"
#include "test.h"

#include "test-common.h"
#include "test-common.h" // for test_sys_checks_post, test_sys_checks_pre
#include "test.h" // for test_invoke
#include "tss2_common.h" // for TSS2_RC
#include "util/aux_util.h" // for UNUSED
#include "util/log.h" // for LOG_ERROR

/**
* This program is a template for integration tests (ones that use the TCTI
Expand Down
14 changes: 8 additions & 6 deletions test/integration/sys-abi-version.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit

#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_ABI_VERSION, TSS2_SYS_RC_ABI_MISMATCH
#include "tss2_sys.h" // for Tss2_Sys_Initialize, Tss2_Sys_GetContextSize
#include "tss2_tcti.h" // for TSS2_TCTI_CONTEXT

#include <stdio.h>
#define LOGMODULE test
#include "util/log.h"
#include "test-common.h"
#include "test.h"
#include "test-common.h" // for TEST_ABI_VERSION, TSSWG_INTEROP, TSS_SYS_FI...
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR, LOG_INFO

/**
*/
Expand Down
19 changes: 10 additions & 9 deletions test/integration/sys-asymmetric-encrypt-decrypt.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <inttypes.h> // for PRIx32
#include <stdlib.h> // for exit
#include <string.h> // for memcpy, strlen

#include "tss2_tcti.h"
#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_RC_SUCCESS, UINT32, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_FlushContext, Tss2_Sys_Create
#include "tss2_tpm2_types.h" // for TPM2B_PUBLIC, TPMT_PUBLIC, TPM2B_PUBLIC...

#define LOGMODULE test
#include "util/log.h"
#include "test.h"
#include "sys-util.h"
#include "sys-util.h" // for TSS2_RETRY_EXP
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR, LOG_INFO

/**
* This program contains integration test for asymmetric encrypt and
* decrypt use case that has SYSs Tss2_Sys_CreatePrimary,
Expand Down
13 changes: 7 additions & 6 deletions test/integration/sys-create-keyedhash-sha1-hmac.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <inttypes.h> // for PRIx32

#include "tss2_tpm2_types.h"
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_Create, Tss2_Sys_FlushContext
#include "tss2_tpm2_types.h" // for TPM2B_PUBLIC, TPMT_PUBLIC, TPM2_ALG_SHA1

#include "inttypes.h"
#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "test.h"
#include "sys-util.h" // for create_primary_rsa_2048_aes_128_cfb
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR, LOG_INFO

int
test_invoke (TSS2_SYS_CONTEXT *sys_context)
Expand Down
16 changes: 9 additions & 7 deletions test/integration/sys-create-loaded.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h> // for PRIx32, uint8_t
#include <stdlib.h> // for exit, NULL, size_t
#include <string.h> // for memset, memcpy

#include "tss2_mu.h"
#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_RC, TSS2_RC_SUCCESS, TSS2_BASE_RC_...
#include "tss2_mu.h" // for Tss2_MU_TPMT_PUBLIC_Marshal
#include "tss2_sys.h" // for Tss2_Sys_CreateLoaded, Tss2_Sys_FlushCo...
#include "tss2_tpm2_types.h" // for TPMT_PUBLIC, TPM2B_NAME, TPMS_RSA_PARMS

#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "sys-util.h" // for TPM2B_NAME_INIT
#include "util/log.h" // for LOG_ERROR, LOG_INFO, LOGBLOB_INFO

TSS2_RC
test_invoke (TSS2_SYS_CONTEXT *sys_context)
Expand Down
17 changes: 10 additions & 7 deletions test/integration/sys-encrypt-decrypt-2.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h> // for PRIx32
#include <stdlib.h> // for exit
#include <string.h> // for strcmp, strcpy, strlen

#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "test-esys.h"
#include "test.h"
#include "sys-util.h" // for create_aes_128_cfb, create_primary_rsa_...
#include "test-esys.h" // for EXIT_SKIP
#include "test.h" // for test_invoke
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_FlushContext, TSS2_SYS_CONTEXT
#include "tss2_tpm2_types.h" // for TPM2B_MAX_BUFFER, TPM2_HANDLE, TPM2_RC_...
#include "util/log.h" // for LOG_ERROR, LOG_INFO, LOG_WARNING

#define ENC_STR "test-data-test-data-test-data"

Expand Down
17 changes: 10 additions & 7 deletions test/integration/sys-encrypt-decrypt.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h> // for PRIx32
#include <stdlib.h> // for exit
#include <string.h> // for strcmp, strcpy, strlen

#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "test-esys.h"
#include "test.h"
#include "sys-util.h" // for create_aes_128_cfb, create_primary_rsa_...
#include "test-esys.h" // for EXIT_SKIP
#include "test.h" // for test_invoke
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_FlushContext, TSS2_SYS_CONTEXT
#include "tss2_tpm2_types.h" // for TPM2B_MAX_BUFFER, TPM2_HANDLE, TPM2_RC_...
#include "util/log.h" // for LOG_ERROR, LOG_INFO, LOG_WARNING

#define ENC_STR "test-data-test-data-test-data"

Expand Down
10 changes: 7 additions & 3 deletions test/integration/sys-entity-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
#include "config.h" // IWYU pragma: keep
#endif

#include "tss2_tpm2_types.h"
#include "sys-util.h"
#include "session-util.h"
#include <stdlib.h> // for calloc, free, NULL
#include <uthash.h> // for UT_hash_handle, HASH_FIND_INT, HASH_ADD...

#include "session-util.h" // for ENTITY, AddEntity, DeleteEntity, GetEntity
#include "sys-util.h" // for CopySizedByteBuffer
#include "tss2_tpm2_types.h" // for TPM2_HANDLE, TPM2B_AUTH
#include "util/tpm2b.h" // for TPM2B

static ENTITY *entities = NULL;

Expand Down
12 changes: 8 additions & 4 deletions test/integration/sys-evict-ctrl.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
#include "config.h" // IWYU pragma: keep
#endif

#include "inttypes.h"
#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "test.h"
#include <inttypes.h> // for PRIx32

#include "sys-util.h" // for create_primary_rsa_2048_aes_128_cfb
#include "test.h" // for test_invoke
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_EvictControl, Tss2_Sys_FlushCo...
#include "tss2_tpm2_types.h" // for TPM2_RH_OWNER, TPM2_HANDLE, TPM2_RC_SUC...
#include "util/log.h" // for LOG_INFO, LOG_ERROR

int
test_invoke (TSS2_SYS_CONTEXT *sys_context)
Expand Down
13 changes: 7 additions & 6 deletions test/integration/sys-get-random.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h> // for exit
#include <string.h> // for memcmp

#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC
#include "tss2_sys.h" // for Tss2_Sys_GetRandom, TSS2_SYS_CONTEXT
#include "tss2_tpm2_types.h" // for TPM2B_DIGEST

#define LOGMODULE test
#include "util/log.h"
#include "test.h"
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR, LOG_INFO

/**
* This program contains integration test for SYS Tss2_Sys_GetRandom.
Expand Down
12 changes: 6 additions & 6 deletions test/integration/sys-hierarchy-change-auth.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <stdlib.h> // for exit

#include "tss2_sys.h"
#include "tss2_common.h" // for BYTE, UINT32
#include "tss2_sys.h" // for Tss2_Sys_HierarchyChangeAuth, TSS2L_SYS...
#include "tss2_tpm2_types.h" // for TPM2B_AUTH, TPMS_AUTH_COMMAND, TPM2_RC_...

#include "inttypes.h"
#define LOGMODULE test
#include "util/log.h"
#include "sys-util.h"
#include "test.h"
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR, LOG_INFO

/*
* Test auth value changes for Owner Auth
Expand Down
17 changes: 8 additions & 9 deletions test/integration/sys-hmac-auth.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h> // for NULL
#include <string.h> // for memcmp

#include "tss2_sys.h"
#include "session-util.h" // for roll_nonces, SESSION, check_response_hmac
#include "sys-util.h" // for DefineNvIndex, TPM2B_SIZE, TSS2_RETRY_EXP
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_RC, BYTE
#include "tss2_sys.h" // for Tss2_Sys_PolicyAuthValue, TSS2L_SYS_AUT...
#include "tss2_tpm2_types.h" // for TPM2_RH_NULL, TPMS_AUTH_COMMAND, TPM2B_...

#include "sys-util.h"
#include "session-util.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/log.h" // for LOG_ERROR, LOG_INFO

#define TPM20_INDEX_PASSWORD_TEST 0x01500020

Expand Down
22 changes: 9 additions & 13 deletions test/integration/sys-hmac.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include "tss2_tpm2_types.h"
#include "tss2_sys.h"
#include "util/tpm2b.h"
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit
#include <string.h> // for memcpy

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>

#include "tss2_tcti.h"
#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_BASE_RC_BAD_REFER...
#include "tss2_sys.h" // for Tss2_Sys_CreatePrimary, Tss2_Sys_FlushC...
#include "tss2_tpm2_types.h" // for TPM2B_PUBLIC, TPM2B_DIGEST, TPMT_PUBLIC

#define LOGMODULE test
#include "util/log.h"
#include "test.h"
#include "sys-util.h"
#include "sys-util.h" // for TSS2_RETRY_EXP
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR

int
test_sys_hmac(TSS2_SYS_CONTEXT * sys_context)
Expand Down
22 changes: 9 additions & 13 deletions test/integration/sys-mac.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include "tss2_tpm2_types.h"
#include "tss2_sys.h"
#include "util/tpm2b.h"
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit
#include <string.h> // for memcpy

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>

#include "tss2_tcti.h"
#include "tss2_sys.h"
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_BASE_RC_BAD_REFER...
#include "tss2_sys.h" // for Tss2_Sys_CreatePrimary, Tss2_Sys_FlushC...
#include "tss2_tpm2_types.h" // for TPM2B_PUBLIC, TPM2B_DIGEST, TPMT_PUBLIC

#define LOGMODULE test
#include "util/log.h"
#include "test.h"
#include "sys-util.h"
#include "sys-util.h" // for TSS2_RETRY_EXP
#include "test.h" // for test_invoke
#include "util/log.h" // for LOG_ERROR

int
test_sys_mac(TSS2_SYS_CONTEXT * sys_context)
Expand Down
Loading

0 comments on commit d7e5c33

Please sign in to comment.