Skip to content

Commit

Permalink
IWYU: Convert FAPI 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 a838d33 commit 5a86708
Show file tree
Hide file tree
Showing 50 changed files with 557 additions and 583 deletions.
23 changes: 8 additions & 15 deletions test/integration/fapi-check-wrong-paths.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@
#ifdef HAVE_CONFIG_H
#include "config.h" // IWYU pragma: keep
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <json-c/json.h>
#include <json-c/json_util.h>
#include <json-c/json_tokener.h>

#include "tss2_fapi.h"

#include "test-fapi.h"
#include <stdio.h> // for NULL
#include <stdlib.h> // for EXIT_FAILURE, EXIT_SUCCESS

#include "test-fapi.h" // for test_invoke_fapi
#include "tss2_common.h" // for TSS2_FAPI_RC_BAD_PATH, TSS2_RC_SUCCESS, TSS...
#include "tss2_fapi.h" // for Fapi_CreateKey, Fapi_Delete, Fapi_CreateNv

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for goto_if_error, LOG_ERROR

#define EVENT_SIZE 10

Expand Down
30 changes: 15 additions & 15 deletions test/integration/fapi-data-crypt.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
#include "config.h" // IWYU pragma: keep
#endif

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

#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>

#include "tss2_fapi.h"

#include "test-fapi.h"
#include <openssl/bio.h> // for BIO_free, BIO_new_mem_buf
#include <openssl/evp.h> // for EVP_DigestSignFinal, EVP_PKEY_free, EVP...
#include <openssl/pem.h> // for PEM_read_bio_PrivateKey
#include <openssl/rsa.h> // for EVP_PKEY_CTX_set_rsa_padding, RSA_PKCS1...
#include <stdint.h> // for uint8_t, uint32_t
#include <stdio.h> // for NULL, fopen, size_t, fclose, fileno, fseek
#include <stdlib.h> // for malloc, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for memcmp, strlen, strcmp, strncmp
#include <unistd.h> // for read

#include "test-fapi.h" // for pcr_reset, EXIT_SKIP, test_invoke_fapi
#include "tss2_common.h" // for TSS2_FAPI_RC_GENERAL_FAILURE, TSS2_RC
#include "tss2_fapi.h" // for Fapi_Free, Fapi_Delete, Fapi_Decrypt
#include "tss2_tpm2_types.h" // for TPM2_ALG_SHA256

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for LOG_ERROR, goto_if_error, SAFE_FREE

#define SIZE 128

Expand Down
16 changes: 8 additions & 8 deletions test/integration/fapi-duplicate.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h> // for NULL, fopen, fclose, fileno, fprintf, fseek
#include <stdlib.h> // for malloc, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strlen
#include <unistd.h> // for read

#include "tss2_fapi.h"
#include "test-fapi.h" // for ASSERT, pcr_reset, ASSERT_SIZE, CHECK_JSON_...
#include "tss2_common.h" // for TSS2_FAPI_RC_MEMORY, TSS2_RC
#include "tss2_fapi.h" // for Fapi_Import, Fapi_CreateKey, Fapi_Delete

#include "test-fapi.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for goto_if_error, SAFE_FREE, LOG_ERROR, LOG_INFO

#define SIZE 2000

Expand Down
30 changes: 12 additions & 18 deletions test/integration/fapi-export-policy.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <json-c/json.h>
#include <json-c/json_util.h>

#include "tss2_fapi.h"
#include "tss2_esys.h"
#include "tss2_tcti.h"

#include "test-fapi.h"
#include "test-fapi-policies.h"
#include <json-c/json.h> // for json_object, json_object_put, json_object_to_js...
#include <stdbool.h> // for bool, false, true
#include <stdio.h> // for NULL, fopen, fprintf, fclose, fileno
#include <stdlib.h> // for malloc, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strlen, strcmp
#include <unistd.h> // for read

#include "test-fapi-policies.h" // for policy_digests, _test_fapi_policy_p...
#include "test-fapi.h" // for pcr_reset, ASSERT, ASSERT_SIZE, tes...
#include "tss2_common.h" // for TSS2_RC
#include "tss2_fapi.h" // for Fapi_Delete, FAPI_CONTEXT, Fapi_Exp...

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for LOG_ERROR, goto_if_error, SAFE_FREE

/** Check the digest values from result table for sha1 and sha256. */
static bool
Expand Down
28 changes: 14 additions & 14 deletions test/integration/fapi-ext-public-key.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <openssl/evp.h>
#include <openssl/aes.h>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <inttypes.h>

