Skip to content

Commit

Permalink
Applied code formatting due to updated build-base image
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Aug 9, 2024
1 parent 853905c commit a0afdc7
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 123 deletions.
20 changes: 10 additions & 10 deletions src/agent/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
#include "agent.h"

const struct option options[] = {
{ARG_HOST, required_argument, 0, ARG_HOST_SHORT },
{ ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
{ ARG_ADDRESS, required_argument, 0, ARG_ADDRESS_SHORT },
{ ARG_NAME, required_argument, 0, ARG_NAME_SHORT },
{ ARG_HEARTBEAT_INTERVAL, required_argument, 0, ARG_HEARTBEAT_INTERVAL_SHORT},
{ ARG_CONFIG, required_argument, 0, ARG_CONFIG_SHORT },
{ ARG_USER, no_argument, 0, ARG_USER_SHORT },
{ ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_VERSION, no_argument, 0, ARG_VERSION_SHORT },
{ NULL, 0, 0, '\0' }
{ ARG_HOST, required_argument, 0, ARG_HOST_SHORT },
{ ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
{ ARG_ADDRESS, required_argument, 0, ARG_ADDRESS_SHORT },
{ ARG_NAME, required_argument, 0, ARG_NAME_SHORT },
{ ARG_HEARTBEAT_INTERVAL, required_argument, 0, ARG_HEARTBEAT_INTERVAL_SHORT },
{ ARG_CONFIG, required_argument, 0, ARG_CONFIG_SHORT },
{ ARG_USER, no_argument, 0, ARG_USER_SHORT },
{ ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_VERSION, no_argument, 0, ARG_VERSION_SHORT },
{ NULL, 0, 0, '\0' }
};

#define GETOPT_OPTSTRING \
Expand Down
62 changes: 31 additions & 31 deletions src/client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,44 @@ int method_version(UNUSED Command *command, UNUSED void *userdata) {
}

const Method methods[] = {
{"help", 0, 0, OPT_NONE, method_help, usage_bluechi},
{ "list-unit-files", 0, 1, OPT_FILTER, method_list_unit_files, usage_bluechi},
{ "list-units", 0, 1, OPT_FILTER, method_list_units, usage_bluechi},
{ "start", 2, 2, OPT_NONE, method_start, usage_bluechi},
{ "stop", 2, 2, OPT_NONE, method_stop, usage_bluechi},
{ "freeze", 2, 2, OPT_NONE, method_freeze, usage_bluechi},
{ "thaw", 2, 2, OPT_NONE, method_thaw, usage_bluechi},
{ "restart", 2, 2, OPT_NONE, method_restart, usage_bluechi},
{ "reload", 2, 2, OPT_NONE, method_reload, usage_bluechi},
{ "monitor", 0, 2, OPT_NONE, method_monitor, usage_bluechi},
{ "metrics", 1, 1, OPT_NONE, method_metrics, usage_bluechi},
{ "enable", 2, ARG_ANY, OPT_FORCE | OPT_RUNTIME | OPT_NO_RELOAD, method_enable, usage_bluechi},
{ "disable", 2, ARG_ANY, OPT_NO_RELOAD, method_disable, usage_bluechi},
{ "daemon-reload", 1, 1, OPT_NONE, method_daemon_reload, usage_bluechi},
{ "status", 0, ARG_ANY, OPT_WATCH, method_status, usage_bluechi},
{ "set-loglevel", 1, 2, OPT_NONE, method_set_loglevel, usage_bluechi},
{ "version", 0, 0, OPT_NONE, method_version, usage_bluechi},
{ NULL, 0, 0, 0, NULL, NULL }
{ "help", 0, 0, OPT_NONE, method_help, usage_bluechi },
{ "list-unit-files", 0, 1, OPT_FILTER, method_list_unit_files, usage_bluechi },
{ "list-units", 0, 1, OPT_FILTER, method_list_units, usage_bluechi },
{ "start", 2, 2, OPT_NONE, method_start, usage_bluechi },
{ "stop", 2, 2, OPT_NONE, method_stop, usage_bluechi },
{ "freeze", 2, 2, OPT_NONE, method_freeze, usage_bluechi },
{ "thaw", 2, 2, OPT_NONE, method_thaw, usage_bluechi },
{ "restart", 2, 2, OPT_NONE, method_restart, usage_bluechi },
{ "reload", 2, 2, OPT_NONE, method_reload, usage_bluechi },
{ "monitor", 0, 2, OPT_NONE, method_monitor, usage_bluechi },
{ "metrics", 1, 1, OPT_NONE, method_metrics, usage_bluechi },
{ "enable", 2, ARG_ANY, OPT_FORCE | OPT_RUNTIME | OPT_NO_RELOAD, method_enable, usage_bluechi },
{ "disable", 2, ARG_ANY, OPT_NO_RELOAD, method_disable, usage_bluechi },
{ "daemon-reload", 1, 1, OPT_NONE, method_daemon_reload, usage_bluechi },
{ "status", 0, ARG_ANY, OPT_WATCH, method_status, usage_bluechi },
{ "set-loglevel", 1, 2, OPT_NONE, method_set_loglevel, usage_bluechi },
{ "version", 0, 0, OPT_NONE, method_version, usage_bluechi },
{ NULL, 0, 0, 0, NULL, NULL }
};

const OptionType option_types[] = {
{ARG_FILTER_SHORT, ARG_FILTER, OPT_FILTER },
{ ARG_FORCE_SHORT, ARG_FORCE, OPT_FORCE },
{ ARG_RUNTIME_SHORT, ARG_RUNTIME, OPT_RUNTIME },
{ ARG_NO_RELOAD_SHORT, ARG_NO_RELOAD, OPT_NO_RELOAD},
{ ARG_WATCH_SHORT, ARG_WATCH, OPT_WATCH },
{ 0, NULL, 0 }
{ ARG_FILTER_SHORT, ARG_FILTER, OPT_FILTER },
{ ARG_FORCE_SHORT, ARG_FORCE, OPT_FORCE },
{ ARG_RUNTIME_SHORT, ARG_RUNTIME, OPT_RUNTIME },
{ ARG_NO_RELOAD_SHORT, ARG_NO_RELOAD, OPT_NO_RELOAD },
{ ARG_WATCH_SHORT, ARG_WATCH, OPT_WATCH },
{ 0, NULL, 0 }
};

#define GETOPT_OPTSTRING ARG_HELP_SHORT_S ARG_FORCE_SHORT_S ARG_WATCH_SHORT_S
const struct option getopt_options[] = {
{ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_FILTER, required_argument, 0, ARG_FILTER_SHORT },
{ ARG_FORCE, no_argument, 0, ARG_FORCE_SHORT },
{ ARG_RUNTIME, no_argument, 0, ARG_RUNTIME_SHORT },
{ ARG_NO_RELOAD, no_argument, 0, ARG_NO_RELOAD_SHORT},
{ ARG_WATCH, no_argument, 0, ARG_WATCH_SHORT },
{ NULL, 0, 0, '\0' }
{ ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_FILTER, required_argument, 0, ARG_FILTER_SHORT },
{ ARG_FORCE, no_argument, 0, ARG_FORCE_SHORT },
{ ARG_RUNTIME, no_argument, 0, ARG_RUNTIME_SHORT },
{ ARG_NO_RELOAD, no_argument, 0, ARG_NO_RELOAD_SHORT },
{ ARG_WATCH, no_argument, 0, ARG_WATCH_SHORT },
{ NULL, 0, 0, '\0' }
};

static void usage() {
Expand Down
10 changes: 5 additions & 5 deletions src/controller/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include "controller.h"

const struct option options[] = {
{ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
{ ARG_CONFIG, required_argument, 0, ARG_CONFIG_SHORT },
{ ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_VERSION, no_argument, 0, ARG_VERSION_SHORT},
{ NULL, 0, 0, '\0' }
{ ARG_PORT, required_argument, 0, ARG_PORT_SHORT },
{ ARG_CONFIG, required_argument, 0, ARG_CONFIG_SHORT },
{ ARG_HELP, no_argument, 0, ARG_HELP_SHORT },
{ ARG_VERSION, no_argument, 0, ARG_VERSION_SHORT },
{ NULL, 0, 0, '\0' }
};

#define GETOPT_OPTSTRING ARG_PORT_SHORT_S ARG_HELP_SHORT_S ARG_CONFIG_SHORT_S ARG_VERSION_SHORT_S
Expand Down
6 changes: 3 additions & 3 deletions src/libbluechi/test/cli/command/command_add_option_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


static const OptionType option_types[] = {
{'f', "force", 1 },
{ 'r', "reload", 11},
{ 0, NULL, 0 },
{ 'f', "force", 1 },
{ 'r', "reload", 11 },
{ 0, NULL, 0 },
};

int main() {
Expand Down
6 changes: 3 additions & 3 deletions src/libbluechi/test/cli/command/command_flag_exists_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


static const OptionType option_types[] = {
{'f', "force", 1 },
{ 'r', "reload", 11},
{ 0, NULL, 0 },
{ 'f', "force", 1 },
{ 'r', "reload", 11 },
{ 0, NULL, 0 },
};

int main() {
Expand Down
6 changes: 3 additions & 3 deletions src/libbluechi/test/cli/command/command_get_option_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


static const OptionType option_types[] = {
{'f', "force", 1 },
{ 'r', "reload", 11},
{ 0, NULL, 0 },
{ 'f', "force", 1 },
{ 'r', "reload", 11 },
{ 0, NULL, 0 },
};

int main() {
Expand Down
6 changes: 3 additions & 3 deletions src/libbluechi/test/cli/command/get_option_type_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


static const OptionType option_types[] = {
{0, "zero", 1 },
{ 1, "one", 11},
{ 0, NULL, 0 },
{ 0, "zero", 1 },
{ 1, "one", 11 },
{ 0, NULL, 0 },
};

bool check_option_type(const OptionType *got, OptionType *expected) {
Expand Down
6 changes: 3 additions & 3 deletions src/libbluechi/test/cli/command/methods_get_method_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ static void usage_dummy() {
}

static const Method methods[] = {
{"dummy-one", 0, 0, 0, method_dummy_one, usage_dummy},
{ "dummy-two", 0, 0, 0, method_dummy_two, usage_dummy},
{ NULL, 0, 0, 0, NULL, NULL }
{ "dummy-one", 0, 0, 0, method_dummy_one, usage_dummy },
{ "dummy-two", 0, 0, 0, method_dummy_two, usage_dummy },
{ NULL, 0, 0, 0, NULL, NULL }
};

int main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ typedef struct cfg_test_param {
} cfg_test_param;

struct cfg_test_param test_data[] = {
/* basic single config file tests */
{"no config files",
/* basic single config file tests */
{ "no config files",
{ NULL, NULL, { NULL, NULL }, NULL },
0, { { NULL, NULL }, { NULL, NULL }, { NULL, NULL } } },
0, { { NULL, NULL }, { NULL, NULL }, { NULL, NULL } } },
{ "only default config file",
{ "NodeName = laptop\n", NULL, { NULL, NULL }, NULL },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
{ "only custom config file",
{ NULL, "NodeName = laptop\n", { NULL, NULL }, NULL },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
{ "only file in confd",
{ NULL, NULL, { "NodeName = laptop\n", NULL }, NULL },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
{ "only file via CLI",
{ NULL, NULL, { NULL, NULL }, "NodeName = laptop\n" },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },

/* testing of loading order and overwrite */
/* testing of loading order and overwrite */
{ "with custom config file",
{ "NodeName = laptop\n", "NodeName = pi\n", { NULL, NULL }, NULL },
0, { { "NodeName", "pi" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "pi" }, { NULL, NULL }, { NULL, NULL } } },
{ "with config file in confd",
{ "NodeName = laptop\n", "NodeName = pi\n", { "NodeName = vm\n", NULL }, NULL },
0, { { "NodeName", "vm" }, { NULL, NULL }, { NULL, NULL } } },
0, { { "NodeName", "vm" }, { NULL, NULL }, { NULL, NULL } } },
{ "with config CLI option",
{ "NodeName = laptop\n", "NodeName = pi\n", { "NodeName = vm\n", NULL }, "NodeName = container\n" },
0, { { "NodeName", "container" }, { NULL, NULL }, { NULL, NULL } }},
0, { { "NodeName", "container" }, { NULL, NULL }, { NULL, NULL } } },
{ "with multiple config files in confd",
{ "NodeName = laptop\n", "NodeName = pi\n", { "NodeName = vm\n", "NodeName = container\n" }, NULL },
0, { { "NodeName", "container" }, { NULL, NULL }, { NULL, NULL } }},
0, { { "NodeName", "container" }, { NULL, NULL }, { NULL, NULL } } },

/* testing of loading order, overwrite and merges */
/* testing of loading order, overwrite and merges */
{ "with multiple, duplicate keys",
{ "NodeName = laptop\nLogLevel=INFO\n",
"NodeName = pi\n",
Expand All @@ -79,21 +79,21 @@ struct cfg_test_param test_data[] = {
0, { { "NodeName", "pi" },
{ "LogLevel", "DEBUG" },
{ "LogTarget", "journald" },
{ "ControllerPort", "1337" } } },
{ "ControllerPort", "1337" } } },

/* testing invalid entries */
/* testing invalid entries */
{ "with invalid value in default config file",
{ "NodeName 0 laptop\n", "NodeName = pi\n", { "LogLevel=DEBUG\n", "LogTarget=stderr\n" }, NULL },
-EINVAL,
{ { NULL, NULL }, { NULL, NULL }, { NULL, NULL } } },
{ { NULL, NULL }, { NULL, NULL }, { NULL, NULL } } },
{ "with invalid value in custom config file",
{ "NodeName = laptop\n", "NodeName 0 pi\n", { "LogLevel=DEBUG\n", "LogTarget=stderr\n" }, NULL },
-EINVAL,
{ { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
{ { "NodeName", "laptop" }, { NULL, NULL }, { NULL, NULL } } },
{ "with invalid value in one of the confd files",
{ "NodeName = laptop\n", "NodeName = pi\n", { "LogLevel=DEBUG\n", "LogTarget0stderr\n" }, NULL },
-EINVAL,
{ { "NodeName", "pi" }, { "LogLevel", "DEBUG" }, { NULL, NULL } } },
{ { "NodeName", "pi" }, { "LogLevel", "DEBUG" }, { NULL, NULL } } },
};

void create_file(const char *file_path, const char *cfg_file_content) {
Expand Down
14 changes: 7 additions & 7 deletions src/libbluechi/test/common/network/get_address_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ typedef struct get_address_test_params {

long unsigned int test_data_index = 0;
struct get_address_test_params test_data[] = {
{NULL, true, NULL, -EINVAL},
{ ".", true, NULL, -1 },
{ "redhat", true, NULL, -1 },
{ "?10.10.10.3", true, NULL, -1 },
{ "192.168.1.", true, NULL, -1 },
{ "8.8.8.8", true, NULL, 0 },
{ "localhost.localdomain", true, "127.0.0.1", 0 },
{ NULL, true, NULL, -EINVAL },
{ ".", true, NULL, -1 },
{ "redhat", true, NULL, -1 },
{ "?10.10.10.3", true, NULL, -1 },
{ "192.168.1.", true, NULL, -1 },
{ "8.8.8.8", true, NULL, 0 },
{ "localhost.localdomain", true, "127.0.0.1", 0 },
};

int getaddrinfo_mock(
Expand Down
Loading

0 comments on commit a0afdc7

Please sign in to comment.