Remove BACFILE dependency in RAM file systems and add mock file object functions for testing (#1227)

This commit is contained in:
Steve Karg
2026-02-12 17:15:31 -06:00
committed by GitHub
parent 9f508c8f2f
commit 9330c47a34
6 changed files with 75 additions and 4 deletions
+2
View File
@@ -116,6 +116,8 @@ The git repositories are hosted at the following sites:
### Changed ### Changed
* Changed BACFILE define dependencies to reflect bacfile-posix.c dependence
since bacfile.c is now independent of any back end file system. (#1227)
* Changed the default BACnet protocol revision to 28 to enable usage of * Changed the default BACnet protocol revision to 28 to enable usage of
special lighting output values. (#1211) special lighting output values. (#1211)
* Changed bacnet_strtof and bacnet_strtold functions to use strtod to * Changed bacnet_strtof and bacnet_strtold functions to use strtod to
-2
View File
@@ -446,13 +446,11 @@ void bacfile_ramfs_deinit(void)
*/ */
void bacfile_ramfs_init(void) void bacfile_ramfs_init(void)
{ {
#if defined(BACFILE)
bacfile_write_stream_data_callback_set(bacfile_ramfs_write_stream_data); bacfile_write_stream_data_callback_set(bacfile_ramfs_write_stream_data);
bacfile_read_stream_data_callback_set(bacfile_ramfs_read_stream_data); bacfile_read_stream_data_callback_set(bacfile_ramfs_read_stream_data);
bacfile_write_record_data_callback_set(bacfile_ramfs_write_record_data); bacfile_write_record_data_callback_set(bacfile_ramfs_write_record_data);
bacfile_read_record_data_callback_set(bacfile_ramfs_read_record_data); bacfile_read_record_data_callback_set(bacfile_ramfs_read_record_data);
bacfile_file_size_callback_set(bacfile_ramfs_file_size); bacfile_file_size_callback_set(bacfile_ramfs_file_size);
bacfile_file_size_set_callback_set(bacfile_ramfs_file_size_set); bacfile_file_size_set_callback_set(bacfile_ramfs_file_size_set);
#endif
File_List = Keylist_Create(); File_List = Keylist_Create();
} }
-2
View File
@@ -203,9 +203,7 @@ bool bacfile_sramfs_read_record_data(
*/ */
void bacfile_sramfs_init(void) void bacfile_sramfs_init(void)
{ {
#if defined(BACFILE)
bacfile_read_stream_data_callback_set(bacfile_sramfs_read_stream_data); bacfile_read_stream_data_callback_set(bacfile_sramfs_read_stream_data);
bacfile_read_record_data_callback_set(bacfile_sramfs_read_record_data); bacfile_read_record_data_callback_set(bacfile_sramfs_read_record_data);
bacfile_file_size_callback_set(bacfile_sramfs_file_size); bacfile_file_size_callback_set(bacfile_sramfs_file_size);
#endif
} }
@@ -0,0 +1,69 @@
/**
* @file
* @brief mock file object functions
* @author Steve Karg <skarg@users.sourceforge.net>
* @date February 2026
*
* @copyright SPDX-License-Identifier: MIT
*/
#include <zephyr/ztest.h>
#include <bacnet/bactext.h>
#include <bacnet/basic/object/bacfile.h>
/**
* @brief Sets the callback function for writing stream data
* @param callback - function pointer to the callback
*/
void bacfile_write_stream_data_callback_set(
size_t (*callback)(const char *, int32_t, const uint8_t *, size_t))
{
(void)callback;
}
/**
* @brief Sets the callback function for writing record data
* @param callback - function pointer to the callback
*/
void bacfile_write_record_data_callback_set(
bool (*callback)(const char *, int32_t, size_t, const uint8_t *, size_t))
{
(void)callback;
}
/**
* @brief Sets the callback function for reading record data
* @param callback - function pointer to the callback
*/
void bacfile_read_record_data_callback_set(
bool (*callback)(const char *, int32_t, size_t, uint8_t *, size_t))
{
(void)callback;
}
/**
* @brief Sets the callback function for reading stream data
* @param callback - function pointer to the callback
*/
void bacfile_read_stream_data_callback_set(
size_t (*callback)(const char *, int32_t, uint8_t *, size_t))
{
(void)callback;
}
/**
* @brief Sets the callback function for getting file size
* @param callback - function pointer to the callback
*/
void bacfile_file_size_callback_set(size_t (*callback)(const char *))
{
(void)callback;
}
/**
* @brief Sets the callback function for setting file size
* @param callback - function pointer to the callback
*/
void bacfile_file_size_set_callback_set(bool (*callback)(const char *, size_t))
{
(void)callback;
}
@@ -28,6 +28,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
${TST_DIR}/bacnet/basic/object/test
) )
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
@@ -40,6 +41,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical) # Support files and stubs (pathname alphabetical)
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
${TST_DIR}/bacnet/basic/object/test/bacfile_mock.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
@@ -28,6 +28,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
${TST_DIR}/bacnet/basic/object/test
) )
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
@@ -40,6 +41,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical) # Support files and stubs (pathname alphabetical)
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
${TST_DIR}/bacnet/basic/object/test/bacfile_mock.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )