btstack_memory: refactor generator code

This commit is contained in:
Matthias Ringwald 2022-05-05 17:08:46 +02:00
parent 6fd2a92ac2
commit 2281ada792
4 changed files with 196 additions and 111 deletions

View File

@ -1971,12 +1971,14 @@ void btstack_memory_init(void){
#if MAX_NR_HCI_CONNECTIONS > 0
btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t));
#endif
#if MAX_NR_L2CAP_SERVICES > 0
btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t));
#endif
#if MAX_NR_L2CAP_CHANNELS > 0
btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t));
#endif
#ifdef ENABLE_CLASSIC
#if MAX_NR_RFCOMM_MULTIPLEXERS > 0
btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t));
@ -1987,42 +1989,53 @@ void btstack_memory_init(void){
#if MAX_NR_RFCOMM_CHANNELS > 0
btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t));
#endif
#if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
btstack_memory_pool_create(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry_storage, MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES, sizeof(btstack_link_key_db_memory_entry_t));
#endif
#if MAX_NR_BNEP_SERVICES > 0
btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t));
#endif
#if MAX_NR_BNEP_CHANNELS > 0
btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t));
#endif
#if MAX_NR_GOEP_SERVER_SERVICES > 0
btstack_memory_pool_create(&goep_server_service_pool, goep_server_service_storage, MAX_NR_GOEP_SERVER_SERVICES, sizeof(goep_server_service_t));
#endif
#if MAX_NR_GOEP_SERVER_CONNECTIONS > 0
btstack_memory_pool_create(&goep_server_connection_pool, goep_server_connection_storage, MAX_NR_GOEP_SERVER_CONNECTIONS, sizeof(goep_server_connection_t));
#endif
#if MAX_NR_HFP_CONNECTIONS > 0
btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t));
#endif
#if MAX_NR_HID_HOST_CONNECTIONS > 0
btstack_memory_pool_create(&hid_host_connection_pool, hid_host_connection_storage, MAX_NR_HID_HOST_CONNECTIONS, sizeof(hid_host_connection_t));
#endif
#if MAX_NR_SERVICE_RECORD_ITEMS > 0
btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
#endif
#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t));
#endif
#if MAX_NR_AVDTP_CONNECTIONS > 0
btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t));
#endif
#if MAX_NR_AVRCP_CONNECTIONS > 0
btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t));
#endif
#if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t));
#endif
#endif
#ifdef ENABLE_BLE
#if MAX_NR_BATTERY_SERVICE_CLIENTS > 0
@ -2046,6 +2059,7 @@ void btstack_memory_init(void){
#if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0
btstack_memory_pool_create(&periodic_advertiser_list_entry_pool, periodic_advertiser_list_entry_storage, MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES, sizeof(periodic_advertiser_list_entry_t));
#endif
#endif
#ifdef ENABLE_MESH
#if MAX_NR_MESH_NETWORK_PDUS > 0
@ -2069,5 +2083,6 @@ void btstack_memory_init(void){
#if MAX_NR_MESH_SUBNETS > 0
btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t));
#endif
#endif
}

View File

