15 #include "../audit_tests_common.h"
22 #define BASE_RETRIEVAL_LOG_INDEX (6)
29 #define FIRST_RETRIEVAL_LOG_INDEX (0)
34 static struct test_t audit_veneers_tests[] = {
35 {&tfm_audit_test_1001,
"TFM_AUDIT_TEST_1001",
43 list_size = (
sizeof(audit_veneers_tests) /
44 sizeof(audit_veneers_tests[0]));
46 set_testsuite(
"Audit Logging secure interface test (TFM_AUDIT_TEST_1XXX)",
47 audit_veneers_tests, list_size, p_test_suite);
69 uint32_t num_records, stored_size, record_size;
82 TEST_FAIL(
"Record addition has returned an error");
90 TEST_FAIL(
"Getting log info has returned error");
99 if (num_records != INITIAL_LOGGING_REQUESTS) {
100 TEST_FAIL(
"Expected log records are " STR(INITIAL_LOGGING_REQUESTS));
117 TEST_FAIL(
"Retrieve indexes 6 or 7 has returned an error");
132 (BASE_RETRIEVAL_LOG_INDEX+1) )) {
133 TEST_FAIL(
"Unexpected argument in the index 7 entry");
138 for (idx=num_records-2; idx<num_records; idx++) {
150 TEST_FAIL(
"Retrieve of last two log records has returned error");
165 (INITIAL_LOGGING_REQUESTS-2) )) {
166 TEST_FAIL(
"Unexpected argument in the second last entry");
179 TEST_FAIL(
"Retrieve of the first log entry has returned error");
189 TEST_FAIL(
"Unexpected argument in the first entry");
201 TEST_FAIL(
"Retrieve of last two log entries has returned error");
212 (INITIAL_LOGGING_REQUESTS-1) )) {
213 TEST_FAIL(
"Unexpected argument in the second last entry");
224 TEST_FAIL(
"Record addition has returned an error");
231 TEST_FAIL(
"Getting log info has returned error");
244 if (num_records != INITIAL_LOGGING_REQUESTS) {
245 TEST_FAIL(
"Expected log records are " STR(INITIAL_LOGGING_REQUESTS));
250 for (idx=num_records-2; idx<num_records; idx++) {
263 TEST_FAIL(
"Retrieve of last two log records has returned error");
275 (INITIAL_LOGGING_REQUESTS-1) )) {
276 TEST_FAIL(
"Unexpected argument in the second last entry");
285 (INITIAL_LOGGING_REQUESTS) )) {
286 TEST_FAIL(
"Unexpected argument in the last entry");
297 TEST_FAIL(
"Record addition has returned an error");
304 TEST_FAIL(
"Getting log info has returned error");
314 if (num_records != 1) {
331 TEST_FAIL(
"Retrieve of index 0 should fail as it's too big");
335 if (record_size != 0) {
336 TEST_FAIL(
"Retrieved log size has unexpected size instead of 0");
341 for (idx=0; idx<2; idx++) {
344 INITIAL_LOGGING_REQUESTS + 2 + idx;
349 TEST_FAIL(
"Record addition has returned an error");
357 TEST_FAIL(
"Getting log info has returned error");
376 for (idx=0; idx<num_records; idx++) {
379 TEST_FAIL(
"Getting record size individually has returned error");
384 TEST_FAIL(
"Unexpected log record size for a single standard item");
392 TEST_FAIL(
"Getting record size for non-existent record has not failed");
#define STANDARD_LOG_ENTRY_SIZE
A log item with no payload (standard size) has the following size. More details can be found observin...
#define MAX_LOG_SIZE
The maximum possible log size in the current implementation.
#define STR(a)
A standard stringify macro.
#define TEST_FAIL(info_msg)
#define DUMMY_TEST_RECORD_ID_BASE
The log record is initialized with a dummy ID which uses this value as base value.
psa_status_t psa_audit_get_record_info(const uint32_t record_index, uint32_t *size)
Returns the size of the record at the specified index.
enum test_suite_err_t set_testsuite(const char *name, struct test_t *test_list, uint32_t size, struct test_suite_t *p_ts)
Sets test suite parameters.
psa_status_t psa_audit_add_record(const struct psa_audit_record *record)
Adds a record.
Fixed size header for a log record.
This structure contains the record that is added to the audit log by the requesting secure service...
#define BASE_RETRIEVAL_LOG_INDEX
Base index from where to start elements retrieval.
#define MAX_LOG_RECORD_SIZE
The maximum possible log line size to fill a MAX_LOG_SIZE bytes log.
#define FINAL_LOGGING_SIZE
Size of the final consecutive logging requests.
#define FINAL_LOGGING_REQUESTS
Number of final consecutive logging requests to perform.
#define INITIAL_LOGGING_REQUESTS
Number of initial consecutive logging requests to perform.
#define INITIAL_LOGGING_SIZE
Size of the initial consecutive logging requests.
#define LOCAL_BUFFER_SIZE
Size in bytes of the local buffer. Size accomodates two standard size (no payload) log items...
void register_testsuite_s_audit_interface(struct test_suite_t *p_test_suite)
Register testsuite for audit logging secure interface.
int32_t psa_status_t
Function return status.
psa_status_t psa_audit_get_info(uint32_t *num_records, uint32_t *size)
Returns the total number and size of the records stored.
psa_status_t psa_audit_retrieve_record(const uint32_t record_index, const uint32_t buffer_size, const uint8_t *token, const uint32_t token_size, uint8_t *buffer, uint32_t *record_size)
Retrieves a record at the specified index.