Added a basic example Auditlog object. (#458)

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Mikhail Antropov
2025-06-23 20:18:13 +03:00
committed by GitHub
parent 464be15bae
commit 267db756b8
12 changed files with 3618 additions and 2 deletions
+2
View File
@@ -78,6 +78,7 @@ list(APPEND testdirs
bacnet/awf
bacnet/bacaddr
bacnet/bacapp
bacnet/bacaudit
bacnet/bacdcode
bacnet/bacdevobjpropref
bacnet/bacdest
@@ -143,6 +144,7 @@ list(APPEND testdirs
bacnet/basic/object/ai
bacnet/basic/object/ao
bacnet/basic/object/av
bacnet/basic/object/auditlog
bacnet/basic/object/bacfile
bacnet/basic/object/bi
bacnet/basic/object/bitstring_value
+70
View File
@@ -0,0 +1,70 @@
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(test_${basename}
VERSION 1.0.0
LANGUAGES C)
string(REGEX REPLACE
"/test/bacnet/[a-zA-Z_/-]*$"
"/src"
SRC_DIR
${CMAKE_CURRENT_SOURCE_DIR})
string(REGEX REPLACE
"/test/bacnet/[a-zA-Z_/-]*$"
"/test"
TST_DIR
${CMAKE_CURRENT_SOURCE_DIR})
set(ZTST_DIR "${TST_DIR}/ztest/src")
add_compile_definitions(
BIG_ENDIAN=0
CONFIG_ZTEST=1
BACAPP_MINIMAL=1
BACAPP_DESTINATION=1
)
include_directories(
${SRC_DIR}
${TST_DIR}/ztest/include
)
add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bacaudit.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/access_rule.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
${SRC_DIR}/bacnet/bacdest.c
${SRC_DIR}/bacnet/bacdevobjpropref.c
${SRC_DIR}/bacnet/bacerror.c
${SRC_DIR}/bacnet/bacint.c
${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/timesync.c
${SRC_DIR}/bacnet/weeklyschedule.c
${SRC_DIR}/bacnet/bactimevalue.c
${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/channel_value.c
${SRC_DIR}/bacnet/secure_connect.c
# Test and test library files
./src/main.c
${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c
)
+259
View File
@@ -0,0 +1,259 @@
/**
* @file
* @brief Unit test for for BACnetAuditNotification and BACnetAuditLogRecord
* @author Steve Karg <skarg@users.sourceforge.net>
* @date November 2024
* @copyright SPDX-License-Identifier: MIT
*/
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <zephyr/ztest.h>
#include <bacnet/bacaudit.h>
/**
* @addtogroup bacnet_tests
* @{
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(bacnet_audit_tests, test_bacnet_audit_value)
#else
static void test_bacnet_audit_value(void)
#endif
{
uint8_t apdu[MAX_APDU] = { 0 };
BACNET_AUDIT_VALUE value = { 0 }, test_value = { 0 };
int apdu_len = 0, null_len = 0, test_len = 0, tag_len = 0, value_len = 0;
uint8_t tag_number = 1;
bool status = false;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* decoding, some negative tests */
test_len = bacnet_audit_value_decode(NULL, apdu_len, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_value_decode(apdu, 0, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, NULL);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
/* out of range tag */
value.tag = 255;
apdu_len = bacnet_audit_value_encode(apdu, &value);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
/* value type = boolean */
value.tag = BACNET_APPLICATION_TAG_BOOLEAN;
value.type.boolean_value = true;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* value type = unsigned */
value.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
value.type.unsigned_value = 1234;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* value type = signed */
value.tag = BACNET_APPLICATION_TAG_SIGNED_INT;
value.type.integer_value = -1234;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* value type = REAL */
value.tag = BACNET_APPLICATION_TAG_REAL;
value.type.real_value = 3.14159f;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* value type = ENUMERATED */
value.tag = BACNET_APPLICATION_TAG_ENUMERATED;
value.type.enumerated_value = 1234;
null_len = bacnet_audit_value_encode(NULL, &value);
apdu_len = bacnet_audit_value_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_value_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_value_same(&value, &test_value), NULL);
/* negative tests */
null_len = bacnet_audit_value_encode(NULL, NULL);
zassert_equal(null_len, 0, NULL);
value.tag = 255;
null_len = bacnet_audit_value_encode(NULL, &value);
zassert_equal(null_len, 1, NULL);
/* context encoded */
value.tag = BACNET_APPLICATION_TAG_BOOLEAN;
value.type.boolean_value = true;
null_len = bacnet_audit_value_context_encode(NULL, tag_number, &value);
apdu_len = bacnet_audit_value_context_encode(apdu, tag_number, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = 0;
status = bacnet_is_opening_tag_number(apdu, apdu_len, tag_number, &tag_len);
zassert_true(status, NULL);
test_len += tag_len;
value_len = bacnet_audit_value_decode(
&apdu[test_len], apdu_len - test_len, &test_value);
test_len += value_len;
status = bacnet_is_closing_tag_number(
&apdu[test_len], apdu_len - test_len, tag_number, &tag_len);
zassert_true(status, NULL);
test_len += tag_len;
zassert_equal(apdu_len, test_len, NULL);
}
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(bacnet_audit_tests, test_bacnet_audit_log_notification)
#else
static void test_bacnet_audit_log_notification(void)
#endif
{
uint8_t apdu[MAX_APDU] = { 0 };
BACNET_AUDIT_NOTIFICATION value = { 0 }, test_value = { 0 };
int apdu_len = 0, null_len = 0, test_len = 0;
null_len = bacnet_audit_log_notification_encode(NULL, &value);
apdu_len = bacnet_audit_log_notification_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_log_notification_decode(apdu, apdu_len, &value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_log_notification_same(&value, &test_value), NULL);
/* decoding, some negative tests */
test_len =
bacnet_audit_log_notification_decode(NULL, apdu_len, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_log_notification_decode(apdu, 0, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_log_notification_decode(apdu, apdu_len, NULL);
zassert_equal(test_len, apdu_len, NULL);
}
uint8_t Test_APDU[MAX_APDU];
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(bacnet_audit_tests, test_bacnet_audit_log_record)
#else
static void test_bacnet_audit_log_record(void)
#endif
{
uint8_t *apdu = Test_APDU;
BACNET_AUDIT_LOG_RECORD value = { 0 }, test_value = { 0 };
int apdu_len = 0, null_len = 0, test_len = 0;
bool status = false;
BACNET_AUDIT_NOTIFICATION *notification = NULL;
value.tag = AUDIT_LOG_DATUM_TAG_STATUS;
datetime_date_init_ascii(&value.timestamp.date, "2024/11/30");
datetime_time_init_ascii(&value.timestamp.time, "23:59:59.99");
null_len = bacnet_audit_log_record_encode(NULL, &value);
apdu_len = bacnet_audit_log_record_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_log_record_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_log_record_same(&value, &test_value), NULL);
/* decoding, some negative tests */
test_len = bacnet_audit_log_record_decode(NULL, apdu_len, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_log_record_decode(apdu, 0, &test_value);
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
test_len = bacnet_audit_log_record_decode(apdu, apdu_len, NULL);
zassert_equal(test_len, apdu_len, NULL);
status = bacnet_audit_log_record_same(&value, NULL);
zassert_false(status, NULL);
status = bacnet_audit_log_record_same(NULL, &value);
zassert_false(status, NULL);
value.tag = 255;
test_value.tag = 255;
status = bacnet_audit_log_record_same(&value, &test_value);
zassert_false(status, NULL);
/* record type = notification */
value.tag = AUDIT_LOG_DATUM_TAG_NOTIFICATION;
notification = &value.log_datum.notification;
bacapp_timestamp_sequence_set(&notification->source_timestamp, 1234);
bacapp_timestamp_sequence_set(&notification->target_timestamp, 5678);
notification->source_device.tag = BACNET_RECIPIENT_TAG_DEVICE;
notification->source_device.type.device.instance = 1234;
notification->source_device.type.device.type = OBJECT_DEVICE;
notification->source_object.type = OBJECT_ANALOG_INPUT;
notification->source_object.instance = 5678;
notification->operation = AUDIT_OPERATION_DEVICE_RESET;
characterstring_init_ansi(&notification->source_comment, "Hello, World!");
characterstring_init_ansi(&notification->target_comment, "Goodbye, World!");
notification->invoke_id = 123;
notification->source_user_id = 456;
notification->source_user_role = 7;
notification->target_device.tag = BACNET_RECIPIENT_TAG_DEVICE;
notification->target_device.type.device.instance = 5678;
notification->target_device.type.device.type = OBJECT_DEVICE;
notification->target_object.type = OBJECT_ANALOG_INPUT;
notification->target_object.instance = 1234;
notification->target_property.property_identifier = PROP_PRESENT_VALUE;
notification->target_property.property_array_index = BACNET_ARRAY_ALL;
notification->target_priority = 8;
notification->target_value.tag = BACNET_APPLICATION_TAG_REAL;
notification->target_value.type.real_value = 3.14159f;
notification->current_value.tag = BACNET_APPLICATION_TAG_REAL;
notification->current_value.type.real_value = 2.71828f;
notification->result = ERROR_CODE_OTHER;
null_len = bacnet_audit_log_record_encode(NULL, &value);
apdu_len = bacnet_audit_log_record_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_log_record_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_log_record_same(&value, &test_value), NULL);
/* record type = time-change */
value.tag = AUDIT_LOG_DATUM_TAG_TIME_CHANGE;
value.log_datum.time_change = 3.14159;
null_len = bacnet_audit_log_record_encode(NULL, &value);
apdu_len = bacnet_audit_log_record_encode(apdu, &value);
zassert_equal(apdu_len, null_len, NULL);
test_len = bacnet_audit_log_record_decode(apdu, apdu_len, &test_value);
zassert_equal(apdu_len, test_len, NULL);
zassert_true(bacnet_audit_log_record_same(&value, &test_value), NULL);
}
/**
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(bacnet_audit_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(
bacnet_audit_tests, ztest_unit_test(test_bacnet_audit_log_record),
ztest_unit_test(test_bacnet_audit_log_notification),
ztest_unit_test(test_bacnet_audit_value));
ztest_run_test_suite(bacnet_audit_tests);
}
#endif
@@ -0,0 +1,73 @@
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(test_${basename}
VERSION 1.0.0
LANGUAGES C)
string(REGEX REPLACE
"/test/bacnet/[a-zA-Z_/-]*$"
"/src"
SRC_DIR
${CMAKE_CURRENT_SOURCE_DIR})
string(REGEX REPLACE
"/test/bacnet/[a-zA-Z_/-]*$"
"/test"
TST_DIR
${CMAKE_CURRENT_SOURCE_DIR})
set(ZTST_DIR "${TST_DIR}/ztest/src")
add_compile_definitions(
BIG_ENDIAN=0
CONFIG_ZTEST=1
BACAPP_MINIMAL=1
BACAPP_DATETIME=1
)
include_directories(
${SRC_DIR}
${TST_DIR}/ztest/include
${TST_DIR}/bacnet/basic/object/test
)
add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/auditlog.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacaudit.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
${SRC_DIR}/bacnet/bacdest.c
${SRC_DIR}/bacnet/bacdevobjpropref.c
${SRC_DIR}/bacnet/bacerror.c
${SRC_DIR}/bacnet/bacint.c
${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/dcc.c
${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c
${SRC_DIR}/bacnet/weeklyschedule.c
${SRC_DIR}/bacnet/bactimevalue.c
${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/proplist.c
# Test and test library files
./src/main.c
${TST_DIR}/bacnet/basic/object/test/property_test.c
${TST_DIR}/bacnet/basic/object/test/device_mock.c
${TST_DIR}/bacnet/basic/object/test/datetime_local.c
${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c
)
@@ -0,0 +1,200 @@
/*
* Copyright (c) 2023 Legrand North America, LLC.
*
* SPDX-License-Identifier: MIT
*/
/* @file
* @brief test BACnet auditlog APIs
*/
#include <zephyr/ztest.h>
#include <bacnet/basic/object/auditlog.h>
#include <bacnet/bactext.h>
#include <bacnet/basic/object/device.h>
#include <property_test.h>
/**
* @addtogroup bacnet_tests
* @{
*/
/**
* @brief Test Auditlog handling
*/
static void testAuditlog(void)
{
int len = 0, index = 0;
const uint32_t instance = 1;
uint32_t test_instance = 0;
const int skip_fail_property_list[] = { -1 };
bool status = false;
BACNET_WRITE_PROPERTY_DATA wp_data = { 0 };
uint32_t buffer_size = 0;
Audit_Log_Init();
len = Audit_Log_Count();
zassert_true(len == 0, NULL);
status = Audit_Log_Valid_Instance(instance);
zassert_false(status, NULL);
test_instance = Audit_Log_Create(instance);
zassert_true(test_instance == instance, NULL);
len = Audit_Log_Count();
zassert_true(len == 1, NULL);
test_instance = Audit_Log_Index_To_Instance(0);
zassert_true(test_instance == instance, NULL);
index = Audit_Log_Instance_To_Index(instance);
zassert_true(index == 0, NULL);
status = Audit_Log_Valid_Instance(instance);
zassert_true(status, NULL);
/* configure ReadProperty test */
/* perform a general test for RP/WP */
bacnet_object_properties_read_write_test(
OBJECT_AUDIT_LOG, instance, Audit_Log_Property_Lists,
Audit_Log_Read_Property, Audit_Log_Write_Property,
skip_fail_property_list);
wp_data.object_type = OBJECT_AUDIT_LOG;
wp_data.object_instance = instance;
wp_data.priority = BACNET_NO_PRIORITY;
wp_data.array_index = BACNET_ARRAY_ALL;
/* test buffer size */
buffer_size = 512;
wp_data.object_property = PROP_BUFFER_SIZE;
wp_data.application_data_len =
encode_application_unsigned(wp_data.application_data, buffer_size);
status = Audit_Log_Write_Property(&wp_data);
zassert_true(status, NULL);
buffer_size = INT_MAX;
buffer_size++;
wp_data.application_data_len =
encode_application_unsigned(wp_data.application_data, buffer_size);
status = Audit_Log_Write_Property(&wp_data);
/* error out of range */
zassert_false(status, NULL);
zassert_equal(wp_data.error_class, ERROR_CLASS_PROPERTY, NULL);
zassert_equal(wp_data.error_code, ERROR_CODE_VALUE_OUT_OF_RANGE, NULL);
wp_data.object_property = PROP_ENABLE;
wp_data.application_data_len =
encode_application_boolean(wp_data.application_data, true);
status = Audit_Log_Write_Property(&wp_data);
zassert_true(status, NULL);
wp_data.object_property = PROP_BUFFER_SIZE;
wp_data.application_data_len =
encode_application_unsigned(wp_data.application_data, buffer_size);
status = Audit_Log_Write_Property(&wp_data);
/* error when enabled=true */
zassert_false(status, NULL);
zassert_equal(wp_data.error_class, ERROR_CLASS_PROPERTY, NULL);
zassert_equal(wp_data.error_code, ERROR_CODE_WRITE_ACCESS_DENIED, NULL);
/* test object name */
bacnet_object_name_ascii_test(
instance, Audit_Log_Name_Set, Audit_Log_Name_ASCII);
bacnet_object_name_ascii_test(
instance, Audit_Log_Description_Set, Audit_Log_Description);
status = Audit_Log_Delete(instance);
zassert_true(status, NULL);
Audit_Log_Cleanup();
len = Audit_Log_Count();
zassert_true(len == 0, NULL);
status = Audit_Log_Valid_Instance(instance);
zassert_false(status, NULL);
}
static void testLogs(void)
{
const uint32_t instance = 1;
uint32_t test_instance = 0;
int len = 0;
uint32_t buffer_size = 0, test_buffer_size = 0, original_buffer_size = 0;
uint32_t record_count = 0;
uint32_t total_record_count = 0;
bool status = false;
BACNET_AUDIT_LOG_RECORD *record;
Audit_Log_Init();
test_instance = Audit_Log_Create(instance);
zassert_true(test_instance == instance, NULL);
len = Audit_Log_Count();
zassert_true(len > 0, NULL);
/* Log Buffer settings */
buffer_size = Audit_Log_Buffer_Size(instance);
zassert_true(buffer_size > 0, NULL);
buffer_size = INT_MAX;
buffer_size++;
status = Audit_Log_Buffer_Size_Set(instance, buffer_size);
zassert_false(status, NULL);
original_buffer_size = Audit_Log_Buffer_Size(instance);
buffer_size = original_buffer_size / 2;
status = Audit_Log_Buffer_Size_Set(instance, buffer_size);
zassert_true(status, NULL);
test_buffer_size = Audit_Log_Buffer_Size(instance);
zassert_true(test_buffer_size == buffer_size, NULL);
status = Audit_Log_Buffer_Size_Set(instance, original_buffer_size);
zassert_true(status, NULL);
/* Log Buffer records manipulation */
record_count = Audit_Log_Record_Count(instance);
zassert_true(record_count == 0, NULL);
total_record_count = Audit_Log_Total_Record_Count(instance);
zassert_true(total_record_count == 0, NULL);
status = Audit_Log_Enable(instance);
zassert_false(status, NULL);
status = Audit_Log_Enable_Set(instance, false);
zassert_true(status, NULL);
/* start logging */
status = Audit_Log_Enable_Set(instance, true);
zassert_true(status, NULL);
record_count = Audit_Log_Record_Count(instance);
zassert_true(record_count == 1, NULL);
total_record_count = Audit_Log_Total_Record_Count(instance);
zassert_true(total_record_count == 1, NULL);
record = Audit_Log_Record_Entry(instance, 0);
zassert_not_null(record, NULL);
zassert_true(record->tag == AUDIT_LOG_DATUM_TAG_STATUS, NULL);
zassert_true(
BIT_CHECK(record->log_datum.log_status, LOG_STATUS_LOG_DISABLED) == 0,
NULL);
Audit_Log_Record_Status_Insert(instance, LOG_STATUS_LOG_INTERRUPTED, true);
record_count = Audit_Log_Record_Count(instance);
zassert_true(record_count == 2, NULL);
total_record_count = Audit_Log_Total_Record_Count(instance);
zassert_true(total_record_count == 2, NULL);
record = Audit_Log_Record_Entry(instance, 1);
zassert_not_null(record, NULL);
zassert_true(record->tag == AUDIT_LOG_DATUM_TAG_STATUS, NULL);
zassert_true(
BIT_CHECK(record->log_datum.log_status, LOG_STATUS_LOG_INTERRUPTED),
NULL);
Audit_Log_Record_Entry_Delete(instance, 1);
record_count = Audit_Log_Record_Count(instance);
zassert_true(record_count == 1, "record_count: %d", record_count);
total_record_count = Audit_Log_Total_Record_Count(instance);
zassert_true(total_record_count == 2, NULL);
record = Audit_Log_Record_Entry(instance, 0);
zassert_not_null(record, NULL);
zassert_true(record->tag == AUDIT_LOG_DATUM_TAG_STATUS, NULL);
zassert_true(
BIT_CHECK(record->log_datum.log_status, LOG_STATUS_LOG_DISABLED) == 0,
NULL);
Audit_Log_Cleanup();
}
/**
* @}
*/
void test_main(void)
{
ztest_test_suite(
auditlog_tests, ztest_unit_test(testAuditlog),
ztest_unit_test(testLogs));
ztest_run_test_suite(auditlog_tests);
}