Commit e1d94030 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'release/0.3.1'

parents b6ec0135 548589be
......@@ -286,7 +286,7 @@ girara_list_iterator_remove(girara_list_iterator_t* iter) {
}
GList* el = iter->element;
if (iter->list != NULL && iter->list->free != NULL) {
if (iter->list->free != NULL) {
(iter->list->free)(iter->element->data);
}
......
......@@ -3,10 +3,8 @@
#include "input-history.h"
#include "datastructures.h"
G_DEFINE_TYPE(GiraraInputHistory, girara_input_history, G_TYPE_OBJECT)
/**
* Private data of the settings manager
* Private data of the input history
*/
typedef struct ih_private_s {
girara_list_t* history; /**< List of stored inputs */
......@@ -15,11 +13,9 @@ typedef struct ih_private_s {
size_t current_match;
GiraraInputHistoryIO* io;
char* command_line;
} ih_private_t;
} GiraraInputHistoryPrivate;
#define GIRARA_INPUT_HISTORY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIRARA_TYPE_INPUT_HISTORY, \
ih_private_t))
G_DEFINE_TYPE_WITH_CODE(GiraraInputHistory, girara_input_history, G_TYPE_OBJECT, G_ADD_PRIVATE(GiraraInputHistory))
/* Methods */
static void ih_dispose(GObject* object);
......@@ -46,9 +42,6 @@ enum {
static void
girara_input_history_class_init(GiraraInputHistoryClass* class)
{
/* add private members */
g_type_class_add_private(class, sizeof(ih_private_t));
/* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = ih_dispose;
......@@ -74,7 +67,7 @@ girara_input_history_class_init(GiraraInputHistoryClass* class)
static void
girara_input_history_init(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
priv->history = girara_list_new2((girara_free_function_t) g_free);
priv->reset = true;
priv->io = NULL;
......@@ -84,7 +77,8 @@ girara_input_history_init(GiraraInputHistory* history)
static void
ih_dispose(GObject* object)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
g_clear_object(&priv->io);
......@@ -95,7 +89,8 @@ ih_dispose(GObject* object)
static void
ih_finalize(GObject* object)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
girara_list_free(priv->history);
g_free(priv->command_line);
......@@ -107,7 +102,8 @@ static void
ih_set_property(GObject* object, guint prop_id, const GValue* value,
GParamSpec* pspec)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
switch (prop_id) {
case PROP_IO: {
......@@ -130,7 +126,8 @@ static void
ih_get_property(GObject* object, guint prop_id, GValue* value,
GParamSpec* pspec)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(object);
GiraraInputHistory* ih = GIRARA_INPUT_HISTORY(object);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(ih);
switch (prop_id) {
case PROP_IO:
......@@ -170,7 +167,7 @@ ih_append(GiraraInputHistory* history, const char* input)
girara_list_append(list, g_strdup(input));
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
if (priv->io != NULL) {
girara_input_history_io_append(priv->io, input);
}
......@@ -182,14 +179,14 @@ ih_append(GiraraInputHistory* history, const char* input)
static girara_list_t*
ih_list(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
return priv->history;
}
static const char*
find_next(GiraraInputHistory* history, const char* current_input, bool next)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
girara_list_t* list = girara_input_history_list(history);
if (list == NULL) {
......@@ -232,8 +229,6 @@ find_next(GiraraInputHistory* history, const char* current_input, bool next)
} else {
++priv->current;
}
} else {
return NULL;
}
command = girara_list_nth(list, priv->current);
......@@ -271,7 +266,7 @@ ih_previous(GiraraInputHistory* history, const char* current_input)
static void
ih_reset(GiraraInputHistory* history)
{
ih_private_t* priv = GIRARA_INPUT_HISTORY_GET_PRIVATE(history);
GiraraInputHistoryPrivate* priv = girara_input_history_get_instance_private(history);
priv->reset = true;
if (priv->io != NULL) {
......
......@@ -449,12 +449,12 @@ girara_session_init(girara_session_t* session, const char* sessionname)
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
const bool show_hscrollbar = strchr(guioptions, 'h') != NULL;
const bool show_vscrollbar = strchr(guioptions, 'v') != NULL;
const bool show_hscrollbar = guioptions != NULL && strchr(guioptions, 'h') != NULL;
const bool show_vscrollbar = guioptions != NULL && strchr(guioptions, 'v') != NULL;
g_free(guioptions);
scrolled_window_set_scrollbar_visibility(
GTK_SCROLLED_WINDOW(session->gtk.view), show_hscrollbar, show_vscrollbar);
g_free(guioptions);
/* viewport */
gtk_container_add(GTK_CONTAINER(session->gtk.view), session->gtk.viewport);
......@@ -562,10 +562,10 @@ girara_session_init(girara_session_t* session, const char* sessionname)
char* window_icon = NULL;
girara_setting_get(session, "window-icon", &window_icon);
if (window_icon != NULL) {
if (window_icon != NULL && strlen(window_icon) != 0) {
girara_set_window_icon(session, window_icon);
g_free(window_icon);
}
g_free(window_icon);
gtk_widget_grab_focus(GTK_WIDGET(session->gtk.view));
......@@ -888,6 +888,11 @@ girara_set_window_icon(girara_session_t* session, const char* name)
return false;
}
if (strlen(name) == 0) {
girara_warning("Empty icon name.");
return false;
}
GtkWindow* window = GTK_WINDOW(session->gtk.window);
char* path = girara_fix_path(name);
bool success = true;
......
......@@ -218,7 +218,7 @@ girara_isc_string_manipulation(girara_session_t* session, girara_argument_t* arg
}
/* find the beginning of the word */
while ((i == (pos - 1)) || ((i > 0) && !strchr(separator, input[i]))) {
while ((i == (pos - 1)) || ((i > 0) && separator != NULL && !strchr(separator, input[i]))) {
i--;
}
......@@ -554,7 +554,7 @@ girara_sc_feedkeys(girara_session_t* session, girara_argument_t* argument,
}
/* Possible special key */
} else {
for (unsigned int j = 0; i < LENGTH(gdk_keyboard_buttons); ++j) {
for (unsigned int j = 0; j < LENGTH(gdk_keyboard_buttons); ++j) {
if (g_strcmp0(tmp, gdk_keyboard_buttons[j].identifier) == 0) {
keyval = gdk_keyboard_buttons[j].keyval;
found = true;
......@@ -743,15 +743,13 @@ simulate_key_press(girara_session_t* session, int state, int key)
GdkEvent* event = gdk_event_new(GDK_KEY_PRESS);
event->key.type = GDK_KEY_PRESS;
event->key.window = gtk_widget_get_parent_window(GTK_WIDGET(session->gtk.box));
event->any.type = GDK_KEY_PRESS;
event->key.window = g_object_ref(gtk_widget_get_parent_window(GTK_WIDGET(session->gtk.box)));
event->key.send_event = false;
event->key.time = GDK_CURRENT_TIME;
event->key.state = state;
event->key.keyval = key;
g_object_ref(event->key.window);
GdkDisplay* display = gtk_widget_get_display(GTK_WIDGET(session->gtk.box));
GdkKeymapKey* keys = NULL;
gint number_of_keys = 0;
......
......@@ -6,8 +6,6 @@
#include <glib.h>
G_DEFINE_TYPE(GiraraTemplate, girara_template, G_TYPE_OBJECT)
/**
* Private data of the template
*/
......@@ -18,12 +16,9 @@ typedef struct private_s {
girara_list_t* variables_in_base;
girara_list_t* variables;
bool valid;
} private_t;
typedef struct private_s GiraraTemplatePrivate;
} GiraraTemplatePrivate;
#define GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GIRARA_TYPE_TEMPLATE, private_t))
G_DEFINE_TYPE_WITH_CODE(GiraraTemplate, girara_template, G_TYPE_OBJECT, G_ADD_PRIVATE(GiraraTemplate))
/**
* Internal variables
......@@ -109,9 +104,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
static void
girara_template_class_init(GiraraTemplateClass* class)
{
/* add private members */
g_type_class_add_private(class, sizeof(private_t));
/* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = dispose;
......@@ -184,7 +176,7 @@ girara_template_init(GiraraTemplate* history)
g_error_free(error);
}
private_t* priv = GET_PRIVATE(history);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(history);
priv->base = g_strdup("");
priv->variable_regex = regex;
priv->variable_check_regex = check_regex;
......@@ -197,7 +189,8 @@ girara_template_init(GiraraTemplate* history)
static void
dispose(GObject* object)
{
private_t* priv = GET_PRIVATE(object);
GiraraTemplate* obj = GIRARA_TEMPLATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(obj);
g_regex_unref(priv->variable_regex);
g_regex_unref(priv->variable_check_regex);
......@@ -212,7 +205,8 @@ dispose(GObject* object)
static void
finalize(GObject* object)
{
private_t* priv = GET_PRIVATE(object);
GiraraTemplate* obj = GIRARA_TEMPLATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(obj);
g_free(priv->base);
girara_list_free(priv->variables_in_base);
......@@ -264,9 +258,6 @@ girara_template_new(const char* base)
{
GObject* obj = g_object_new(GIRARA_TYPE_TEMPLATE, NULL);
g_return_val_if_fail(obj, NULL);
if (obj == NULL) {
return NULL;
}
GiraraTemplate* object = GIRARA_TEMPLATE(obj);
if (base != NULL) {
......@@ -280,7 +271,7 @@ girara_template_set_base(GiraraTemplate* object, const char* base)
{
g_return_if_fail(GIRARA_IS_TEMPLATE(object));
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
if (g_strcmp0(base, priv->base) != 0) {
g_free(priv->base);
priv->base = g_strdup(base != NULL ? base : "");
......@@ -295,14 +286,14 @@ girara_template_get_base(GiraraTemplate* object)
{
g_return_val_if_fail(GIRARA_IS_TEMPLATE(object), NULL);
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
return priv->base;
}
static void
base_changed(GiraraTemplate* object)
{
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
girara_list_clear(priv->variables_in_base);
priv->valid = true;
......@@ -336,7 +327,7 @@ base_changed(GiraraTemplate* object)
static void
variable_changed(GiraraTemplate* object, const char* GIRARA_UNUSED(name))
{
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
priv->valid = true;
GIRARA_LIST_FOREACH_BODY(priv->variables_in_base, char*, variable,
......@@ -358,7 +349,7 @@ girara_template_referenced_variables(GiraraTemplate* object)
{
g_return_val_if_fail(GIRARA_IS_TEMPLATE(object), NULL);
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
return priv->variables_in_base;
}
......@@ -368,7 +359,7 @@ girara_template_add_variable(GiraraTemplate* object, const char* name)
g_return_val_if_fail(GIRARA_IS_TEMPLATE(object), false);
g_return_val_if_fail(name != NULL, false);
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
if (g_regex_match(priv->variable_check_regex, name, 0, NULL) == FALSE) {
girara_debug("'%s' is not a valid variable name.", name);
......@@ -403,7 +394,7 @@ girara_template_set_variable_value(GiraraTemplate* object, const char* name,
g_return_if_fail(name != NULL);
g_return_if_fail(value != NULL);
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
variable_t* variable = girara_list_find(priv->variables, compare_variable_name,
name);
......@@ -442,7 +433,7 @@ girara_template_evaluate(GiraraTemplate* object)
{
g_return_val_if_fail(GIRARA_IS_TEMPLATE(object), NULL);
private_t* priv = GET_PRIVATE(object);
GiraraTemplatePrivate* priv = girara_template_get_instance_private(object);
if (priv->valid == false) {
girara_error("Base contains variables that do not have a value assigned.");
return NULL;
......
project('girara', 'c',
version: '0.3.0',
version: '0.3.1',
meson_version: '>=0.43',
default_options: 'c_std=c11',
)
......@@ -24,7 +24,7 @@ conf_data.set('GVMINOR', version_array[1])
conf_data.set('GVREV', version_array[2])
conf_data.set('version', version)
cc = meson.get_compiler('c', required: false)
cc = meson.get_compiler('c')
prefix = get_option('prefix')
localedir = get_option('localedir')
......
option('enable-notify',
type: 'boolean',
value: true,
value: false,
description: 'Enable libnotify support if available.'
)
option('enable-json',
......
......@@ -7,23 +7,61 @@ if check.found()
include_directories += [ include_directories('../girara') ]
test_sources = [
'tests.c',
'test_config.c',
'test_datastructures.c',
'test_session.c',
'test_setting.c',
'test_template.c',
'test_utils.c'
]
xdg_test_helper = executable('xdg_test_helper', 'xdg_test_helper.c',
dependencies: [ glib, declare_dependency(link_with: girara) ],
include_directories: include_directories,
c_args: defines + flags
)
tests = executable('tests', test_sources,
config = executable('test_config', ['test_config.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
test('config', config,
timeout: 60*60,
is_parallel: false
)
datastructures = executable('test_datastructures', ['test_datastructures.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
test('datastructures', datastructures,
timeout: 60*60
)
session = executable('test_session', ['test_session.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
test('session', session,
timeout: 60*60,
is_parallel: false
)
setting = executable('test_setting', ['test_setting.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
test('setting', setting,
timeout: 60*60,
is_parallel: false
)
template = executable('test_template', ['test_template.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
)
test('template', template,
timeout: 60*60
)
utils = executable('test_utils', ['test_utils.c', 'tests.c'],
dependencies: build_dependencies + test_dependencies,
include_directories: include_directories,
c_args: defines + flags
......@@ -32,10 +70,9 @@ if check.found()
env = environment()
env.set('XDG_TEST_HELPER_PATH', meson.current_build_dir())
env.set('HOME', '/home/test')
test('tests-with-home', tests,
test('utils-with-home', utils,
env: env,
timeout: 60*60,
is_parallel: false
timeout: 60*60
)
env_bin = find_program('env', required: false)
......@@ -43,11 +80,10 @@ if check.found()
env = environment()
env.set('XDG_TEST_HELPER_PATH', meson.current_build_dir())
test('tests-without-home', env_bin,
args: ['-u', 'HOME', tests],
test('utils-without-home', env_bin,
args: ['-u', 'HOME', utils],
env: env,
timeout: 60*60,
is_parallel: false
timeout: 60*60
)
endif
endif
......@@ -49,7 +49,7 @@ START_TEST(test_config_parse) {
girara_session_destroy(session);
} END_TEST
Suite* suite_config(void)
static Suite* suite_config(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Config");
......@@ -62,3 +62,8 @@ Suite* suite_config(void)
return suite;
}
int main()
{
return run_suite(suite_config());
}
......@@ -4,6 +4,8 @@
#include <glib.h>
#include <stdint.h>
#include <datastructures.h>
#include <macros.h>
#include <log.h>
#include "tests.h"
......@@ -361,13 +363,28 @@ START_TEST(test_datastructures_list_prepend) {
girara_list_free(list);
} END_TEST
Suite* suite_datastructures(void)
static void
critical_print(const gchar* GIRARA_UNUSED(log_domain), GLogLevelFlags GIRARA_UNUSED(log_level),
const gchar* message, gpointer GIRARA_UNUSED(user_data))
{
girara_debug("expected glib critical: %s", message);
}
static void
setup_logger(void)
{
g_log_set_handler(NULL, G_LOG_LEVEL_CRITICAL, critical_print, NULL);
}
static Suite*
suite_datastructures(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Datastructures");
/* list free */
tcase = tcase_create("list_free_function");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_list_free_empty);
tcase_add_test(tcase, test_datastructures_list_free_already_cleared);
tcase_add_test(tcase, test_datastructures_list_free_free_function);
......@@ -376,44 +393,57 @@ Suite* suite_datastructures(void)
/* list create */
tcase = tcase_create("list_basics");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_list);
suite_add_tcase(suite, tcase);
/* sorted list */
tcase = tcase_create("list_sorted");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_sorted_list_basic);
tcase_add_test(tcase, test_datastructures_sorted_list);
suite_add_tcase(suite, tcase);
/* merge lists */
tcase = tcase_create("list_merge");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_list_merge);
suite_add_tcase(suite, tcase);
/* search lists */
tcase = tcase_create("list_find");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_list_find);
suite_add_tcase(suite, tcase);
/* prepend lists */
tcase = tcase_create("list_prepend");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_list_prepend);
suite_add_tcase(suite, tcase);
/* list iterators */
tcase = tcase_create("list_iterators");
/* tcase_add_test(tcase, test_datastructures_list_iterator_remove); */
tcase_add_checked_fixture(tcase, setup_logger, NULL);
suite_add_tcase(suite, tcase);
/* node free */
tcase = tcase_create("node_free");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_sorted_list);
suite_add_tcase(suite, tcase);
/* node basics */
tcase = tcase_create("node_basics");
tcase_add_checked_fixture(tcase, setup_logger, NULL);
tcase_add_test(tcase, test_datastructures_node);
suite_add_tcase(suite, tcase);
return suite;
}
int
main()
{
return run_suite(suite_datastructures());
}
......@@ -19,7 +19,7 @@ START_TEST(test_init) {
girara_session_destroy(session);
} END_TEST
Suite* suite_session(void)
static Suite* suite_session(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Session");
......@@ -33,3 +33,8 @@ Suite* suite_session(void)
return suite;
}
int main()
{
return run_suite(suite_session());
}
......@@ -67,7 +67,7 @@ START_TEST(test_settings_callback) {
girara_session_destroy(session);
} END_TEST
Suite* suite_settings(void)
static Suite* suite_settings(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Settings");
......@@ -86,3 +86,8 @@ Suite* suite_settings(void)
return suite;
}
int main()
{
return run_suite(suite_settings());
}
......@@ -122,14 +122,13 @@ START_TEST(test_full_2) {
g_object_unref(obj);
} END_TEST
Suite* suite_template(void)
static Suite* suite_template(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Template");
/* girara_template_new */
tcase = tcase_create("object creation");
tcase_add_checked_fixture(tcase, setup, NULL);
tcase_add_test(tcase, test_new);
tcase_add_test(tcase, test_new_with_null);
tcase_add_test(tcase, test_new_with_base);
......@@ -137,7 +136,6 @@ Suite* suite_template(void)
/* base processing */
tcase = tcase_create("base processing");
tcase_add_checked_fixture(tcase, setup, NULL);
tcase_add_test(tcase, test_base_variables_none);
tcase_add_test(tcase, test_base_variables_one);
tcase_add_test(tcase, test_base_variables_one_twice);
......@@ -145,7 +143,6 @@ Suite* suite_template(void)
/* basic variable operations */
tcase = tcase_create("variables");
tcase_add_checked_fixture(tcase, setup, NULL);
tcase_add_test(tcase, test_variable_add);
tcase_add_test(tcase, test_variable_add_invalid);
tcase_add_test(tcase, test_variable_set);
......@@ -153,10 +150,14 @@ Suite* suite_template(void)
/* full processing */
tcase = tcase_create("full");
tcase_add_checked_fixture(tcase, setup, NULL);
tcase_add_test(tcase, test_full_1);
tcase_add_test(tcase, test_full_2);
suite_add_tcase(suite, tcase);
return suite;
}
int main()
{
return run_suite(suite_template());
}
......@@ -256,7 +256,7 @@ START_TEST(test_strings_replace_substrings_3) {
g_free(result);
} END_TEST
Suite* suite_utils(void)
static Suite* suite_utils(void)
{
TCase* tcase = NULL;
Suite* suite = suite_create("Utils");
......@@ -309,3 +309,8 @@ Suite* suite_utils(void)
return suite;
}
int main()
{
return run_suite(suite_utils());
}
/* See LICENSE file for license and copyright information */
#include <check.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include "tests.h"
void setup(void)
{
gtk_init(NULL, NULL);
}
int main()
int run_suite(Suite* suite)
{
Suite* suite = NULL;
SRunner* suite_runner = NULL;
int number_failed = 0;
/* test utils */
suite = suite_utils();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
/* test datastructures */
suite = suite_datastructures();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
/* test settings */
suite = suite_settings();
suite_runner = srunner_create(suite);
SRunner* suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
/* test config */
suite = suite_config();
suite_runner = srunner_create(suite);
srunner_run_all(suite_runner, CK_NORMAL);
number_failed += srunner_ntests_failed(suite_runner);
srunner_free(suite_runner);
const int number_failed = srunner_ntests_failed(suite_runner);
int ret = EXIT_SUCCESS;
if (number_failed != 0) {
ret = EXIT_FAILURE;
TestResult** results = srunner_failures(suite_runner);
for (int i = 0; i < number_failed; ++i) {
if (tr_ctx(results[i]) == CK_CTX_SETUP) {
/* mark tests as skipped */