mirror of
https://github.com/openstreetmap/mod_tile.git
synced 2025-08-03 07:49:53 +00:00
Test error output in catch tests (#419)
This commit is contained in:
@ -26,6 +26,7 @@ bin_PROGRAMS = \
|
|||||||
render_speedtest
|
render_speedtest
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = \
|
||||||
gen_tile_test \
|
gen_tile_test \
|
||||||
|
renderd_config_test \
|
||||||
renderd_test \
|
renderd_test \
|
||||||
render_expired_test \
|
render_expired_test \
|
||||||
render_list_test \
|
render_list_test \
|
||||||
@ -108,6 +109,10 @@ gen_tile_test_CFLAGS = -DMAIN_ALREADY_DEFINED
|
|||||||
gen_tile_test_CXXFLAGS = $(renderd_CXXFLAGS)
|
gen_tile_test_CXXFLAGS = $(renderd_CXXFLAGS)
|
||||||
gen_tile_test_LDADD = $(renderd_LDADD) catch_test_common.o
|
gen_tile_test_LDADD = $(renderd_LDADD) catch_test_common.o
|
||||||
|
|
||||||
|
renderd_config_test_SOURCES = \
|
||||||
|
tests/renderd_config_test.cpp
|
||||||
|
renderd_config_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o
|
||||||
|
|
||||||
renderd_test_SOURCES = \
|
renderd_test_SOURCES = \
|
||||||
tests/renderd_test.cpp
|
tests/renderd_test.cpp
|
||||||
renderd_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o
|
renderd_test_LDADD = $(GLIB_LIBS) catch_main.o catch_test_common.o
|
||||||
@ -132,8 +137,9 @@ CLEANFILES=*.slo mod_tile.la stderr.out src/*.slo src/*.lo src/.libs/* src/*.la
|
|||||||
|
|
||||||
COMMA=,
|
COMMA=,
|
||||||
|
|
||||||
test: gen_tile_test renderd_test render_expired_test render_list_test render_old_test render_speedtest_test
|
test: gen_tile_test renderd_config_test renderd_test render_expired_test render_list_test render_old_test render_speedtest_test
|
||||||
./gen_tile_test
|
./gen_tile_test
|
||||||
|
./renderd_config_test
|
||||||
./renderd_test
|
./renderd_test
|
||||||
./render_expired_test
|
./render_expired_test
|
||||||
./render_list_test
|
./render_list_test
|
||||||
|
@ -389,7 +389,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (min_y_passed && max_y_passed && max_y < min_y) {
|
if (min_y_passed && max_y_passed && max_y < min_y) {
|
||||||
g_logger(G_LOG_LEVEL_CRITICAL, "Specified min-y (%i) is larger than max-x (%i).", min_y, max_y);
|
g_logger(G_LOG_LEVEL_CRITICAL, "Specified min-y (%i) is larger than max-y (%i).", min_y, max_y);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,6 +786,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
g_logger(G_LOG_LEVEL_INFO, "Renderd started (version %s)", VERSION);
|
g_logger(G_LOG_LEVEL_INFO, "Renderd started (version %s)", VERSION);
|
||||||
|
|
||||||
|
process_config_file(config_file_name, active_renderd_section_num, G_LOG_LEVEL_INFO);
|
||||||
|
|
||||||
|
if (config_file_name_passed) {
|
||||||
|
free((void *)config_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
g_logger(G_LOG_LEVEL_INFO, "Initialising request queue");
|
g_logger(G_LOG_LEVEL_INFO, "Initialising request queue");
|
||||||
render_request_queue = request_queue_init();
|
render_request_queue = request_queue_init();
|
||||||
|
|
||||||
@ -794,12 +800,6 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
process_config_file(config_file_name, active_renderd_section_num, G_LOG_LEVEL_INFO);
|
|
||||||
|
|
||||||
if (config_file_name_passed) {
|
|
||||||
free((void *)config_file_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = server_socket_init(&config);
|
fd = server_socket_init(&config);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -208,6 +208,11 @@ add_test(
|
|||||||
COMMAND renderd_test
|
COMMAND renderd_test
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME renderd_config_test
|
||||||
|
COMMAND renderd_config_test
|
||||||
|
)
|
||||||
|
|
||||||
foreach(STORAGE_BACKEND_INDEX RANGE ${STORAGE_BACKENDS_LENGTH})
|
foreach(STORAGE_BACKEND_INDEX RANGE ${STORAGE_BACKENDS_LENGTH})
|
||||||
# Get STORAGE_BACKEND from STORAGE_BACKENDS list
|
# Get STORAGE_BACKEND from STORAGE_BACKENDS list
|
||||||
list(GET STORAGE_BACKENDS ${STORAGE_BACKEND_INDEX} STORAGE_BACKEND)
|
list(GET STORAGE_BACKENDS ${STORAGE_BACKEND_INDEX} STORAGE_BACKEND)
|
||||||
@ -1162,7 +1167,7 @@ target_include_directories(catch_test_common_o PRIVATE ${GLIB_INCLUDE_DIRS})
|
|||||||
|
|
||||||
add_compile_definitions(
|
add_compile_definitions(
|
||||||
PROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}/src"
|
PROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}/src"
|
||||||
RENDERD_CONF="${PROJECT_SOURCE_DIR}/etc/renderd/renderd.conf"
|
RENDERD_CONF="${PROJECT_SOURCE_DIR}/etc/renderd/renderd.conf.examples"
|
||||||
)
|
)
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/includes)
|
include_directories(${PROJECT_SOURCE_DIR}/includes)
|
||||||
link_libraries(${GLIB_LIBRARIES})
|
link_libraries(${GLIB_LIBRARIES})
|
||||||
@ -1221,3 +1226,14 @@ add_executable(renderd_test
|
|||||||
$<TARGET_OBJECTS:catch_main_o>
|
$<TARGET_OBJECTS:catch_main_o>
|
||||||
renderd_test.cpp
|
renderd_test.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# renderd_config_test
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
add_executable(renderd_config_test
|
||||||
|
$<TARGET_OBJECTS:catch_main_o>
|
||||||
|
renderd_config_test.cpp
|
||||||
|
)
|
||||||
|
@ -18,21 +18,24 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern int foreground;
|
#include "catch_test_common.hpp"
|
||||||
|
|
||||||
typedef struct _captured_stdio {
|
extern int foreground;
|
||||||
int temp_fd;
|
|
||||||
int pipes[2];
|
|
||||||
} captured_stdio;
|
|
||||||
|
|
||||||
captured_stdio captured_stderr;
|
captured_stdio captured_stderr;
|
||||||
captured_stdio captured_stdout;
|
captured_stdio captured_stdout;
|
||||||
|
|
||||||
|
std::string read_stderr(int buffer_size)
|
||||||
|
{
|
||||||
|
char buffer[buffer_size];
|
||||||
|
read(captured_stderr.pipes[0], buffer, buffer_size);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void capture_stderr()
|
void capture_stderr()
|
||||||
{
|
{
|
||||||
// Flush stderr first if you've previously printed something
|
// Flush stderr first if you've previously printed something
|
||||||
@ -52,7 +55,7 @@ void capture_stderr()
|
|||||||
captured_stderr.pipes[1] = pipes[1];
|
captured_stderr.pipes[1] = pipes[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_captured_stderr(bool print = false)
|
std::string get_captured_stderr(bool print)
|
||||||
{
|
{
|
||||||
// Terminate captured output with a zero
|
// Terminate captured output with a zero
|
||||||
write(captured_stderr.pipes[1], "", 1);
|
write(captured_stderr.pipes[1], "", 1);
|
||||||
@ -61,12 +64,8 @@ std::string get_captured_stderr(bool print = false)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
dup2(captured_stderr.temp_fd, fileno(stderr));
|
dup2(captured_stderr.temp_fd, fileno(stderr));
|
||||||
|
|
||||||
// Save & return the captured output
|
// Save & return the captured stderr
|
||||||
std::string log_lines;
|
std::string log_lines = read_stderr();
|
||||||
const int buffer_size = 4096;
|
|
||||||
char buffer[buffer_size];
|
|
||||||
read(captured_stderr.pipes[0], buffer, buffer_size);
|
|
||||||
log_lines += buffer;
|
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
std::cout << "err_log_lines: " << log_lines << "\n";
|
std::cout << "err_log_lines: " << log_lines << "\n";
|
||||||
@ -75,6 +74,13 @@ std::string get_captured_stderr(bool print = false)
|
|||||||
return log_lines;
|
return log_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string read_stdout(int buffer_size)
|
||||||
|
{
|
||||||
|
char buffer[buffer_size];
|
||||||
|
read(captured_stdout.pipes[0], buffer, buffer_size);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void capture_stdout()
|
void capture_stdout()
|
||||||
{
|
{
|
||||||
// Flush stdout first if you've previously printed something
|
// Flush stdout first if you've previously printed something
|
||||||
@ -94,7 +100,7 @@ void capture_stdout()
|
|||||||
captured_stdout.pipes[1] = pipes[1];
|
captured_stdout.pipes[1] = pipes[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_captured_stdout(bool print = false)
|
std::string get_captured_stdout(bool print)
|
||||||
{
|
{
|
||||||
// Terminate captured output with a zero
|
// Terminate captured output with a zero
|
||||||
write(captured_stdout.pipes[1], "", 1);
|
write(captured_stdout.pipes[1], "", 1);
|
||||||
@ -103,12 +109,8 @@ std::string get_captured_stdout(bool print = false)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
dup2(captured_stdout.temp_fd, fileno(stdout));
|
dup2(captured_stdout.temp_fd, fileno(stdout));
|
||||||
|
|
||||||
// Save & return the captured output
|
// Save & return the captured stdout
|
||||||
std::string log_lines;
|
std::string log_lines = read_stdout();
|
||||||
const int buffer_size = 4096;
|
|
||||||
char buffer[buffer_size];
|
|
||||||
read(captured_stdout.pipes[0], buffer, buffer_size);
|
|
||||||
log_lines += buffer;
|
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
std::cout << "out_log_lines: " << log_lines << "\n";
|
std::cout << "out_log_lines: " << log_lines << "\n";
|
||||||
@ -117,7 +119,7 @@ std::string get_captured_stdout(bool print = false)
|
|||||||
return log_lines;
|
return log_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_capture(bool debug = false)
|
void start_capture(bool debug)
|
||||||
{
|
{
|
||||||
foreground = debug ? 1 : 0;
|
foreground = debug ? 1 : 0;
|
||||||
|
|
||||||
@ -135,7 +137,7 @@ void start_capture(bool debug = false)
|
|||||||
capture_stdout();
|
capture_stdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<std::string, std::string> end_capture(bool print = false)
|
std::tuple<std::string, std::string> end_capture(bool print)
|
||||||
{
|
{
|
||||||
setenv("G_MESSAGES_DEBUG", "", 1);
|
setenv("G_MESSAGES_DEBUG", "", 1);
|
||||||
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 79
|
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 79
|
||||||
|
@ -20,6 +20,14 @@
|
|||||||
#ifndef CATCH_TEST_COMMON_HPP
|
#ifndef CATCH_TEST_COMMON_HPP
|
||||||
#define CATCH_TEST_COMMON_HPP
|
#define CATCH_TEST_COMMON_HPP
|
||||||
|
|
||||||
|
typedef struct _captured_stdio {
|
||||||
|
int temp_fd;
|
||||||
|
int pipes[2];
|
||||||
|
} captured_stdio;
|
||||||
|
|
||||||
|
std::string read_stderr(int buffer_size = 16384);
|
||||||
|
std::string read_stdout(int buffer_size = 16384);
|
||||||
|
|
||||||
void capture_stderr();
|
void capture_stderr();
|
||||||
void capture_stdout();
|
void capture_stdout();
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render_config.h"
|
#include "render_config.h"
|
||||||
|
|
||||||
@ -32,10 +32,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RENDERD_CONF
|
#ifndef RENDERD_CONF
|
||||||
#define RENDERD_CONF "./etc/renderd/renderd.conf"
|
#define RENDERD_CONF "./etc/renderd/renderd.conf.examples"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_expired";
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_expired";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
TEST_CASE("render_expired common", "common testing")
|
TEST_CASE("render_expired common", "common testing")
|
||||||
{
|
{
|
||||||
@ -85,83 +87,59 @@ TEST_CASE("render_expired common", "common testing")
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config invalid file", "should return 1") {
|
SECTION("--config invalid file", "should return 1") {
|
||||||
std::string option = "--config /path/is/invalid";
|
std::string renderd_conf = "/path/is/invalid";
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Config file '" + renderd_conf + "' does not exist, please specify a valid file");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_expired specific", "specific testing")
|
TEST_CASE("render_expired specific", "specific testing")
|
||||||
{
|
{
|
||||||
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
|
||||||
std::string option = "--num-threads 0";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
|
||||||
std::string option = GENERATE("--max-zoom", "--min-zoom");
|
|
||||||
std::string command = test_binary + " " + option + " " + std::to_string(MAX_ZOOM + 1);
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
|
||||||
std::string option = "--max-zoom " + std::to_string(MAX_ZOOM - 2) + " --min-zoom " + std::to_string(MAX_ZOOM - 1);
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config without maps", "should return 1") {
|
|
||||||
std::string option = "--config " + (std::string)RENDERD_CONF;
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config with invalid --map", "should return 1") {
|
SECTION("--config with invalid --map", "should return 1") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map invalid";
|
std::string option = "--config " + renderd_conf + " --map invalid";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Map section 'invalid' does not exist in config file '" + renderd_conf + "'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config with valid --map and --tile-dir with invalid path", "should return 1") {
|
SECTION("--config with valid --map and --tile-dir with invalid path", "should return 1") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir /path/is/invalid";
|
std::string option = "--config " + renderd_conf + " --map example-map --tile-dir /path/is/invalid";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: Failed to stat /path/is/invalid with error: No such file or directory");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend /path/is/invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config with valid --map, --verbose and bad input lines", "should return 0") {
|
SECTION("--config with valid --map, --verbose and bad input lines", "should return 0") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
std::string option = "--config " + renderd_conf + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -170,6 +148,12 @@ TEST_CASE("render_expired specific", "specific testing")
|
|||||||
fputs("x y z\n", pipe);
|
fputs("x y z\n", pipe);
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("bad line 0: z/x/y");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("bad line 0: x y z");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid option", "should return 1") {
|
SECTION("--tile-dir with invalid option", "should return 1") {
|
||||||
@ -180,6 +164,12 @@ TEST_CASE("render_expired specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: No valid storage backend found for options: invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid path", "should return 1") {
|
SECTION("--tile-dir with invalid path", "should return 1") {
|
||||||
@ -190,6 +180,54 @@ TEST_CASE("render_expired specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: Failed to stat /path/is/invalid with error: No such file or directory");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend /path/is/invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
||||||
|
std::string option = "--num-threads 0";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid number of threads, must be >= 1 (0 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
||||||
|
std::string option = GENERATE("--max-zoom", "--min-zoom");
|
||||||
|
std::string command = test_binary + " " + option + " " + std::to_string(MAX_ZOOM + 1);
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("zoom, must be <= 20 (21 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
||||||
|
std::string option = "--max-zoom 1 --min-zoom 2";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min zoom (2) is larger than max zoom (1).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +235,7 @@ TEST_CASE("render_expired min/max int generator", "min/max int generator testing
|
|||||||
{
|
{
|
||||||
std::string option = GENERATE("--delete-from", "--max-load", "--max-zoom", "--min-zoom", "--num-threads", "--touch-from");
|
std::string option = GENERATE("--delete-from", "--max-load", "--max-zoom", "--min-zoom", "--num-threads", "--touch-from");
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 1 --help";
|
std::string command = test_binary + " " + option + " 1 --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -205,31 +243,4 @@ TEST_CASE("render_expired min/max int generator", "min/max int generator testing
|
|||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -1";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not an integer", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render_config.h"
|
#include "render_config.h"
|
||||||
|
|
||||||
@ -32,10 +32,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RENDERD_CONF
|
#ifndef RENDERD_CONF
|
||||||
#define RENDERD_CONF "./etc/renderd/renderd.conf"
|
#define RENDERD_CONF "./etc/renderd/renderd.conf.examples"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_list";
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_list";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
TEST_CASE("render_list common", "common testing")
|
TEST_CASE("render_list common", "common testing")
|
||||||
{
|
{
|
||||||
@ -59,16 +61,6 @@ TEST_CASE("render_list common", "common testing")
|
|||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--help", "should return 0") {
|
|
||||||
std::string option = "--help";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--version", "should show version number") {
|
SECTION("--version", "should show version number") {
|
||||||
std::string option = "--version";
|
std::string option = "--version";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
@ -85,133 +77,58 @@ TEST_CASE("render_list common", "common testing")
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config invalid file", "should return 1") {
|
SECTION("--config invalid file", "should return 1") {
|
||||||
std::string option = "--config /path/is/invalid";
|
std::string renderd_conf = "/path/is/invalid";
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Config file '" + renderd_conf + "' does not exist, please specify a valid file");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_list specific", "specific testing")
|
TEST_CASE("render_list specific", "specific testing")
|
||||||
{
|
{
|
||||||
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
|
||||||
std::string option = "--num-threads 0";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
|
||||||
std::string option = GENERATE("--max-zoom", "--min-zoom");
|
|
||||||
std::string command = test_binary + " " + option + " " + std::to_string(MAX_ZOOM + 1);
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
|
||||||
std::string option = "--max-zoom " + std::to_string(MAX_ZOOM - 2) + " --min-zoom " + std::to_string(MAX_ZOOM - 1);
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--all --min-zoom not equal to --max-zoom with X/Y options", "should return 1") {
|
|
||||||
std::string option = "--all --max-x 1 --max-zoom 10 --max-y 1 --min-zoom 9";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--all --max-x/y options exceed maximum (2^zoom-1)", "should return 1") {
|
|
||||||
std::string option = "--all --max-x 2 --max-y 2 --max-zoom 1 --min-zoom 1";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--all --min-x/y options exceed maximum (2^zoom-1)", "should return 1") {
|
|
||||||
std::string option = "--all --max-zoom 1 --min-x 2 --min-y 2 --min-zoom 1";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--all --min-x exceeds --max-x", "should return 1") {
|
|
||||||
std::string option = "--all --max-x 1 --max-zoom 1 --min-x 2 --min-zoom 1";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--all --min-y exceeds --max-y", "should return 1") {
|
|
||||||
std::string option = "--all --max-y 1 --max-zoom 1 --min-y 2 --min-zoom 1";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config without maps", "should return 1") {
|
|
||||||
std::string option = "--config " + (std::string)RENDERD_CONF;
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config with invalid --map", "should return 1") {
|
SECTION("--config with invalid --map", "should return 1") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map invalid";
|
std::string option = "--config " + renderd_conf + " --map invalid";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Map section 'invalid' does not exist in config file '" + renderd_conf + "'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config with valid --map and --tile-dir with invalid path", "should return 1") {
|
SECTION("--config with valid --map and --tile-dir with invalid path", "should return 1") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir /path/is/invalid";
|
std::string option = "--config " + renderd_conf + " --map example-map --tile-dir /path/is/invalid";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: Failed to stat /path/is/invalid with error: No such file or directory");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend /path/is/invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config with valid --map, --verbose and bad input lines", "should return 0") {
|
SECTION("--config with valid --map, --verbose and bad input lines", "should return 0") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
std::string option = "--config " + renderd_conf + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -220,11 +137,17 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
fputs("x y z\n", pipe);
|
fputs("x y z\n", pipe);
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("bad line 0: z/x/y");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("bad line 0: x y z");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config with valid --map, --verbose and invalid zoom input lines", "should return 0") {
|
SECTION("--config with valid --map, --verbose and invalid zoom input lines", "should return 0") {
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
std::string option = "--config " + renderd_conf + " --map example-map --tile-dir " + P_tmpdir + " --verbose";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -233,6 +156,12 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
fputs("0 0 100\n", pipe);
|
fputs("0 0 100\n", pipe);
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Ignoring tile, zoom -100 outside valid range (0..20)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Ignoring tile, zoom 100 outside valid range (0..20)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid option", "should return 1") {
|
SECTION("--tile-dir with invalid option", "should return 1") {
|
||||||
@ -243,6 +172,12 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: No valid storage backend found for options: invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid path", "should return 1") {
|
SECTION("--tile-dir with invalid path", "should return 1") {
|
||||||
@ -253,26 +188,139 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("init_storage_backend: Failed to stat /path/is/invalid with error: No such file or directory");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("Failed to initialise storage backend /path/is/invalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--all --max-lat --max-lon --min-lat --min-lon with --max-x", "should return 1") {
|
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
||||||
std::string option = "--all --max-lat 0 --max-lon 0 --min-lat 0 --min-lon 0 --max-x 0";
|
std::string option = "--num-threads 0";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid number of threads, must be >= 1 (0 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--all --max-lat --max-lon --min-lat --min-lon with --max-y", "should return 1") {
|
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
||||||
std::string option = "--all --max-lat 0 --max-lon 0 --min-lat 0 --min-lon 0 --max-y 0";
|
std::string option = GENERATE("--max-zoom", "--min-zoom");
|
||||||
|
std::string command = test_binary + " " + option + " " + std::to_string(MAX_ZOOM + 1);
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("zoom, must be <= 20 (21 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
||||||
|
std::string option = "--max-zoom 1 --min-zoom 2";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min zoom (2) is larger than max zoom (1).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --min-zoom not equal to --max-zoom with X/Y options", "should return 1") {
|
||||||
|
std::string option = "--all --max-x 1 --max-zoom 10 --max-y 1 --min-zoom 9";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("min-zoom must be equal to max-zoom when using min-x, max-x, min-y, or max-y options");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --max-x/y options exceed maximum (2^zoom-1)", "should return 1") {
|
||||||
|
std::string option = "--all --max-x 2 --max-y 2 --max-zoom 1 --min-zoom 1";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid range, x and y values must be <= 1 (2^zoom-1)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --min-x/y options exceed maximum (2^zoom-1)", "should return 1") {
|
||||||
|
std::string option = "--all --max-zoom 1 --min-x 2 --min-y 2 --min-zoom 1";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid range, x and y values must be <= 1 (2^zoom-1)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --min-x exceeds --max-x", "should return 1") {
|
||||||
|
std::string option = "--all --max-x 1 --max-zoom 1 --min-x 2 --min-zoom 1";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min-x (2) is larger than max-x (1).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --min-y exceeds --max-y", "should return 1") {
|
||||||
|
std::string option = "--all --max-y 1 --max-zoom 1 --min-y 2 --min-zoom 1";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min-y (2) is larger than max-y (1).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("--all --max-lat --max-lon --min-lat --min-lon with --min-x/y and/or --max-x/y", "should return 1") {
|
||||||
|
std::string suboption = GENERATE("--min-x 0", "--min-y 0", "--max-x 0", "--max-y 0", "--min-x 0 --min-y 0 --max-x 0 --max-y 0");
|
||||||
|
std::string option = "--all --max-lat 0 --max-lon 0 --min-lat 0 --min-lon 0 " + suboption;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("min-lat, min-lon, max-lat & max-lon cannot be used together with min-x, max-x, min-y, or max-y");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--all --min-lat exceeds --max-lat", "should return 1") {
|
SECTION("--all --min-lat exceeds --max-lat", "should return 1") {
|
||||||
@ -283,6 +331,10 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min-lat (1.000000) is larger than max-lat (0.000000).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--all --min-lon exceeds --max-lon", "should return 1") {
|
SECTION("--all --min-lon exceeds --max-lon", "should return 1") {
|
||||||
@ -293,6 +345,10 @@ TEST_CASE("render_list specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min-lon (1.000000) is larger than max-lon (0.000000).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +356,7 @@ TEST_CASE("render_list min/max int generator", "min/max int generator testing")
|
|||||||
{
|
{
|
||||||
std::string option = GENERATE("--max-load", "--max-x", "--max-y", "--max-zoom", "--min-x", "--min-y", "--min-zoom", "--num-threads");
|
std::string option = GENERATE("--max-load", "--max-x", "--max-y", "--max-zoom", "--min-x", "--min-y", "--min-zoom", "--num-threads");
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 1 --help";
|
std::string command = test_binary + " " + option + " 1 --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -308,59 +364,16 @@ TEST_CASE("render_list min/max int generator", "min/max int generator testing")
|
|||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -1";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not an integer", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_list min/max lat generator", "min/max lat generator testing")
|
TEST_CASE("render_list min/max lat generator", "min/max double generator testing")
|
||||||
{
|
{
|
||||||
std::string option = GENERATE("--max-lat", "--min-lat");
|
std::string option = GENERATE("--max-lat", "--min-lat");
|
||||||
|
double min = -85.051100;
|
||||||
|
double max = 85.051100;
|
||||||
|
|
||||||
SECTION("option is too large", "should return 1") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 85.05111";
|
std::string command = test_binary + " " + option + " " + std::to_string(max) + " --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is too small", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -85.05111";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
|
||||||
std::string command = test_binary + " " + option + " 85.0511 --help";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
@ -368,58 +381,24 @@ TEST_CASE("render_list min/max lat generator", "min/max lat generator testing")
|
|||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative with --help", "should return 0") {
|
SECTION(option + " option is negative with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " -85.0511 --help";
|
std::string command = test_binary + " " + option + " " + std::to_string(min) + " --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is float with --help", "should return 0") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789 --help";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not a float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_list min/max lon generator", "min/max lon generator testing")
|
TEST_CASE("render_list min/max lon generator", "min/max double generator testing")
|
||||||
{
|
{
|
||||||
std::string option = GENERATE("--max-lon", "--min-lon");
|
std::string option = GENERATE("--max-lon", "--min-lon");
|
||||||
|
double min = -180.000000;
|
||||||
|
double max = 180.000000;
|
||||||
|
|
||||||
SECTION("option is too large", "should return 1") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 180.1";
|
std::string command = test_binary + " " + option + " " + std::to_string(max) + " --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is too small", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -180.1";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
|
||||||
std::string command = test_binary + " " + option + " 180 --help";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
@ -427,30 +406,12 @@ TEST_CASE("render_list min/max lon generator", "min/max lon generator testing")
|
|||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative with --help", "should return 0") {
|
SECTION(option + " option is negative with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " -180 --help";
|
std::string command = test_binary + " " + option + " " + std::to_string(min) + " --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is float with --help", "should return 0") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789 --help";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not a float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render_config.h"
|
#include "render_config.h"
|
||||||
|
|
||||||
@ -32,10 +32,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RENDERD_CONF
|
#ifndef RENDERD_CONF
|
||||||
#define RENDERD_CONF "./etc/renderd/renderd.conf"
|
#define RENDERD_CONF "./etc/renderd/renderd.conf.examples"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_old";
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_old";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
TEST_CASE("render_old common", "common testing")
|
TEST_CASE("render_old common", "common testing")
|
||||||
{
|
{
|
||||||
@ -59,16 +61,6 @@ TEST_CASE("render_old common", "common testing")
|
|||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--help", "should return 0") {
|
|
||||||
std::string option = "--help";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--version", "should show version number") {
|
SECTION("--version", "should show version number") {
|
||||||
std::string option = "--version";
|
std::string option = "--version";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
@ -85,18 +77,38 @@ TEST_CASE("render_old common", "common testing")
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config invalid file", "should return 1") {
|
SECTION("--config invalid file", "should return 1") {
|
||||||
std::string option = "--config /path/is/invalid";
|
std::string renderd_conf = "/path/is/invalid";
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Config file '" + renderd_conf + "' does not exist, please specify a valid file");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_old specific", "specific testing")
|
TEST_CASE("render_old specific", "specific testing")
|
||||||
{
|
{
|
||||||
|
SECTION("--config with invalid --map", "should return 1") {
|
||||||
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
|
std::string option = "--config " + renderd_conf + " --map invalid";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Map section 'invalid' does not exist in config file '" + renderd_conf + "'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
||||||
std::string option = "--num-threads 0";
|
std::string option = "--num-threads 0";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
@ -105,6 +117,10 @@ TEST_CASE("render_old specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid number of threads, must be >= 1 (0 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
||||||
@ -115,16 +131,24 @@ TEST_CASE("render_old specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("zoom, must be <= 20 (21 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
||||||
std::string option = "--max-zoom " + std::to_string(MAX_ZOOM - 2) + " --min-zoom " + std::to_string(MAX_ZOOM - 1);
|
std::string option = "--max-zoom 1 --min-zoom 2";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min zoom (2) is larger than max zoom (1).");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--timestamp is not an integer", "should return 1") {
|
SECTION("--timestamp is not an integer", "should return 1") {
|
||||||
@ -156,34 +180,13 @@ TEST_CASE("render_old specific", "specific testing")
|
|||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config without maps", "should return 1") {
|
|
||||||
std::string option = "--config " + (std::string)RENDERD_CONF;
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config with invalid --map", "should return 1") {
|
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map invalid";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_old min/max int generator", "min/max int generator testing")
|
TEST_CASE("render_old min/max int generator", "min/max int generator testing")
|
||||||
{
|
{
|
||||||
std::string option = GENERATE("--max-load", "--max-zoom", "--min-zoom", "--num-threads");
|
std::string option = GENERATE("--max-load", "--max-zoom", "--min-zoom", "--num-threads");
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 1 --help";
|
std::string command = test_binary + " " + option + " 1 --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -191,31 +194,4 @@ TEST_CASE("render_old min/max int generator", "min/max int generator testing")
|
|||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -1";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not an integer", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render_config.h"
|
#include "render_config.h"
|
||||||
|
|
||||||
@ -32,10 +32,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RENDERD_CONF
|
#ifndef RENDERD_CONF
|
||||||
#define RENDERD_CONF "./etc/renderd/renderd.conf"
|
#define RENDERD_CONF "./etc/renderd/renderd.conf.examples"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_speedtest";
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_speedtest";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
TEST_CASE("render_speedtest common", "common testing")
|
TEST_CASE("render_speedtest common", "common testing")
|
||||||
{
|
{
|
||||||
@ -59,16 +61,6 @@ TEST_CASE("render_speedtest common", "common testing")
|
|||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--help", "should return 0") {
|
|
||||||
std::string option = "--help";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--version", "should show version number") {
|
SECTION("--version", "should show version number") {
|
||||||
std::string option = "--version";
|
std::string option = "--version";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
@ -85,18 +77,38 @@ TEST_CASE("render_speedtest common", "common testing")
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config invalid file", "should return 1") {
|
SECTION("--config invalid file", "should return 1") {
|
||||||
std::string option = "--config /path/is/invalid";
|
std::string renderd_conf = "/path/is/invalid";
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Config file '" + renderd_conf + "' does not exist, please specify a valid file");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("render_speedtest specific", "specific testing")
|
TEST_CASE("render_speedtest specific", "specific testing")
|
||||||
{
|
{
|
||||||
|
SECTION("--config with invalid --map", "should return 1") {
|
||||||
|
std::string renderd_conf = (std::string)RENDERD_CONF;
|
||||||
|
std::string option = "--config " + renderd_conf + " --map invalid";
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Map section 'invalid' does not exist in config file '" + renderd_conf + "'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
SECTION("--num-threads subceeds minimum of 1", "should return 1") {
|
||||||
std::string option = "--num-threads 0";
|
std::string option = "--num-threads 0";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
@ -105,6 +117,10 @@ TEST_CASE("render_speedtest specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid number of threads, must be >= 1 (0 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
SECTION("--min-zoom/--max-zoom exceeds maximum of MAX_ZOOM", "should return 1") {
|
||||||
@ -115,68 +131,24 @@ TEST_CASE("render_speedtest specific", "specific testing")
|
|||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("zoom, must be <= 20 (21 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
SECTION("--min-zoom exceeds --max-zoom", "should return 1") {
|
||||||
std::string option = "--max-zoom " + std::to_string(MAX_ZOOM - 2) + " --min-zoom " + std::to_string(MAX_ZOOM - 1);
|
std::string option = "--max-zoom 1 --min-zoom 2";
|
||||||
std::string command = test_binary + " " + option;
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config without maps", "should return 1") {
|
err_log_lines = read_stderr();
|
||||||
std::string option = "--config " + (std::string)RENDERD_CONF;
|
found = err_log_lines.find("Specified min zoom (2) is larger than max zoom (1).");
|
||||||
std::string command = test_binary + " " + option;
|
REQUIRE(found > -1);
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config with invalid --map", "should return 1") {
|
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map invalid";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--config with valid --map and --tile-dir with invalid path", "should return 1") {
|
|
||||||
std::string renderd_conf_examples = (std::string)RENDERD_CONF + ".examples";
|
|
||||||
std::string option = "--config " + renderd_conf_examples + " --map example-map --tile-dir /path/is/invalid";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid option", "should return 1") {
|
|
||||||
std::string option = "--tile-dir invalid";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("--tile-dir with invalid path", "should return 1") {
|
|
||||||
std::string option = "--tile-dir /path/is/invalid";
|
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +156,7 @@ TEST_CASE("render_speedtest min/max int generator", "min/max int generator testi
|
|||||||
{
|
{
|
||||||
std::string option = GENERATE("--max-zoom", "--min-zoom", "--num-threads");
|
std::string option = GENERATE("--max-zoom", "--min-zoom", "--num-threads");
|
||||||
|
|
||||||
SECTION("option is positive with --help", "should return 0") {
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
std::string command = test_binary + " " + option + " 1 --help";
|
std::string command = test_binary + " " + option + " 1 --help";
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
@ -192,31 +164,4 @@ TEST_CASE("render_speedtest min/max int generator", "min/max int generator testi
|
|||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 0);
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("option is negative", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " -1";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is float", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " 1.23456789";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("option is not an integer", "should return 1") {
|
|
||||||
std::string command = test_binary + " " + option + " invalid";
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
|
||||||
int status = pclose(pipe);
|
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
550
tests/renderd_config_test.cpp
Normal file
550
tests/renderd_config_test.cpp
Normal file
@ -0,0 +1,550 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007 - 2023 by mod_tile contributors (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; If not, see http://www.gnu.org/licenses/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
|
#include "render_config.h"
|
||||||
|
#include "renderd.h"
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROJECT_BINARY_DIR
|
||||||
|
#define PROJECT_BINARY_DIR "."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Only render_list uses all functions in renderd_config.c
|
||||||
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "render_list";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
|
TEST_CASE("renderd_config min/max int", "min/max int generator testing")
|
||||||
|
{
|
||||||
|
std::string option = GENERATE("--max-load", "--max-x", "--max-y", "--max-zoom", "--min-x", "--min-y", "--min-zoom", "--num-threads");
|
||||||
|
|
||||||
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " 1 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is negative", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " -1";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be >=");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
found = err_log_lines.find("(-1 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is float", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " 1.23456789";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be an integer (1.23456789 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is not an integer", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " invalid";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be an integer (invalid was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("renderd_config min/max double lat generator", "min/max double generator testing")
|
||||||
|
{
|
||||||
|
std::string option = GENERATE("--max-lat", "--min-lat");
|
||||||
|
double min = -85.051100;
|
||||||
|
double max = 85.051100;
|
||||||
|
|
||||||
|
SECTION(option + " option is too large", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " 85.05111";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be <= 85.051100 (85.05111 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is too small", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " -85.05111";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be >= -85.051100 (-85.05111 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is not a double", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " invalid";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be a double (invalid was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " 85.0511 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is negative with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " -85.0511 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is double with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " 1.23456789 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("renderd_config min/max double lon generator", "min/max double generator testing")
|
||||||
|
{
|
||||||
|
std::string option = GENERATE("--max-lon", "--min-lon");
|
||||||
|
double min = -180.000000;
|
||||||
|
double max = 180.000000;
|
||||||
|
|
||||||
|
SECTION(option + " option is too large", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " 180.1";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be <= 180.000000 (180.1 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is too small", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " -180.1";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be >= -180.000000 (-180.1 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is not a double", "should return 1") {
|
||||||
|
std::string command = test_binary + " " + option + " invalid";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be a double (invalid was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is positive with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " 180 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is negative with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " -180 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION(option + " option is double with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " " + option + " 1.23456789 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("renderd_config config parser", "specific testing")
|
||||||
|
{
|
||||||
|
SECTION("renderd.conf with too many map sections", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
for (int i = 0; i <= XMLCONFIGS_MAX; i++) {
|
||||||
|
renderd_conf_file << "[map" + std::to_string(i) + "]\n";
|
||||||
|
}
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Can't handle more than " + std::to_string(XMLCONFIGS_MAX) + " map config sections");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf without map sections", "should return 1") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("No map config sections were found in file: " + renderd_conf);
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf without mapnik section", "should return 1") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[map]\n[renderd]\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("No mapnik config section was found in file: " + renderd_conf);
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf with invalid renderd sections", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[map]\n[renderdinvalid]\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Invalid renderd section name: renderdinvalid");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf with too many renderd sections", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[map]\n";
|
||||||
|
for (int i = 0; i <= MAX_SLAVES; i++) {
|
||||||
|
renderd_conf_file << "[renderd" + std::to_string(i) + "]\n";
|
||||||
|
}
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Can't handle more than " + std::to_string(MAX_SLAVES) + " renderd config sections");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf without renderd sections", "should return 1") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[map]\n[mapnik]\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("No renderd config sections were found in file: " + renderd_conf);
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section scale too small", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nscale=0.0\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified scale factor (0.000000) is too small, must be greater than or equal to 0.100000.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section scale too large", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nscale=8.1\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified scale factor (8.100000) is too large, must be less than or equal to 8.000000.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section maxzoom too small", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nmaxzoom=-1\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified max zoom (-1) is too small, must be greater than or equal to 0.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section maxzoom too large", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nmaxzoom=" << MAX_ZOOM + 1 << "\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified max zoom (" + std::to_string(MAX_ZOOM + 1) + ") is too large, must be less than or equal to " + std::to_string(MAX_ZOOM) + ".");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section minzoom too small", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nminzoom=-1\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min zoom (-1) is too small, must be greater than or equal to 0.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section minzoom too large", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\nminzoom=" << MAX_ZOOM + 1 << "\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified min zoom (" + std::to_string(MAX_ZOOM + 1) + ") is larger than max zoom (" + std::to_string(MAX_ZOOM) + ").");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section type has too few parts", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\ntype=a\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified type (a) has too few parts, there must be at least 2, e.g., 'png image/png'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("renderd.conf map section type has too many parts", "should return 7") {
|
||||||
|
std::string renderd_conf = std::tmpnam(nullptr);
|
||||||
|
std::ofstream renderd_conf_file;
|
||||||
|
renderd_conf_file.open(renderd_conf);
|
||||||
|
renderd_conf_file << "[mapnik]\n[renderd]\n";
|
||||||
|
renderd_conf_file << "[map]\ntype=a b c d\n";
|
||||||
|
renderd_conf_file.close();
|
||||||
|
|
||||||
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " " + option;
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
std::remove(renderd_conf.c_str());
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 7);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Specified type (a b c d) has too many parts, there must be no more than 3, e.g., 'png image/png png256'.");
|
||||||
|
REQUIRE(found > -1);
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "catch/catch.hpp"
|
#include "catch/catch.hpp"
|
||||||
|
#include "catch/catch_test_common.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
@ -30,11 +30,9 @@
|
|||||||
#define PROJECT_BINARY_DIR "."
|
#define PROJECT_BINARY_DIR "."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RENDERD_CONF
|
|
||||||
#define RENDERD_CONF "./etc/renderd/renderd.conf"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "renderd";
|
std::string test_binary = (std::string)PROJECT_BINARY_DIR + "/" + "renderd";
|
||||||
|
int found;
|
||||||
|
std::string err_log_lines;
|
||||||
|
|
||||||
TEST_CASE("renderd common", "common testing")
|
TEST_CASE("renderd common", "common testing")
|
||||||
{
|
{
|
||||||
@ -84,25 +82,44 @@ TEST_CASE("renderd common", "common testing")
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("--config invalid file", "should return 1") {
|
SECTION("--config invalid file", "should return 1") {
|
||||||
std::string option = "--config /path/is/invalid";
|
std::string renderd_conf = "/path/is/invalid";
|
||||||
std::string command = test_binary + " " + option;
|
std::string option = "--config " + renderd_conf;
|
||||||
|
std::string command = test_binary + " --foreground " + option;
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("Config file '" + renderd_conf + "' does not exist, please specify a valid file");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("renderd specific", "specific testing")
|
TEST_CASE("renderd specific", "specific testing")
|
||||||
{
|
{
|
||||||
|
std::string option = "--slave";
|
||||||
|
|
||||||
|
SECTION("--slave is positive with --help", "should return 0") {
|
||||||
|
std::string command = test_binary + " --foreground " + option + " 1 --help";
|
||||||
|
|
||||||
|
// flawfinder: ignore
|
||||||
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
|
int status = pclose(pipe);
|
||||||
|
REQUIRE(WEXITSTATUS(status) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("--slave subceeds minimum of 0", "should return 1") {
|
SECTION("--slave subceeds minimum of 0", "should return 1") {
|
||||||
std::string option = "--slave -1";
|
std::string command = test_binary + " --foreground " + option + " -1";
|
||||||
std::string command = test_binary + " " + option;
|
|
||||||
|
|
||||||
// flawfinder: ignore
|
// flawfinder: ignore
|
||||||
FILE *pipe = popen(command.c_str(), "r");
|
FILE *pipe = popen(command.c_str(), "r");
|
||||||
int status = pclose(pipe);
|
int status = pclose(pipe);
|
||||||
REQUIRE(WEXITSTATUS(status) == 1);
|
REQUIRE(WEXITSTATUS(status) == 1);
|
||||||
|
|
||||||
|
err_log_lines = read_stderr();
|
||||||
|
found = err_log_lines.find("must be >= 0 (-1 was provided)");
|
||||||
|
REQUIRE(found > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user