#include "tss2_fapi.h"
#include <inttypes.h> // for uint8_t
#include <openssl/bio.h> // for BIO_free, BIO_new_mem_buf
#include <openssl/evp.h> // for EVP_PKEY_CTX_free, EVP_PKEY_free, EVP_PKE...
#include <openssl/pem.h> // for PEM_read_bio_PrivateKey
#include <openssl/rsa.h> // for EVP_PKEY_CTX_set_rsa_padding, RSA_PKCS1_P...
#include <stddef.h> // for NULL, size_t
#include <stdio.h> // for fprintf, stderr
#include <stdlib.h> // for EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strcmp, strlen

#include "tss2_common.h" // for TSS2_RC
#include "tss2_fapi.h" // for Fapi_Delete, Fapi_Import, Fapi_GetCertifi...

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "test-fapi.h"
#include "test-fapi.h" // for ASSERT, ASSERT_SIZE, test_invoke_fapi
#include "util/log.h" // for goto_if_error, LOG_ERROR, SAFE_FREE, LOG_...

/** Test the FAPI functions use an external public key for signature and quote verify without TPM.
*
Expand Down
26 changes: 14 additions & 12 deletions test/integration/fapi-get-esys-blobs.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <json-c/json.h> // for json_object, json_object_put, json_object_to_js...
#include <stdint.h> // for uint8_t
#include <stdio.h> // for sprintf
#include <stdlib.h> // for NULL, size_t, EXIT_FAILURE, EXIT_SUC...
#include <string.h> // for memcpy, strncmp

#include "fapi_int.h" // for FAPI_CONTEXT
#include "test-fapi.h" // for ASSERT, FAPI_PROFILE, EXIT_SKIP, tes...
#include "tss2_common.h" // for TSS2_RC, TSS2_RC_SUCCESS, BYTE, TSS2...
#include "tss2_esys.h" // for Esys_FlushContext, Esys_TR_Deserialize
#include "tss2_fapi.h" // for FAPI_CONTEXT, Fapi_Delete, Fapi_GetE...
#include "tss2_tpm2_types.h" // for TPM2_ALG_SHA256, TPM2B_AUTH, TPM2B_P...

#include "tss2_fapi.h"
#include "tss2_esys.h"

#include "test-fapi.h"
#include "fapi_util.h"
#include "fapi_int.h"

#include "esys_iutil.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "tss2_mu.h"
#include "tss2_mu.h" // for Tss2_MU_TPMS_CONTEXT_Unmarshal
#include "util/log.h" // for goto_if_error, SAFE_FREE, LOG_ERROR

#define PASSWORD "abc"
#define SIGN_TEMPLATE "sign,noDa"
Expand Down
13 changes: 8 additions & 5 deletions test/integration/fapi-get-random.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <poll.h> // for poll
#include <stdint.h> // for uint8_t
#include <stdlib.h> // for NULL, size_t, EXIT_FAILURE

#include "tss2_fapi.h"
#include "test-fapi.h"
#include "test-fapi.h" // for ASSERT, test_invoke_fapi
#include "tss2_common.h" // for TSS2_RC_SUCCESS, TSS2_FAPI_RC_NO_HANDLE
#include "tss2_fapi.h" // for Fapi_Free, Fapi_Delete, Fapi_GetPollHan...
#include "tss2_tpm2_types.h" // for TPMU_HA

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for goto_if_error, LOG_ERROR

/** Test the FAPI function FAPI_GetRandom and async invocations.
*
Expand Down
19 changes: 8 additions & 11 deletions test/integration/fapi-import-ossl-key.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <json-c/json.h>
#include <json-c/json_util.h>
#include <json-c/json_tokener.h>
#include <json-c/json.h> // for json_object, json_object_put, json_object_to_js...
#include <stdio.h> // for NULL
#include <stdlib.h> // for EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strcmp, strdup, strlen, strncmp

#include "tss2_fapi.h"
#include "test-fapi.h" // for ASSERT, ASSERT_SIZE, test_invoke_fapi
#include "tss2_common.h" // for TSS2_RC
#include "tss2_fapi.h" // for Fapi_Delete, Fapi_ExportKey, Fapi_I...

#include "test-fapi.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for LOG_ERROR, SAFE_FREE, goto_if_error

#define SIZE 2000

Expand Down
12 changes: 6 additions & 6 deletions test/integration/fapi-info.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 <string.h>
#include <stdlib.h> // for NULL, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strlen

#include "tss2_fapi.h"
#include "tss2_common.h" // for TSS2_RC
#include "tss2_fapi.h" // for Fapi_GetInfo, FAPI_CONTEXT

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "test-fapi.h"
#include "test-fapi.h" // for ASSERT, CHECK_JSON_FIELDS, ASSERT_SIZE, tes...
#include "util/log.h" // for SAFE_FREE, LOG_INFO, goto_if_error

/** Test the FAPI functions for GetInfo.
*
Expand Down
16 changes: 9 additions & 7 deletions test/integration/fapi-key-change-auth.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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h> // for uint8_t
#include <stdio.h> // for NULL, asprintf, size_t
#include <stdlib.h> // for exit, free, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strlen, strstr

#include "tss2_fapi.h"
#include "tss2_common.h" // for TSS2_RC, BYTE, TSS2_FAPI_RC_BAD_VALUE
#include "tss2_fapi.h" // for Fapi_Delete, Fapi_ChangeAuth, Fapi_Crea...
#include "tss2_tpm2_types.h" // for TPM2B_DIGEST

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "test-fapi.h"
#include "test-fapi.h" // for ASSERT, fapi_profile, test_invoke_fapi
#include "util/log.h" // for goto_if_error, SAFE_FREE, UNUSED, retur...

#define PASSWORD "abc"
#define USER_DATA "my user data"
Expand Down
14 changes: 8 additions & 6 deletions test/integration/fapi-key-create-ckda-sign.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 <string.h>
#include <stdint.h> // for uint8_t
#include <stdlib.h> // for NULL, EXIT_FAILURE, EXIT_SUCCESS, size_t
#include <string.h> // for strstr, strcmp

#include "tss2_fapi.h"
#include "tss2_common.h" // for TSS2_RC, BYTE, TSS2_FAPI_RC_BAD_VALUE
#include "tss2_fapi.h" // for Fapi_Delete, Fapi_CreateKey, Fapi_Provi...
#include "tss2_tpm2_types.h" // for TPM2B_DIGEST

#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "test-fapi.h"
#include "test-fapi.h" // for ASSERT, test_invoke_fapi
#include "util/log.h" // for SAFE_FREE, goto_if_error, UNUSED, retur...

#ifdef FAPI_PASSWORD

Expand Down
19 changes: 9 additions & 10 deletions test/integration/fapi-key-create-he-sign.int.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@
#include "config.h" // IWYU pragma: keep
#endif

#include <stdlib.h>
#include <string.h>
#include <stdbool.h> // for bool, false, true
#include <stdint.h> // for uint8_t
#include <stdlib.h> // for NULL, size_t, EXIT_FAILURE, EXIT_SUCCESS
#include <string.h> // for strcmp, strlen, strncmp

#include "tss2_fapi.h"
#include "test-fapi.h" // for ASSERT, ASSERT_SIZE, fapi_profile, test...
#include "tss2_common.h" // for TSS2_RC, BYTE, TSS2_FAPI_RC_GENERAL_FAI...
#include "tss2_fapi.h" // for Fapi_Delete, Fapi_CreateKey, Fapi_Provi...
#include "tss2_tpm2_types.h" // for TPM2B_DIGEST

#include "test-fapi.h"
#include "fapi_util.h"
#include "fapi_int.h"

#include "esys_iutil.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for goto_if_error, SAFE_FREE, UNUSED, LOG_E...

#define PASSWORD "abc"
#define SIGN_TEMPLATE "sign,noDa"
Expand Down
19 changes: 10 additions & 9 deletions test/integration/fapi-key-create-null-key-sign.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 <stdlib.h>
#include <json-c/json.h> // for json_object, json_object_put, json_object_to_js...
#include <stdint.h> // for uint8_t
#include <stdio.h> // for sprintf
#include <stdlib.h> // for NULL, size_t, EXIT_FAILURE, EXIT_SUC...
#include <string.h> // for strncmp

#include "tss2_fapi.h"
#include "test-fapi.h" // for init_fapi, fapi_profile, test_invoke...
#include "tss2_common.h" // for TSS2_FAPI_RC_BAD_VALUE, TSS2_RC_SUCCESS
#include "tss2_fapi.h" // for Fapi_CreateKey, Fapi_Delete, Fapi_Fi...
#include "tss2_tpm2_types.h" // for TPM2B_DIGEST

#include "test-fapi.h"
#include "fapi_util.h"
#include "fapi_int.h"

#include "esys_iutil.h"
#define LOGMODULE test
#include "util/log.h"
#include "util/aux_util.h"
#include "util/log.h" // for goto_if_error, SAFE_FREE, UNUSED

#define PASSWORD "abc"
#define SIGN_TEMPLATE "sign,noDa"
Expand Down
Loading

0 comments on commit 5a86708

Please sign in to comment.