Skip to content

Commit 28fc962

Browse files
committed
Continue adding unit tests
1 parent b5ece33 commit 28fc962

25 files changed

+1395
-393
lines changed

.github/actions/cmake/test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
inputs:
33
options:
4-
default: --exclude-regex 'clear_dirs_.+|remove_tile_.+' --output-on-failure
4+
default: --exclude-regex 'clear_dirs_.+|remove_tile_.+' --output-on-failure --repeat until-pass:3
55

66
runs:
77
using: composite

includes/renderd_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ extern "C" {
3232
#endif
3333

3434
int num_slave_threads;
35-
renderd_config config;
35+
renderd_config *config;
3636
renderd_config config_slaves[MAX_SLAVES];
3737
xmlconfigitem maps[XMLCONFIGS_MAX];
3838

3939
double min_max_double_opt(const char *opt_arg, const char *opt_type_name, double minimum, double maximum);
4040
int min_max_int_opt(const char *opt_arg, const char *opt_type_name, int minimum, int maximum);
41-
void free_map_section(xmlconfigitem map_section);
41+
void free_map_section(xmlconfigitem *map_section);
4242
void free_map_sections(xmlconfigitem *map_sections);
43-
void free_renderd_section(renderd_config renderd_section);
43+
void free_renderd_section(renderd_config *renderd_section);
4444
void free_renderd_sections(renderd_config *renderd_sections);
4545
void process_config_file(const char *config_file_name, int active_renderd_section_num, int log_level);
4646
void process_map_sections(dictionary *ini, const char *config_file_name, xmlconfigitem *maps_dest, const char *default_tile_dir, int num_threads);

src/CMakeLists.txt

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,97 @@ set(gen_tile_test_SRCS
212212
)
213213
set(gen_tile_test_LIBS
214214
${renderd_LIBS}
215+
${STORE_LIBRARIES}
215216
)
216217
add_executable(gen_tile_test ${gen_tile_test_SRCS})
218+
set_target_properties(gen_tile_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
217219
target_compile_definitions(gen_tile_test PRIVATE MAIN_ALREADY_DEFINED)
218220
target_include_directories(gen_tile_test PRIVATE ${PROJECT_SOURCE_DIR}/tests)
219221
target_link_libraries(gen_tile_test ${gen_tile_test_LIBS})
220-
set_target_properties(gen_tile_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
222+
223+
224+
#-----------------------------------------------------------------------------
225+
#
226+
# unit_test_cache_expire
227+
#
228+
#-----------------------------------------------------------------------------
229+
230+
set(unit_test_cache_expire_SRCS
231+
$<TARGET_OBJECTS:catch_main_o>
232+
${PROJECT_SOURCE_DIR}/tests/unit_test_cache_expire.cpp
233+
)
234+
set(unit_test_cache_expire_LIBS
235+
${GLIB_LIBRARIES}
236+
)
237+
add_executable(unit_test_cache_expire ${unit_test_cache_expire_SRCS})
238+
set_target_properties(unit_test_cache_expire PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
239+
target_include_directories(unit_test_cache_expire PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/tests)
240+
target_link_libraries(unit_test_cache_expire ${unit_test_cache_expire_LIBS})
241+
242+
243+
#-----------------------------------------------------------------------------
244+
#
245+
# unit_test_metatile
246+
#
247+
#-----------------------------------------------------------------------------
248+
249+
set(unit_test_metatile_SRCS
250+
$<TARGET_OBJECTS:catch_main_o>
251+
${PROJECT_SOURCE_DIR}/tests/unit_test_metatile.cpp
252+
)
253+
set(unit_test_metatile_LIBS
254+
${GLIB_LIBRARIES}
255+
)
256+
add_executable(unit_test_metatile ${unit_test_metatile_SRCS})
257+
set_target_properties(unit_test_metatile PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
258+
target_include_directories(unit_test_metatile PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/tests)
259+
target_link_libraries(unit_test_metatile ${unit_test_metatile_LIBS})
260+
261+
262+
#-----------------------------------------------------------------------------
263+
#
264+
# unit_test_parameterize_style
265+
#
266+
#-----------------------------------------------------------------------------
267+
268+
set(unit_test_parameterize_style_SRCS
269+
$<TARGET_OBJECTS:catch_main_o>
270+
${PROJECT_SOURCE_DIR}/tests/unit_test_parameterize_style.cpp
271+
)
272+
set(unit_test_parameterize_style_LIBS
273+
${GLIB_LIBRARIES}
274+
${LIBMAPNIK_LIBRARIES}
275+
)
276+
add_executable(unit_test_parameterize_style ${unit_test_parameterize_style_SRCS})
277+
set_target_properties(unit_test_parameterize_style PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
278+
target_compile_definitions(unit_test_parameterize_style PRIVATE
279+
MAPNIK_XML="${PROJECT_SOURCE_DIR}/utils/example-map/mapnik.xml"
280+
)
281+
target_include_directories(unit_test_parameterize_style PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/tests)
282+
target_link_libraries(unit_test_parameterize_style ${unit_test_parameterize_style_LIBS})
283+
284+
285+
#-----------------------------------------------------------------------------
286+
#
287+
# unit_test_protocol_helper
288+
#
289+
#-----------------------------------------------------------------------------
290+
291+
set(unit_test_protocol_helper_SRCS
292+
$<TARGET_OBJECTS:catch_main_o>
293+
${PROJECT_SOURCE_DIR}/tests/unit_test_protocol_helper.cpp
294+
)
295+
set(unit_test_protocol_helper_LIBS
296+
${GLIB_LIBRARIES}
297+
${INIPARSER_LIBRARIES}
298+
)
299+
add_executable(unit_test_protocol_helper ${unit_test_protocol_helper_SRCS})
300+
set_target_properties(unit_test_protocol_helper PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
301+
target_compile_definitions(unit_test_protocol_helper PRIVATE
302+
RENDERD_CONF="${PROJECT_SOURCE_DIR}/etc/renderd/renderd.conf.examples"
303+
)
304+
target_include_directories(unit_test_protocol_helper PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/tests)
305+
target_link_libraries(unit_test_protocol_helper ${unit_test_protocol_helper_LIBS})
221306

222307

223308
#-----------------------------------------------------------------------------

src/convert_meta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void descend(const char *search)
127127
int main(int argc, char **argv)
128128
{
129129
int z, c;
130-
const char *map = "default";
130+
const char *map = XMLCONFIG_DEFAULT;
131131

132132
while (1) {
133133
int option_index = 0;

src/mod_tile.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,36 +1755,6 @@ static int tile_handler_serve(request_rec *r)
17551755
return DECLINED;
17561756
}
17571757

1758-
static apr_status_t mod_tile_shutdown_handler(void *data)
1759-
{
1760-
server_rec *s = (server_rec *)data;
1761-
tile_server_conf *scfg = (tile_server_conf *)ap_get_module_config(s->module_config, &tile_module);
1762-
tile_config_rec *tile_configs = (tile_config_rec *)scfg->configs->elts;
1763-
int tile_configs_count = scfg->configs->nelts;
1764-
1765-
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
1766-
"Cleaning up %i configs for server %s", tile_configs_count, s->server_hostname);
1767-
1768-
for (int i = 0; i < tile_configs_count; ++i) {
1769-
tile_config_rec *tile_config = &tile_configs[i];
1770-
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
1771-
"Freeing tile config for %s", tile_config->xmlname);
1772-
free((void *)*tile_config->hostnames);
1773-
free((void *)tile_config->hostnames);
1774-
free((void *)tile_config->attribution);
1775-
free((void *)tile_config->baseuri);
1776-
free((void *)tile_config->cors);
1777-
free((void *)tile_config->description);
1778-
free((void *)tile_config->fileExtension);
1779-
free((void *)tile_config->mimeType);
1780-
free((void *)tile_config->store);
1781-
free((void *)tile_config->xmlname);
1782-
free(tile_config);
1783-
}
1784-
1785-
return APR_SUCCESS;
1786-
}
1787-
17881758
/*
17891759
* This routine is called in the parent, so we'll set up the shared
17901760
* memory segment and mutex here.
@@ -1953,10 +1923,6 @@ static int mod_tile_post_config(apr_pool_t *pconf, apr_pool_t *plog,
19531923

19541924
#endif /* MOD_TILE_SET_MUTEX_PERMS */
19551925

1956-
for (server_rec *virt = s; virt != NULL; virt = virt->next) {
1957-
apr_pool_cleanup_register(pconf, (void *)virt, mod_tile_shutdown_handler, apr_pool_cleanup_null);
1958-
}
1959-
19601926
return OK;
19611927
}
19621928

src/parameterize_style.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ parameterize_function_ptr init_parameterization_function(const char *function_na
9191
return parameterize_map_language;
9292
} else {
9393
g_logger(G_LOG_LEVEL_WARNING, "unknown parameterization function for '%s'", function_name);
94+
return NULL;
9495
}
95-
96-
return NULL;
9796
}

src/protocol_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ int recv_cmd(struct protocol * cmd, int fd, int block)
8383
break;
8484

8585
case 2:
86-
ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol_v2) - sizeof(struct protocol_v1), block ? MSG_WAITALL : MSG_DONTWAIT);
86+
ret2 = recv(fd, ((char *)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol_v2) - sizeof(struct protocol_v1), block ? MSG_WAITALL : MSG_DONTWAIT);
8787
break;
8888

8989
case 3:
90-
ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol) - sizeof(struct protocol_v1), block ? MSG_WAITALL : MSG_DONTWAIT);
90+
ret2 = recv(fd, ((char *)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol) - sizeof(struct protocol_v1), block ? MSG_WAITALL : MSG_DONTWAIT);
9191
break;
9292
}
9393

src/render_expired.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ int main(int argc, char **argv)
296296
}
297297

298298
if (!socketname_passed) {
299-
socketname = strndup(config.socketname, PATH_MAX);
299+
socketname = strndup(config->socketname, PATH_MAX);
300300
socketname_passed = 1;
301301
}
302302

src/render_list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
350350
}
351351

352352
if (!socketname_passed) {
353-
socketname = strndup(config.socketname, PATH_MAX);
353+
socketname = strndup(config->socketname, PATH_MAX);
354354
socketname_passed = 1;
355355
}
356356

src/render_old.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ int main(int argc, char **argv)
357357
}
358358

359359
if (!socketname_passed) {
360-
socketname = strndup(config.socketname, PATH_MAX);
360+
socketname = strndup(config->socketname, PATH_MAX);
361361
socketname_passed = 1;
362362
}
363363

0 commit comments

Comments
 (0)