@ -102,18 +102,15 @@ void btstack_memory_deinit(void);
/* API_END */
// hci_connection
hci_connection_t * btstack_memory_hci_connection_get(void);
void btstack_memory_hci_connection_free(hci_connection_t *hci_connection);
// l2cap_service, l2cap_channel
l2cap_service_t * btstack_memory_l2cap_service_get(void);
void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service);
l2cap_channel_t * btstack_memory_l2cap_channel_get(void);
void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel);
#ifdef ENABLE_CLASSIC
// rfcomm_multiplexer, rfcomm_service, rfcomm_channel
rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void);
void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer);
rfcomm_service_t * btstack_memory_rfcomm_service_get(void);
@ -121,53 +118,42 @@ void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service);
rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void);
void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel);
// btstack_link_key_db_memory_entry
btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void);
void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry);
// bnep_service, bnep_channel
bnep_service_t * btstack_memory_bnep_service_get(void);
void btstack_memory_bnep_service_free(bnep_service_t *bnep_service);
bnep_channel_t * btstack_memory_bnep_channel_get(void);
void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel);
// goep_server_service, goep_server_connection
goep_server_service_t * btstack_memory_goep_server_service_get(void);
void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service);
goep_server_connection_t * btstack_memory_goep_server_connection_get(void);
void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection);
// hfp_connection
hfp_connection_t * btstack_memory_hfp_connection_get(void);
void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection);
// hid_host_connection
hid_host_connection_t * btstack_memory_hid_host_connection_get(void);
void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection);
// service_record_item
service_record_item_t * btstack_memory_service_record_item_get(void);
void btstack_memory_service_record_item_free(service_record_item_t *service_record_item);
// avdtp_stream_endpoint
avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void);
void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint);
// avdtp_connection
avdtp_connection_t * btstack_memory_avdtp_connection_get(void);
void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection);
// avrcp_connection
avrcp_connection_t * btstack_memory_avrcp_connection_get(void);
void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection);
// avrcp_browsing_connection
avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void);
void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection);
#endif
#ifdef ENABLE_BLE
// battery_service_client, gatt_client, hids_client, scan_parameters_service_client, sm_lookup_entry, whitelist_entry, periodic_advertiser_list_entry
battery_service_client_t * btstack_memory_battery_service_client_get(void);
void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client);
gatt_client_t * btstack_memory_gatt_client_get(void);
@ -182,9 +168,9 @@ whitelist_entry_t * btstack_memory_whitelist_entry_get(void);
void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void);
void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry);
#endif
#ifdef ENABLE_MESH
// mesh_network_pdu, mesh_segmented_pdu, mesh_upper_transport_pdu, mesh_network_key, mesh_transport_key, mesh_virtual_address, mesh_subnet
mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void);
void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu);
mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void);
@ -199,6 +185,7 @@ mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void);
void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address);
mesh_subnet_t * btstack_memory_mesh_subnet_get(void);
void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet);
#endif
#if defined __cplusplus

View File

