mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Servald 'config [ set|del ... ] ... ' command
Update all test scripts to avoid repetitive executeOk_servald invocations.
This commit is contained in:
parent
4985359158
commit
fe042bfa64
@ -926,10 +926,6 @@ int app_mdp_ping(int argc, const char *const *argv, const struct command_line_op
|
||||
int app_config_set(int argc, const char *const *argv, const struct command_line_option *o, void *context)
|
||||
{
|
||||
if (debug & DEBUG_VERBOSE) DEBUG_argv("command", argc, argv);
|
||||
const char *var, *val;
|
||||
if ( cli_arg(argc, argv, o, "variable", &var, is_configvarname, NULL)
|
||||
|| cli_arg(argc, argv, o, "value", &val, NULL, ""))
|
||||
return -1;
|
||||
if (create_serval_instance_dir() == -1)
|
||||
return -1;
|
||||
// <kludge>
|
||||
@ -948,26 +944,32 @@ int app_config_set(int argc, const char *const *argv, const struct command_line_
|
||||
if (cf_om_reload() == -1)
|
||||
return -1;
|
||||
// </kludge>
|
||||
if (cf_om_set(&cf_om_root, var, val) == -1 || cf_om_save() == -1)
|
||||
return -1;
|
||||
if (cf_reload() == -1) // logs an error if the new config is bad
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_config_del(int argc, const char *const *argv, const struct command_line_option *o, void *context)
|
||||
{
|
||||
if (debug & DEBUG_VERBOSE) DEBUG_argv("command", argc, argv);
|
||||
const char *var;
|
||||
if (cli_arg(argc, argv, o, "variable", &var, is_configvarname, NULL))
|
||||
return -1;
|
||||
if (create_serval_instance_dir() == -1)
|
||||
return -1;
|
||||
// <kludge> See app_config_set()
|
||||
if (cf_om_reload() == -1)
|
||||
return -1;
|
||||
// </kludge>
|
||||
if (cf_om_set(&cf_om_root, var, NULL) == -1 || cf_om_save() == -1)
|
||||
const char *var[argc - 1];
|
||||
const char *val[argc - 1];
|
||||
int nvar = 0;
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
int iv;
|
||||
if (strcmp(argv[i], "set") == 0) {
|
||||
if (i + 2 > argc)
|
||||
return WHYF("malformed command at argv[%d]: 'set' not followed by two arguments", i);
|
||||
var[nvar] = argv[iv = ++i];
|
||||
val[nvar] = argv[++i];
|
||||
} else if (strcmp(argv[i], "del") == 0) {
|
||||
if (i + 1 > argc)
|
||||
return WHYF("malformed command at argv[%d]: 'del' not followed by one argument", i);
|
||||
var[nvar] = argv[iv = ++i];
|
||||
val[nvar] = NULL;
|
||||
} else
|
||||
return WHYF("malformed command at argv[%d]: unsupported action '%s'", i, argv[i]);
|
||||
if (!is_configvarname(var[nvar]))
|
||||
return WHYF("malformed command at argv[%d]: '%s' is not a valid config option name", iv, var[nvar]);
|
||||
++nvar;
|
||||
}
|
||||
for (i = 0; i < nvar; ++i)
|
||||
if (cf_om_set(&cf_om_root, var[i], val[i]) == -1)
|
||||
return -1;
|
||||
if (cf_om_save() == -1)
|
||||
return -1;
|
||||
if (cf_reload() == -1) // logs an error if the new config is bad
|
||||
return 2;
|
||||
@ -1908,10 +1910,10 @@ struct command_line_option command_line_options[]={
|
||||
"Display information about any running Serval Mesh node."},
|
||||
{app_mdp_ping,{"mdp","ping","<SID|broadcast>","[<count>]",NULL},CLIFLAG_STANDALONE,
|
||||
"Attempts to ping specified node via Mesh Datagram Protocol (MDP)."},
|
||||
{app_config_set,{"config","set","<variable>","<value>",NULL},CLIFLAG_STANDALONE|CLIFLAG_PERMISSIVE_CONFIG,
|
||||
"Set specified configuration variable."},
|
||||
{app_config_del,{"config","del","<variable>",NULL},CLIFLAG_STANDALONE|CLIFLAG_PERMISSIVE_CONFIG,
|
||||
"Set specified configuration variable."},
|
||||
{app_config_set,{"config","set","<variable>","<value>","...",NULL},CLIFLAG_STANDALONE|CLIFLAG_PERMISSIVE_CONFIG,
|
||||
"Set and del specified configuration variables."},
|
||||
{app_config_set,{"config","del","<variable>","...",NULL},CLIFLAG_STANDALONE|CLIFLAG_PERMISSIVE_CONFIG,
|
||||
"Del and set specified configuration variables."},
|
||||
{app_config_get,{"config","get","[<variable>]",NULL},CLIFLAG_STANDALONE|CLIFLAG_PERMISSIVE_CONFIG,
|
||||
"Get specified configuration variable."},
|
||||
{app_vomp_console,{"console",NULL},0,
|
||||
|
33
tests/config
33
tests/config
@ -88,10 +88,11 @@ test_SetGet() {
|
||||
|
||||
doc_GetAll="Get all config items"
|
||||
test_GetAll() {
|
||||
executeOk_servald config set debug.verbose true
|
||||
executeOk_servald config set log.show_pid true
|
||||
executeOk_servald config set server.chdir /tmp/nothing
|
||||
executeOk_servald config set rhizome.enable no
|
||||
executeOk_servald config \
|
||||
set debug.verbose true \
|
||||
set log.show_pid true \
|
||||
set server.chdir /tmp/nothing \
|
||||
set rhizome.enable no
|
||||
executeOk_servald config get
|
||||
assertStdoutLineCount '==' 4
|
||||
assertStdoutGrep --stdout --matches=1 '^debug\.verbose=true$'
|
||||
@ -100,6 +101,25 @@ test_GetAll() {
|
||||
assertStdoutGrep --stdout --matches=1 '^rhizome\.enable=no$'
|
||||
}
|
||||
|
||||
doc_SetDelMixed="Set and del config items in single command"
|
||||
test_SetDelMixed() {
|
||||
executeOk_servald config \
|
||||
set debug.verbose true \
|
||||
set log.show_pid true \
|
||||
set server.chdir /tmp/nothing \
|
||||
set rhizome.enable no
|
||||
executeOk_servald config \
|
||||
set debug.verbose false \
|
||||
del log.show_pid \
|
||||
set log.show_time 1 \
|
||||
del server.chdir \
|
||||
del rhizome.enable
|
||||
executeOk_servald config get
|
||||
assertStdoutLineCount '==' 2
|
||||
assertStdoutGrep --stdout --matches=1 '^debug\.verbose=false$'
|
||||
assertStdoutGrep --stdout --matches=1 '^log\.show_time=1$'
|
||||
}
|
||||
|
||||
doc_SetTwice="Set a single config item twice"
|
||||
test_SetTwice() {
|
||||
executeOk_servald config set debug.verbose yes
|
||||
@ -120,8 +140,7 @@ test_DelNull() {
|
||||
|
||||
doc_Del="Delete single config item"
|
||||
test_Del() {
|
||||
executeOk_servald config set debug.verbose yes
|
||||
executeOk_servald config set log.show_pid true
|
||||
executeOk_servald config set debug.verbose yes set log.show_pid true
|
||||
executeOk_servald config get
|
||||
assertStdoutLineCount '==' 2
|
||||
executeOk_servald config del debug.verbose
|
||||
@ -143,7 +162,7 @@ test_OptionNames() {
|
||||
assertExitStatus --stderr '!=' 0
|
||||
execute $servald config set .verbose yes
|
||||
assertExitStatus --stderr '!=' 0
|
||||
execute $servald config set debug..verbose yes
|
||||
execute $servald config del debug..verbose
|
||||
assertExitStatus --stderr '!=' 0
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,10 @@ source "${0%/*}/../testframework.sh"
|
||||
source "${0%/*}/../testdefs.sh"
|
||||
|
||||
configure_servald_server() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.mdprequests Yes
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.mdprequests Yes
|
||||
}
|
||||
|
||||
setup() {
|
||||
@ -38,8 +39,9 @@ setup() {
|
||||
DIDD=$DIDD1
|
||||
NAMED=$NAMED1
|
||||
set_instance +A
|
||||
executeOk_servald config set dna.helper.executable "$servald_build_root/directory_service"
|
||||
executeOk_servald config set debug.dnahelper on
|
||||
executeOk_servald config \
|
||||
set dna.helper.executable "$servald_build_root/directory_service" \
|
||||
set debug.dnahelper on
|
||||
foreach_instance +B +C +D executeOk_servald config set directory.service $SIDA
|
||||
start_servald_instances +A +B +C +D
|
||||
}
|
||||
@ -79,12 +81,13 @@ test_publish() {
|
||||
}
|
||||
|
||||
start_routing_instance() {
|
||||
executeOk_servald config set server.dummy_interface_dir "$SERVALD_VAR"
|
||||
executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.mdprequests Yes
|
||||
executeOk_servald config \
|
||||
set server.dummy_interface_dir "$SERVALD_VAR" \
|
||||
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
||||
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.mdprequests Yes
|
||||
start_servald_server
|
||||
}
|
||||
|
||||
@ -96,26 +99,29 @@ setup_routing() {
|
||||
>$SERVALD_VAR/dummyB
|
||||
>$SERVALD_VAR/dummyC
|
||||
set_instance +A
|
||||
executeOk_servald config set interfaces.0.dummy dummyB
|
||||
executeOk_servald config set interfaces.0.mdp_tick_ms 0
|
||||
executeOk_servald config set interfaces.1.dummy dummyC
|
||||
executeOk_servald config set interfaces.1.mdp_tick_ms 0
|
||||
executeOk_servald config set dna.helper.executable "$servald_build_root/directory_service"
|
||||
executeOk_servald config set debug.dnahelper on
|
||||
executeOk_servald config \
|
||||
set interfaces.0.dummy dummyB \
|
||||
set interfaces.0.mdp_tick_ms 0 \
|
||||
set interfaces.1.dummy dummyC \
|
||||
set interfaces.1.mdp_tick_ms 0 \
|
||||
set dna.helper.executable "$servald_build_root/directory_service" \
|
||||
set debug.dnahelper on
|
||||
start_routing_instance
|
||||
set_instance +B
|
||||
executeOk_servald config set interfaces.0.dummy dummyB
|
||||
executeOk_servald config set interfaces.0.mdp_tick_ms 0
|
||||
executeOk_servald config set directory.service $SIDA
|
||||
execute $servald config set hosts.$SIDA.address 127.0.0.1
|
||||
executeOk_servald config set hosts.$SIDA.interface "dummyB"
|
||||
executeOk_servald config \
|
||||
set interfaces.0.dummy dummyB \
|
||||
set interfaces.0.mdp_tick_ms 0 \
|
||||
set directory.service $SIDA \
|
||||
set hosts.$SIDA.address 127.0.0.1 \
|
||||
set hosts.$SIDA.interface "dummyB"
|
||||
start_routing_instance
|
||||
set_instance +C
|
||||
executeOk_servald config set interfaces.1.dummy dummyC
|
||||
executeOk_servald config set interfaces.1.mdp_tick_ms 0
|
||||
executeOk_servald config set directory.service $SIDA
|
||||
execute $servald config set hosts.$SIDA.address 127.0.0.1
|
||||
executeOk_servald config set hosts.$SIDA.interface "dummyC"
|
||||
executeOk_servald config \
|
||||
set interfaces.1.dummy dummyC \
|
||||
set interfaces.1.mdp_tick_ms 0 \
|
||||
set directory.service $SIDA \
|
||||
set hosts.$SIDA.address 127.0.0.1 \
|
||||
set hosts.$SIDA.interface "dummyC"
|
||||
start_routing_instance
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,13 @@ teardown() {
|
||||
# Called by start_servald_instances immediately before starting the server
|
||||
# process in each instance.
|
||||
configure_servald_server() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.dnahelper on
|
||||
executeOk_servald config set dna.helper.executable "$dnahelper"
|
||||
executeOk_servald config set dna.helper.argv.1 "Hello,"
|
||||
executeOk_servald config set dna.helper.argv.2 "World!"
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.dnahelper on \
|
||||
set dna.helper.executable "$dnahelper" \
|
||||
set dna.helper.argv.1 "Hello," \
|
||||
set dna.helper.argv.2 "World!"
|
||||
}
|
||||
|
||||
setup_dnahelper() {
|
||||
|
@ -58,17 +58,18 @@ teardown() {
|
||||
}
|
||||
|
||||
set_server_vars() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set mdp.iftype.wifi.tick_ms 100
|
||||
executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1
|
||||
executeOk_servald config set debug.interfaces Yes
|
||||
executeOk_servald config set debug.packetformats No
|
||||
executeOk_servald config set debug.routing No
|
||||
executeOk_servald config set debug.tx No
|
||||
executeOk_servald config set debug.rx No
|
||||
executeOk_servald config set debug.mdprequests Yes
|
||||
executeOk_servald config set debug.keyring Yes
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set mdp.iftype.wifi.tick_ms 100 \
|
||||
set mdp.selfannounce.ticks_per_full_address 1 \
|
||||
set debug.interfaces Yes \
|
||||
set debug.packetformats No \
|
||||
set debug.routing No \
|
||||
set debug.tx No \
|
||||
set debug.rx No \
|
||||
set debug.mdprequests Yes \
|
||||
set debug.keyring Yes
|
||||
}
|
||||
|
||||
doc_LookupWildcard="Lookup by wildcard"
|
||||
@ -139,9 +140,10 @@ EOF
|
||||
foreach_instance +A +B +C +D create_single_identity
|
||||
configure_servald_server() {
|
||||
set_server_vars
|
||||
executeOk_servald config set debug.dnahelper on
|
||||
executeOk_servald config set dna.helper.executable "$dnahelper"
|
||||
executeOk_servald config set dna.helper.argv.1 "$instance_name"
|
||||
executeOk_servald config \
|
||||
set debug.dnahelper on \
|
||||
set dna.helper.executable "$dnahelper" \
|
||||
set dna.helper.argv.1 "$instance_name"
|
||||
}
|
||||
start_servald_instances +A +B +C +D
|
||||
wait_until --sleep=0.25 instances_reach_each_other +A +B +C +D
|
||||
|
@ -36,14 +36,15 @@ teardown() {
|
||||
|
||||
# Called by start_servald_instances for each instance.
|
||||
configure_servald_server() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.rhizome on
|
||||
executeOk_servald config set debug.rhizometx on
|
||||
executeOk_servald config set debug.rhizomerx on
|
||||
executeOk_servald config set server.respawn_on_crash off
|
||||
executeOk_servald config set mdp.iftype.wifi.tick_ms 500
|
||||
executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizometx on \
|
||||
set debug.rhizomerx on \
|
||||
set server.respawn_on_crash off \
|
||||
set mdp.iftype.wifi.tick_ms 500 \
|
||||
set mdp.selfannounce.ticks_per_full_address 1
|
||||
}
|
||||
|
||||
setup_curl_7() {
|
||||
@ -206,8 +207,9 @@ setup_HttpAddLocal() {
|
||||
setup_curl_7
|
||||
setup_common
|
||||
set_instance +A
|
||||
executeOk_servald config set rhizome.api.addfile.uri_path "/rhizome/secretaddfile"
|
||||
executeOk_servald config set rhizome.api.addfile.default_author $SIDA
|
||||
executeOk_servald config \
|
||||
set rhizome.api.addfile.uri_path "/rhizome/secretaddfile" \
|
||||
set rhizome.api.addfile.default_author $SIDA
|
||||
start_servald_instances +A
|
||||
wait_until rhizome_http_server_started +A
|
||||
get_rhizome_server_port PORTA +A
|
||||
@ -232,11 +234,12 @@ setup_sync() {
|
||||
wait_until rhizome_http_server_started +A
|
||||
get_rhizome_server_port PORTA +A
|
||||
set_instance +B
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.rhizome on
|
||||
executeOk_servald config set debug.rhizometx on
|
||||
executeOk_servald config set debug.rhizomerx on
|
||||
executeOk_servald config set rhizome.direct.peer.0 "http://${addr_localhost}:${PORTA}"
|
||||
executeOk_servald config \
|
||||
set log.show_time on \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizometx on \
|
||||
set debug.rhizomerx on \
|
||||
set rhizome.direct.peer.0 "http://${addr_localhost}:${PORTA}"
|
||||
rhizome_add_file file2
|
||||
BID2=$BID
|
||||
VERSION2=$VERSION
|
||||
|
@ -36,14 +36,15 @@ teardown() {
|
||||
|
||||
# Called by start_servald_instances for each instance.
|
||||
configure_servald_server() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.rhizome on
|
||||
executeOk_servald config set debug.rhizometx on
|
||||
executeOk_servald config set debug.rhizomerx on
|
||||
executeOk_servald config set server.respawn_on_crash off
|
||||
executeOk_servald config set mdp.iftype.wifi.tick_ms 500
|
||||
executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizometx on \
|
||||
set debug.rhizomerx on \
|
||||
set server.respawn_on_crash off \
|
||||
set mdp.iftype.wifi.tick_ms 500 \
|
||||
set mdp.selfannounce.ticks_per_full_address 1
|
||||
}
|
||||
|
||||
doc_FileTransferStress="Stress - five nodes each sharing 16 bundles"
|
||||
|
@ -21,9 +21,10 @@ source "${0%/*}/../testframework.sh"
|
||||
source "${0%/*}/../testdefs.sh"
|
||||
|
||||
configure_servald_server() {
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.mdprequests Yes
|
||||
executeOk_servald config \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.mdprequests Yes
|
||||
}
|
||||
|
||||
add_interface() {
|
||||
@ -34,12 +35,13 @@ add_interface() {
|
||||
}
|
||||
|
||||
start_routing_instance() {
|
||||
executeOk_servald config set server.dummy_interface_dir "$SERVALD_VAR"
|
||||
executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config set log.show_pid on
|
||||
executeOk_servald config set log.show_time on
|
||||
executeOk_servald config set debug.mdprequests Yes
|
||||
executeOk_servald config \
|
||||
set server.dummy_interface_dir "$SERVALD_VAR" \
|
||||
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
||||
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
||||
set log.show_pid on \
|
||||
set log.show_time on \
|
||||
set debug.mdprequests Yes
|
||||
start_servald_server
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,10 @@ setup() {
|
||||
|
||||
setup_interfaces() {
|
||||
>$TFWTMP/dummy
|
||||
executeOk_servald config set interfaces "+>$TFWTMP/dummy"
|
||||
executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
||||
executeOk_servald config \
|
||||
set interfaces "+>$TFWTMP/dummy" \
|
||||
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
||||
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user