aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-25 22:37:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-25 22:37:04 +0000
commitc765d6722ce95f0734f85b3e3bf1f742b509d516 (patch)
tree3d67b0c94e6153bf081b68dbbcbab56ad845c175 /tests
parenttest: config: test [bell].command (spawn template) (diff)
test: config: bindings: verify pipe argv
Diffstat (limited to 'tests')
-rw-r--r--tests/test-config.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/test-config.c b/tests/test-config.c
index 4343e859..57940208 100644
--- a/tests/test-config.c
+++ b/tests/test-config.c
@@ -339,6 +339,10 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const bool alt = action % 3;
const bool shift = action % 4;
const bool super = action % 5;
+ const bool argv = action % 6;
+
+ static const char *const args[] = {
+ "command", "arg1", "arg2", "arg3 has spaces"};
/* Generate the modifier part of the ‘value’ */
char modifier_string[32];
@@ -373,14 +377,18 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
char sym_name[16];
xkb_keysym_get_name(sym, sym_name, sizeof(sym_name));
- snprintf(value, sizeof(value), "%s%s", modifier_string, sym_name);
+ snprintf(value, sizeof(value), "%s%s%s",
+ argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : "",
+ modifier_string, sym_name);
break;
}
case MOUSE_BINDING: {
const char *const button_name = button_map[button_idx].name;
int chars = snprintf(
- value, sizeof(value), "%s%s", modifier_string, button_name);
+ value, sizeof(value), "%s%s%s",
+ argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : "",
+ modifier_string, button_name);
xassert(click_count > 0);
if (click_count > 1)
@@ -397,7 +405,35 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const struct config_key_binding *binding =
&bindings->arr[bindings->count - 1];
- xassert(binding->pipe.argv.args == NULL);
+ if (argv) {
+ if (binding->pipe.argv.args == NULL) {
+ BUG("[%s].%s=%s: pipe argv is NULL",
+ ctx->section, ctx->key, ctx->value);
+ }
+
+ for (size_t i = 0; i < ALEN(args); i++) {
+ if (binding->pipe.argv.args[i] == NULL ||
+ strcmp(binding->pipe.argv.args[i], args[i]) != 0)
+ {
+ BUG("[%s].%s=%s: pipe argv not the expected one: "
+ "mismatch of arg #%zu: expected=\"%s\", got=\"%s\"",
+ ctx->section, ctx->key, ctx->value, i,
+ args[i], binding->pipe.argv.args[i]);
+ }
+ }
+
+ if (binding->pipe.argv.args[ALEN(args)] != NULL) {
+ BUG("[%s].%s=%s: pipe argv not the expected one: "
+ "expected NULL terminator at arg #%zu, got=\"%s\"",
+ ctx->section, ctx->key, ctx->value,
+ ALEN(args), binding->pipe.argv.args[ALEN(args)]);
+ }
+ } else {
+ if (binding->pipe.argv.args != NULL) {
+ BUG("[%s].%s=%s: pipe argv not NULL",
+ ctx->section, ctx->key, ctx->value);
+ }
+ }
if (binding->action != action) {
BUG("[%s].%s=%s: action mismatch: %d != %d",