@ -127,6 +127,7 @@ TEST(btstack_memory, hci_connection_NotEnoughBuffers){
TEST(btstack_memory, l2cap_service_GetAndFree){
l2cap_service_t * context;
#ifdef HAVE_MALLOC
@ -209,6 +210,7 @@ TEST(btstack_memory, l2cap_channel_NotEnoughBuffers){
CHECK(context == NULL);
}
#ifdef ENABLE_CLASSIC
@ -338,6 +340,7 @@ TEST(btstack_memory, rfcomm_channel_NotEnoughBuffers){
TEST(btstack_memory, btstack_link_key_db_memory_entry_GetAndFree){
btstack_link_key_db_memory_entry_t * context;
#ifdef HAVE_MALLOC
@ -380,6 +383,7 @@ TEST(btstack_memory, btstack_link_key_db_memory_entry_NotEnoughBuffers){
TEST(btstack_memory, bnep_service_GetAndFree){
bnep_service_t * context;
#ifdef HAVE_MALLOC
@ -464,6 +468,92 @@ TEST(btstack_memory, bnep_channel_NotEnoughBuffers){
TEST(btstack_memory, goep_server_service_GetAndFree){
goep_server_service_t * context;
#ifdef HAVE_MALLOC
context = btstack_memory_goep_server_service_get();
CHECK(context != NULL);
btstack_memory_goep_server_service_free(context);
#else
#ifdef MAX_NR_GOEP_SERVER_SERVICES
// single
context = btstack_memory_goep_server_service_get();
CHECK(context != NULL);
btstack_memory_goep_server_service_free(context);
#else
// none
context = btstack_memory_goep_server_service_get();
CHECK(context == NULL);
btstack_memory_goep_server_service_free(context);
#endif
#endif
}
TEST(btstack_memory, goep_server_service_NotEnoughBuffers){
goep_server_service_t * context;
#ifdef HAVE_MALLOC
simulate_no_memory = 1;
#else
#ifdef MAX_NR_GOEP_SERVER_SERVICES
int i;
// alloc all static buffers
for (i = 0; i < MAX_NR_GOEP_SERVER_SERVICES; i++){
context = btstack_memory_goep_server_service_get();
CHECK(context != NULL);
}
#endif
#endif
// get one more
context = btstack_memory_goep_server_service_get();
CHECK(context == NULL);
}
TEST(btstack_memory, goep_server_connection_GetAndFree){
goep_server_connection_t * context;
#ifdef HAVE_MALLOC
context = btstack_memory_goep_server_connection_get();
CHECK(context != NULL);
btstack_memory_goep_server_connection_free(context);
#else
#ifdef MAX_NR_GOEP_SERVER_CONNECTIONS
// single
context = btstack_memory_goep_server_connection_get();
CHECK(context != NULL);
btstack_memory_goep_server_connection_free(context);
#else
// none
context = btstack_memory_goep_server_connection_get();
CHECK(context == NULL);
btstack_memory_goep_server_connection_free(context);
#endif
#endif
}
TEST(btstack_memory, goep_server_connection_NotEnoughBuffers){
goep_server_connection_t * context;
#ifdef HAVE_MALLOC
simulate_no_memory = 1;
#else
#ifdef MAX_NR_GOEP_SERVER_CONNECTIONS
int i;
// alloc all static buffers
for (i = 0; i < MAX_NR_GOEP_SERVER_CONNECTIONS; i++){
context = btstack_memory_goep_server_connection_get();
CHECK(context != NULL);
}
#endif
#endif
// get one more
context = btstack_memory_goep_server_connection_get();
CHECK(context == NULL);
}
TEST(btstack_memory, hfp_connection_GetAndFree){
hfp_connection_t * context;
#ifdef HAVE_MALLOC
@ -506,6 +596,7 @@ TEST(btstack_memory, hfp_connection_NotEnoughBuffers){
TEST(btstack_memory, hid_host_connection_GetAndFree){
hid_host_connection_t * context;
#ifdef HAVE_MALLOC
@ -548,6 +639,7 @@ TEST(btstack_memory, hid_host_connection_NotEnoughBuffers){
TEST(btstack_memory, service_record_item_GetAndFree){
service_record_item_t * context;
#ifdef HAVE_MALLOC
@ -590,6 +682,7 @@ TEST(btstack_memory, service_record_item_NotEnoughBuffers){
TEST(btstack_memory, avdtp_stream_endpoint_GetAndFree){
avdtp_stream_endpoint_t * context;
#ifdef HAVE_MALLOC
@ -632,6 +725,7 @@ TEST(btstack_memory, avdtp_stream_endpoint_NotEnoughBuffers){
TEST(btstack_memory, avdtp_connection_GetAndFree){
avdtp_connection_t * context;
#ifdef HAVE_MALLOC
@ -674,6 +768,7 @@ TEST(btstack_memory, avdtp_connection_NotEnoughBuffers){
TEST(btstack_memory, avrcp_connection_GetAndFree){
avrcp_connection_t * context;
#ifdef HAVE_MALLOC
@ -716,6 +811,7 @@ TEST(btstack_memory, avrcp_connection_NotEnoughBuffers){
TEST(btstack_memory, avrcp_browsing_connection_GetAndFree){
avrcp_browsing_connection_t * context;
#ifdef HAVE_MALLOC
@ -756,6 +852,7 @@ TEST(btstack_memory, avrcp_browsing_connection_NotEnoughBuffers){
CHECK(context == NULL);
}
#endif
#ifdef ENABLE_BLE
@ -1052,6 +1149,7 @@ TEST(btstack_memory, periodic_advertiser_list_entry_NotEnoughBuffers){
CHECK(context == NULL);
}
#endif
#ifdef ENABLE_MESH
@ -1348,6 +1446,52 @@ TEST(btstack_memory, mesh_subnet_NotEnoughBuffers){
CHECK(context == NULL);
}
#endif
#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
TEST(btstack_memory, hci_iso_stream_GetAndFree){
hci_iso_stream_t * context;
#ifdef HAVE_MALLOC
context = btstack_memory_hci_iso_stream_get();
CHECK(context != NULL);
btstack_memory_hci_iso_stream_free(context);
#else
#ifdef MAX_NR_HCI_ISO_STREAMS
// single
context = btstack_memory_hci_iso_stream_get();
CHECK(context != NULL);
btstack_memory_hci_iso_stream_free(context);
#else
// none
context = btstack_memory_hci_iso_stream_get();
CHECK(context == NULL);
btstack_memory_hci_iso_stream_free(context);
#endif
#endif
}
TEST(btstack_memory, hci_iso_stream_NotEnoughBuffers){
hci_iso_stream_t * context;
#ifdef HAVE_MALLOC
simulate_no_memory = 1;
#else
#ifdef MAX_NR_HCI_ISO_STREAMS
int i;
// alloc all static buffers
for (i = 0; i < MAX_NR_HCI_ISO_STREAMS; i++){
context = btstack_memory_hci_iso_stream_get();
CHECK(context != NULL);
}
#endif
#endif
// get one more
context = btstack_memory_hci_iso_stream_get();
CHECK(context == NULL);
}
#endif
int main (int argc, const char * argv[]){

View File

@ -274,19 +274,6 @@ init_template = """#if POOL_COUNT > 0
btstack_memory_pool_create(&STRUCT_NAME_pool, STRUCT_NAME_storage, POOL_COUNT, sizeof(STRUCT_TYPE));
#endif"""
def writeln(f, data):
f.write(data + "\n")
def replacePlaceholder(template, struct_name):
struct_type = struct_name + '_t'
if struct_name.endswith('try'):
pool_count = "MAX_NR_" + struct_name.upper()[:-3] + "TRIES"
else:
pool_count = "MAX_NR_" + struct_name.upper() + "S"
pool_count_old_no = pool_count.replace("MAX_NR_", "MAX_NO_")
snippet = template.replace("STRUCT_TYPE", struct_type).replace("STRUCT_NAME", struct_name).replace("POOL_COUNT_OLD_NO", pool_count_old_no).replace("POOL_COUNT", pool_count)
return snippet
list_of_structs = [
["hci_connection"],
["l2cap_service", "l2cap_channel"],
@ -311,6 +298,36 @@ list_of_mesh_structs = [
['mesh_network_pdu', 'mesh_segmented_pdu', 'mesh_upper_transport_pdu', 'mesh_network_key', 'mesh_transport_key', 'mesh_virtual_address', 'mesh_subnet']
]
def writeln(f, data):
f.write(data + "\n")
def replacePlaceholder(template, struct_name):
struct_type = struct_name + '_t'
if struct_name.endswith('try'):
pool_count = "MAX_NR_" + struct_name.upper()[:-3] + "TRIES"
else:
pool_count = "MAX_NR_" + struct_name.upper() + "S"
pool_count_old_no = pool_count.replace("MAX_NR_", "MAX_NO_")
snippet = template.replace("STRUCT_TYPE", struct_type).replace("STRUCT_NAME", struct_name).replace("POOL_COUNT_OLD_NO", pool_count_old_no).replace("POOL_COUNT", pool_count)
return snippet
def add_struct(f, guard, template, structs):
if not guard == "":
writeln(f, "#ifdef " + guard)
for struct_names in structs:
# writeln(f, "// "+ ", ".join(struct_names))
for struct_name in struct_names:
writeln(f, replacePlaceholder(template, struct_name))
writeln(f, "")
if not guard == "":
writeln(f, "#endif")
def add_structs(f, template):
add_struct(f, "", template, list_of_structs)
add_struct(f, "ENABLE_CLASSIC", template, list_of_classic_structs)
add_struct(f, "ENABLE_BLE", template, list_of_le_structs)
add_struct(f, "ENABLE_MESH", template, list_of_mesh_structs)
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
file_name = btstack_root + "/src/btstack_memory"
print ('Generating %s.[h|c]' % file_name)
@ -318,30 +335,7 @@ print ('Generating %s.[h|c]' % file_name)
f = open(file_name+".h", "w")
writeln(f, copyright)
writeln(f, hfile_header_begin)
for struct_names in list_of_structs:
writeln(f, "// "+ ", ".join(struct_names))
for struct_name in struct_names:
writeln(f, replacePlaceholder(header_template, struct_name))
writeln(f, "")
writeln(f, "#ifdef ENABLE_CLASSIC")
for struct_names in list_of_classic_structs:
writeln(f, "// "+ ", ".join(struct_names))
for struct_name in struct_names:
writeln(f, replacePlaceholder(header_template, struct_name))
writeln(f, "")
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_BLE")
for struct_names in list_of_le_structs:
writeln(f, "// "+ ", ".join(struct_names))
for struct_name in struct_names:
writeln(f, replacePlaceholder(header_template, struct_name))
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_MESH")
for struct_names in list_of_mesh_structs:
writeln(f, "// "+ ", ".join(struct_names))
for struct_name in struct_names:
writeln(f, replacePlaceholder(header_template, struct_name))
writeln(f, "#endif")
add_structs(f, header_template)
writeln(f, hfile_header_end)
f.close();
@ -349,48 +343,10 @@ f.close();
f = open(file_name+".c", "w")
writeln(f, copyright)
writeln(f, cfile_header_begin)
for struct_names in list_of_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(code_template, struct_name))
writeln(f, "")
writeln(f, "#ifdef ENABLE_CLASSIC")
for struct_names in list_of_classic_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(code_template, struct_name))
writeln(f, "")
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_BLE")
for struct_names in list_of_le_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(code_template, struct_name))
writeln(f, "")
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_MESH")
for struct_names in list_of_mesh_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(code_template, struct_name))
writeln(f, "")
writeln(f, "#endif")
add_structs(f, code_template)
f.write(init_header)
for struct_names in list_of_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(init_template, struct_name))
writeln(f, "#ifdef ENABLE_CLASSIC")
for struct_names in list_of_classic_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(init_template, struct_name))
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_BLE")
for struct_names in list_of_le_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(init_template, struct_name))
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_MESH")
for struct_names in list_of_mesh_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(init_template, struct_name))
writeln(f, "#endif")
add_structs(f, init_template)
writeln(f, "}")
f.close();
@ -493,28 +449,11 @@ int main (int argc, const char * argv[]){
}
"""
file_name = btstack_root + "/test/btstack_memory/btstack_memory_test.c"
file_name = btstack_root + "/test/btstack_memory/btstack_memory_test.cpp"
print ('Generating %s' % file_name)
f = open(file_name, "w")
writeln(f, copyright)
writeln(f, test_header)
for struct_names in list_of_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(test_template, struct_name))
writeln(f, "#ifdef ENABLE_CLASSIC")
for struct_names in list_of_classic_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(test_template, struct_name))
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_BLE")
for struct_names in list_of_le_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(test_template, struct_name))
writeln(f, "#endif")
writeln(f, "#ifdef ENABLE_MESH")
for struct_names in list_of_mesh_structs:
for struct_name in struct_names:
writeln(f, replacePlaceholder(test_template, struct_name))
writeln(f, "#endif")
add_structs(f, test_template)
writeln(f, test_footer)