summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2013-03-18 22:15:20 +0000
committerDaniel Stone <daniel@fooishbar.org>2013-03-19 10:54:23 +0000
commit22ba1fa1a63ba230a8435c50571e7b759d7426ed (patch)
treef602a2fb7c1a45a270007c082f505013b09bfc04 /test
parent964b2a40239454e1c1e56b88a6aff27cdaa7c3be (diff)
test: Add environment checking to rulescomp
To ensure that overriding RMLVO from the environment works. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'test')
-rw-r--r--test/rulescomp.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/test/rulescomp.c b/test/rulescomp.c
index dfe4084..0bf0725 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -91,9 +91,42 @@ benchmark(struct xkb_context *context)
BENCHMARK_ITERATIONS, elapsed.tv_sec, elapsed.tv_nsec);
}
-int main(int argc, char *argv[])
+static int
+test_rmlvo_env(struct xkb_context *ctx, const char *rules, const char *model,
+ const char *layout, const char *variant, const char *options)
+{
+ if (!isempty(rules))
+ setenv("XKB_DEFAULT_RULES", rules, 1);
+ else
+ unsetenv("XKB_DEFAULT_RULES");
+
+ if (!isempty(model))
+ setenv("XKB_DEFAULT_MODEL", model, 1);
+ else
+ unsetenv("XKB_DEFAULT_MODEL");
+
+ if (!isempty(layout))
+ setenv("XKB_DEFAULT_LAYOUT", layout, 1);
+ else
+ unsetenv("XKB_DEFAULT_LAYOUT");
+
+ if (!isempty(variant))
+ setenv("XKB_DEFAULT_VARIANT", variant, 1);
+ else
+ unsetenv("XKB_DEFAULT_VARIANT");
+
+ if (!isempty(options))
+ setenv("XKB_DEFAULT_OPTIONS", options, 1);
+ else
+ unsetenv("XKB_DEFAULT_OPTIONS");
+
+ return test_rmlvo(ctx, NULL, NULL, NULL, NULL, NULL);
+}
+
+int
+main(int argc, char *argv[])
{
- struct xkb_context *ctx = test_get_context(0);
+ struct xkb_context *ctx = test_get_context(CONTEXT_ALLOW_ENVIRONMENT_NAMES);
assert(ctx);
@@ -114,10 +147,19 @@ int main(int argc, char *argv[])
assert(test_rmlvo(ctx, "evdev", "", "us,,ca", "", ""));
assert(test_rmlvo(ctx, "", "", "", "", ""));
- assert(test_rmlvo(ctx, NULL, NULL, NULL, NULL, NULL));
assert(!test_rmlvo(ctx, "does-not-exist", "", "", "", ""));
+ assert(test_rmlvo_env(ctx, "evdev", "", "us", "", ""));
+ assert(test_rmlvo_env(ctx, "evdev", "", "us", "", "ctrl:nocaps"));
+ assert(test_rmlvo_env(ctx, "evdev", "", "us,ca", ",,,multix", "grp:alts_toggle"));
+ assert(!test_rmlvo_env(ctx, "broken", "what-on-earth", "invalid", "", ""));
+
+ xkb_context_unref(ctx);
+
+ ctx = test_get_context(0);
+ assert(test_rmlvo_env(ctx, "broken", "but", "ignored", "per", "ctx flags"));
+
/* Test response to invalid flags. */
{
struct xkb_rule_names rmlvo = { NULL };