Debian Codegraph @

test/merge_modes.c.jinja

raw
1 /*
2 * WARNING: This file is automatically generated by: {{ script }}
3 * Do not edit manually!
4 */
5
6 /*
7 * Copyright © 2024-2025 Pierre Le Marre <[email protected]>
8 * SPDX-License-Identifier: MIT
9 */
10
11 #include "config.h"
12
13 #include <assert.h>
14 #include <limits.h>
15 #include <stdbool.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include "test.h"
20 #include "utils.h"
21 {% if not compiler.is_default %}
22 #include "external_xkb_compilers.h"
23 {% endif %}
24
25
26 enum update_files {
27 NO_UPDATE = 0,
28 UPDATE_USING_TEST_INPUT,
29 UPDATE_USING_TEST_OUTPUT
30 };
31
32 #define GOLDEN_TESTS_OUTPUTS "keymaps/merge-modes/"
33
34 {% if compiler.is_default %}
35
36 /* xkbcommon buffer compiler */
37 static struct xkb_keymap *
38 compile_buffer(struct xkb_context *context, enum xkb_keymap_format format,
39 const char *buf, size_t len, void *private)
40 {
41 return test_compile_buffer(context, format, buf, len);
42 }
43
44 static bool
45 test_compile(struct xkb_context *ctx, const char* xkb_root,
46 const char *test_title,
47 const char *keymap_str, size_t keymap_len,
48 const char *path, bool update)
49 {
50 return test_compile_output(ctx, XKB_KEYMAP_FORMAT_TEXT_V2,
51 XKB_KEYMAP_USE_ORIGINAL_FORMAT, compile_buffer,
52 NULL, test_title, keymap_str, keymap_len,
53 path, !!update);
54 }
55
56 {% else %}
57
58 /* Third-party compiler: {{ compiler.name }} */
59 struct compile_buffer_{{ compiler.name }}_data {
60 const char* xkb_root;
61 };
62
63 static int
64 compile_buffer_{{ compiler.name }}(const char *buf, size_t len, void *private,
65 char* *out, size_t *out_size)
66 {
67 struct compile_buffer_{{ compiler.name }}_data *data = private;
68 {% if compiler.name == "xkbcomp" %}
69 /* Xorg xkbcomp */
70 return compile_with_xkbcomp(NULL, data->xkb_root, buf, len, out, out_size);
71 {% elif compiler.name == "kbvm" %}
72 /* kbvm */
73 return compile_with_kbvm(data->xkb_root, buf, len, out, out_size);
74 {% else %}
75 #error "Unsupported compiler: {{ compiler.name }}"
76 {% endif %}
77 }
78
79 static bool
80 test_compile(struct xkb_context *ctx, const char* xkb_root,
81 const char *test_title,
82 const char *keymap_str, size_t keymap_len,
83 const char *path, bool update)
84 {
85 struct compile_buffer_{{ compiler.name }}_data data = { .xkb_root = xkb_root };
86 return test_third_pary_compile_output(compile_buffer_{{ compiler.name}},
87 &data, test_title,
88 keymap_str, keymap_len,
89 path, !!update);
90 }
91 {% endif %}
92
93 struct keymap_test_data {
94 const char* title;
95 const char* file;
96 const char* keymap;
97 const char* expected;
98 };
99
100 {% if compiler.extended_syntax %}
101 static void
102 test_vmods(struct xkb_context *ctx, const char* xkb_root,
103 enum update_files update) {
104
105 #define BASE_VMODS \
106 "virtual_modifiers U1, U2, U3, U4, U5, U6;\n" \
107 "virtual_modifiers Z1=none, Z2=none, Z3=none, Z4=none, Z5=none, Z6=none;\n"\
108 "virtual_modifiers M1=0x1000, M2=0x2000, M3=0x3000, " \
109 "M4=0x4000, M5=0x5000, M6=0x6000;\n"
110
111 const struct keymap_test_data tests[] = {
112 /*
113 * Change virtual modifiers in same component
114 */
115
116 {
117 .title = "same-component-include-default-augment",
118 .keymap =
119 "xkb_keymap {\n"
120 " xkb_types \"\" {\n"
121 " include \"merge_modes_vmods(base)|merge_modes_vmods(new)\"\n"
122 " };\n"
123 " xkb_compat \"\" { interpret.repeat= True; };\n"
124 "};",
125 .file = "same-component-include-default-augment",
126 },
127 {
128 .title = "same-component-include-default-override",
129 .keymap =
130 "xkb_keymap {\n"
131 " xkb_types \"\" {\n"
132 " include \"merge_modes_vmods(base)+merge_modes_vmods(new)\"\n"
133 " };\n"
134 " xkb_compat \"\" { interpret.repeat= True; };\n"
135 "};",
136 .file = "same-component-include-default-override",
137 },
138
139 /*
140 * Change virtual modifiers in another component
141 */
142
143 {
144 .title = "other-component-direct",
145 .keymap =
146 "xkb_keymap {\n"
147 " xkb_types {\n"
148 BASE_VMODS
149 " };\n"
150 " xkb_compat \"\" {\n"
151 " augment virtual_modifiers U1, U2=none, U3=0x300000;\n"
152 " override virtual_modifiers U4, U5=none, U6=0x600000;\n"
153 " augment virtual_modifiers Z1, Z2=none, Z3=0x310000;\n"
154 " override virtual_modifiers Z4, Z5=none, Z6=0x610000;\n"
155 " augment virtual_modifiers M1, M2=none, M3=0x320000;\n"
156 " override virtual_modifiers M4, M5=none, M6=0x620000;\n"
157 " };\n"
158 "};",
159 .file = "other-component-direct",
160 },
161 {
162 .title = "other-component-include-default",
163 .keymap =
164 "xkb_keymap {\n"
165 " xkb_types \"\" {\n"
166 BASE_VMODS
167 " };\n"
168 " xkb_compat \"\" { include \"merge_modes_vmods(new)\" };\n"
169 "};",
170 .file = "same-component-include-default-override",
171 },
172 {
173 .title = "other-component-include-augment",
174 .keymap =
175 "xkb_keymap {\n"
176 " xkb_types \"\" {\n"
177 BASE_VMODS
178 " };\n"
179 " xkb_compat \"\" { augment \"merge_modes_vmods(new)\" };\n"
180 "};",
181 .file = "same-component-include-default-augment",
182 },
183 {
184 .title = "other-component-include-override",
185 .keymap =
186 "xkb_keymap {\n"
187 " xkb_types \"\" {\n"
188 BASE_VMODS
189 " };\n"
190 " xkb_compat \"\" { override \"merge_modes_vmods(new)\" };\n"
191 "};",
192 .file = "same-component-include-default-override",
193 },
194 {
195 .title = "other-component-include-replace",
196 .keymap =
197 "xkb_keymap {\n"
198 " xkb_types \"\" {\n"
199 BASE_VMODS
200 " };\n"
201 " xkb_compat \"\" { replace \"merge_modes_vmods(new)\" };\n"
202 "};",
203 .file = "same-component-include-default-override",
204 },
205 };
206
207 for (unsigned int k = 0; k < ARRAY_SIZE(tests); k++) {
208 const struct keymap_test_data* const test = &tests[k];
209
210 char title[1024] = { 0 };
211 snprintf(title, sizeof(title), "%s #%u: %s", __func__, k, test->title);
212
213 char path[PATH_MAX] = { 0 };
214 snprintf(path, sizeof(path),
215 GOLDEN_TESTS_OUTPUTS "vmods-%s{{ compiler.suffix }}.xkb",
216 test->file);
217
218 assert(test_compile(ctx, xkb_root, title,
219 test->keymap, strlen(test->keymap),
220 path, !!update));
221 }
222 }
223 {% endif %}
224
225 static void
226 test_compat(struct xkb_context *ctx, const char* xkb_root,
227 enum update_files update)
228 {
229 // Github Issue #566
230 const char keymap_str[] =
231 "xkb_keymap {\n"
232 " xkb_keycodes { <> = 8; };\n"
233 " xkb_compat {\n"
234 " interpret A { repeat = true; };\n"
235 " interpret A { repeat = true; };\n"
236 " interpret A { action = SetMods(mods=Mod1); };\n"
237 " interpret B { repeat = true; };\n"
238 " interpret B { repeat = true; };\n"
239 " augment interpret B { action = SetMods(mods=Mod1); };\n"
240 " interpret C { repeat = true; };\n"
241 " interpret C { repeat = true; };\n"
242 " override interpret C { action = SetMods(mods=Mod1); };\n"
243 " interpret D { repeat = true; };\n"
244 " interpret D { repeat = true; };\n"
245 " replace interpret D { action = SetMods(mods=Mod1); };\n"
246 "\n"
247 " indicator \"A\" { modifiers=Shift; };\n"
248 " indicator \"A\" { modifiers=Lock; };\n"
249 " indicator \"A\" { groups= Group1; };\n"
250 " indicator \"B\" { modifiers=Shift; };\n"
251 " indicator \"B\" { modifiers=Lock; };\n"
252 " augment indicator \"B\" { groups=Group1; };\n"
253 " indicator \"C\" { modifiers=Shift; };\n"
254 " indicator \"C\" { modifiers=Lock; };\n"
255 " override indicator \"C\" { groups=Group1; };\n"
256 " indicator \"D\" { modifiers=Shift; };\n"
257 " indicator \"D\" { modifiers=Lock; };\n"
258 " replace indicator \"D\" { groups=Group1; };\n"
259 " };\n"
260 " xkb_symbols { key <> { }; };\n"
261 "};\n";
262
263 assert(test_compile(ctx, xkb_root, "test_merge_mode: compat",
264 keymap_str, ARRAY_SIZE(keymap_str) - 1,
265 GOLDEN_TESTS_OUTPUTS "compat{{ compiler.suffix }}.xkb",
266 !!update));
267 }
268
269 static void
270 test_merge_modes(struct xkb_context *ctx, const char* xkb_root,
271 enum update_files update) {
272 const struct keymap_test_data tests[] = {
273 {% for group in tests %}
274 /*
275 * #{{ loop.index0 }}{{ " " + group.title if group.title else "" }}
276 */
277 {% for test in group.tests %}
278 {
279 .title = "#{{ loop.index0 }} {{ test.title | escape_quotes }}",
280 .file = "{{ test.file | string | escape_quotes }}",
281 .keymap =
282 {%- for line in test.content.splitlines() +%}
283 "{{ line | escape_quotes }}\n"
284 {%- endfor %},
285 .expected =
286 {% for line in test.expected.splitlines() %}
287 "{{ line | escape_quotes }}\n"
288 {% endfor %}
289 },
290 {% endfor %}
291 {% endfor %}
292 };
293
294 for (unsigned int k = 0; k < ARRAY_SIZE(tests); k++) {
295 const struct keymap_test_data* const test = &tests[k];
296
297 char title[1024] = { 0 };
298 snprintf(title, sizeof(title), "%s #%u: %s", __func__, k, test->title);
299
300 char path[PATH_MAX] = { 0 };
301 {% if compiler.is_default %}
302 snprintf(path, sizeof(path), GOLDEN_TESTS_OUTPUTS "%s.xkb", test->file);
303 {% else %}
304 snprintf(path, sizeof(path),
305 GOLDEN_TESTS_OUTPUTS "%02u-%s{{ compiler.suffix }}.xkb",
306 k, test->file);
307 {% endif %}
308
309 const char* const keymap = (update == UPDATE_USING_TEST_INPUT)
310 ? test->expected
311 : test->keymap;
312 assert(test_compile(ctx, xkb_root, title, keymap, strlen(keymap),
313 path, !!update));
314 }
315 }
316
317 static void
318 test_defaults(struct xkb_context *ctx, const char* xkb_root,
319 enum update_files update)
320 {
321 const struct keymap_test_data tests[] = {
322 {
323 .title = "plain",
324 .file = "plain",
325 .keymap =
326 "xkb_keymap {\n"
327 " xkb_keycodes {\n"
328 " <A> = 38;\n"
329 " <S> = 39;\n"
330 " <D> = 40;\n"
331 " <F> = 41;\n"
332 " <G> = 42;\n"
333 "\n"
334 " indicator 1 = \"A\";\n"
335 " indicator 2 = \"B\";\n"
336 " indicator 3 = \"C\";\n"
337 " };\n"
338 " xkb_types {\n"
339 " type \"ONE_LEVEL\" {\n"
340 " map[None] = 1;\n"
341 " };\n"
342 " type \"ALPHABETIC\" {\n"
343 " modifiers = Shift + Lock;\n"
344 " map[Shift] = 2;\n"
345 " map[Lock] = 2;\n"
346 " };\n"
347 " };\n"
348 " xkb_compat {\n"
349 " virtual_modifiers M1=0x1000, M2=0x2000, M3=0x4000, M4=0x8000;\n"
350 "\n"
351 " interpret.repeat= False;\n"
352 " // Effective: override\n"
353 " interpret.repeat= True;\n"
354 "\n"
355 " interpret.virtualmod = M1;\n"
356 " // Effective: override\n"
357 " interpret.virtualmod = M2;\n"
358 " // Ineffective: cannot augment previous value\n"
359 " augment interpret.virtualmod = M3;\n"
360 "\n"
361 " SetGroup.group = 1;\n"
362 " // Effective: override\n"
363 " SetGroup.group = 2;\n"
364 " // Ineffective: cannot augment previous value\n"
365 " augment SetGroup.group = 3;\n"
366 "\n"
367 "\n"
368 " // Effective: *override* every explicit field\n"
369 " interpret a {\n"
370 " virtualmod = M4;\n"
371 " action=SetGroup(group=1);\n"
372 " };\n"
373 " interpret A {\n"
374 " repeat = False;\n"
375 " virtualmod = M1;\n"
376 " action=SetMods(mods=M1);\n"
377 " };\n"
378 "\n"
379 "\n"
380 " // Effective: no previous interpret entry,\n"
381 " // so *override* every explicit field\n"
382 " augment interpret s {\n"
383 " repeat = False;\n"
384 " action=SetGroup();\n"
385 " };\n"
386 " // Only augment fields not set previously (explicit or implicit)\n"
387 " augment interpret s {\n"
388 " // Ineffective: cannot augment previous implicit value\n"
389 " virtualmod = M4;\n"
390 " // Ineffective: cannot augment previous explicit value\n"
391 " action=SetGroup(group=4);\n"
392 " // Effective: no previous value\n"
393 " useModMapMods=level1;\n"
394 " };\n"
395 " augment interpret S {\n"
396 " action=SetGroup(group=4);\n"
397 " };\n"
398 " interpret g {\n"
399 " virtualmod = M3;\n"
400 " repeat = False;"
401 " action = SetGroup(group=3);\n"
402 " };\n"
403 " indicator \"C\" {\n"
404 " modifiers = M3;\n"
405 " whichmodstate = locked;\n"
406 " };\n"
407 "\n"
408 "\n"
409 " indicator.modifiers = M1;\n"
410 " indicator.modifiers = M2;\n"
411 " augment indicator.modifiers = M3;\n"
412 " indicator.groups = All - 1;\n"
413 " indicator.controls = AudibleBell;\n"
414 "\n"
415 " indicator \"A\" {\n"
416 " modifiers = M4;\n"
417 " whichmodstate = base;\n"
418 " };\n"
419 " indicator \"A\" {\n"
420 " whichmodstate = locked;\n"
421 " whichgroupstate = locked;\n"
422 " controls = SlowKeys;\n"
423 " };\n"
424 " augment indicator \"B\" {\n"
425 " modifiers = M4;\n"
426 " whichmodstate = base;\n"
427 " };\n"
428 " augment indicator \"B\" {\n"
429 " groups = 4;\n"
430 " whichmodstate = locked;\n"
431 " whichgroupstate = locked;\n"
432 " };\n"
433 " };\n"
434 " xkb_symbols {\n"
435 " name[1] = \"xxx\";\n"
436 " name[1] = \"yyy\";\n"
437 " augment name[1] = \"zzz\";\n"
438 "\n"
439 " key <A> { [a, A] };\n"
440 " key <S> { [s, S] };\n"
441 " modifier_map Shift { <A> };\n"
442 " modifier_map Control { <S> };\n"
443 "\n"
444 " key <G> { type = \"ONE_LEVEL\", repeat=true, [g] };"
445 " modifier_map Mod3 { <G> };\n"
446 "\n"
447 " key.repeat = false;\n"
448 " key.vmods = M1;\n"
449 " key.vmods = M2;\n"
450 " augment key.vmods = M3;\n"
451 "\n"
452 " key <D> { vmods = M4, [d, D] };\n"
453 " augment key <F> { vmods = M4, [f, F] };\n"
454 " augment key <F> { vmods = M1, repeat = true };\n"
455 " };\n"
456 "};\n",
457 .expected =
458 "xkb_keymap {\n"
459 " xkb_keycodes {\n"
460 " <A> = 38;\n"
461 " <S> = 39;\n"
462 " <D> = 40;\n"
463 " <F> = 41;\n"
464 " indicator 1 = \"A\";\n"
465 " indicator 2 = \"B\";\n"
466 " indicator 3 = \"C\";\n"
467 " };\n"
468 " xkb_types {\n"
469 " type \"ONE_LEVEL\" {\n"
470 " map[None] = 1;\n"
471 " };\n"
472 " type \"ALPHABETIC\" {\n"
473 " modifiers = Shift + Lock;\n"
474 " map[Shift] = 2;\n"
475 " map[Lock] = 2;\n"
476 " };\n"
477 " };\n"
478 " xkb_compat {\n"
479 " virtual_modifiers M1=0x1000, M2=0x2000, M3=0x4000, M4=0x8000;\n"
480 "\n"
481 " interpret.repeat= True;\n"
482 " interpret.virtualmod = M2;\n"
483 " SetGroup.group = 2;\n"
484 "\n"
485 " interpret a {\n"
486 " virtualmod = M4;\n"
487 " action=SetGroup(group=1);\n"
488 " };\n"
489 " interpret A {\n"
490 " repeat = False;\n"
491 " virtualmod = M1;\n"
492 " action=SetMods(mods=M1);\n"
493 " };\n"
494 " interpret s {\n"
495 " repeat = False;\n"
496 " action=SetGroup(group=2);\n"
497 " useModMapMods=level1;\n"
498 " };\n"
499 " interpret S {\n"
500 " action=SetGroup(group=4);"
501 " };\n"
502 "\n"
503 " indicator.modifiers = M2;\n"
504 " indicator.groups = All - 1;\n"
505 " indicator.controls = AudibleBell;\n"
506 "\n"
507 " indicator \"A\" {\n"
508 " modifiers = M4;\n"
509 " whichmodstate = locked;\n"
510 " whichgroupstate = locked;\n"
511 " controls = SlowKeys;\n"
512 " };\n"
513 " indicator \"B\" {\n"
514 " modifiers = M4;\n"
515 " whichmodstate = base;\n"
516 " whichgroupstate = locked;\n"
517 " };\n"
518 " };\n"
519 " xkb_symbols {\n"
520 " name[1] = \"yyy\";\n"
521 "\n"
522 " key <A> { [a, A] };\n"
523 " key <S> { [s, S] };\n"
524 " modifier_map Shift { <A> };\n"
525 " modifier_map Control { <S> };\n"
526 "\n"
527 " key <D> { vmods = M4, repeat = false, [d, D] };\n"
528 " key <F> { vmods = M4, repeat = true , [f, F] };\n"
529 " key <G> { type = \"ONE_LEVEL\", repeat=true, vmods=M3, [g] };"
530 " };\n"
531 "};\n"
532 },
533 {
534 .title = "include",
535 .file = "include",
536 .keymap =
537 "xkb_keymap {\n"
538 " xkb_keycodes {\n"
539 " <A> = 38;\n"
540 " <S> = 39;\n"
541 " <D> = 40;\n"
542 " <F> = 41;\n"
543 " <G> = 42;\n"
544 "\n"
545 " indicator 1 = \"A\";\n"
546 " indicator 2 = \"B\";\n"
547 " indicator 3 = \"C\";\n"
548 " };\n"
549 " xkb_types {\n"
550 " type \"ONE_LEVEL\" {\n"
551 " map[None] = 1;\n"
552 " };\n"
553 " type \"ALPHABETIC\" {\n"
554 " modifiers = Shift + Lock;\n"
555 " map[Shift] = 2;\n"
556 " map[Lock] = 2;\n"
557 " };\n"
558 " };\n"
559 " xkb_compat {\n"
560 " virtual_modifiers M1,M2,M3;"
561 " interpret.virtualmod = M3;\n"
562 " indicator.modifiers = M3;\n"
563 " SetGroup.group = 3;\n"
564 "\n"
565 " include \"merge_modes_defaults\"\n"
566 "\n"
567 " interpret g {\n"
568 " action = SetGroup();\n"
569 " };\n"
570 " indicator \"C\" {\n"
571 " whichmodstate = locked;\n"
572 " };\n"
573 " };\n"
574 " xkb_symbols {\n"
575 " name[1] = \"XXX\";\n"
576 "\n"
577 " key.type = \"ONE_LEVEL\";"
578 "\n"
579 " include \"merge_modes_defaults\"\n"
580 "\n"
581 " key <G> { repeat = true, [g, G] };\n"
582 " modifier_map Mod3 { <G> };\n"
583 " };\n"
584 "};\n",
585 .expected =
586 "xkb_keymap {\n"
587 " xkb_keycodes {\n"
588 " <A> = 38;\n"
589 " <S> = 39;\n"
590 " <D> = 40;\n"
591 " <F> = 41;\n"
592 " indicator 1 = \"A\";\n"
593 " indicator 2 = \"B\";\n"
594 " indicator 3 = \"C\";\n"
595 " };\n"
596 " xkb_types {\n"
597 " type \"ONE_LEVEL\" {\n"
598 " map[None] = 1;\n"
599 " };\n"
600 " type \"ALPHABETIC\" {\n"
601 " modifiers = Shift + Lock;\n"
602 " map[Shift] = 2;\n"
603 " map[Lock] = 2;\n"
604 " };\n"
605 " };\n"
606 " xkb_compat {\n"
607 " virtual_modifiers M1=0x1000, M2=0x2000, M3=0x4000, M4=0x8000;\n"
608 "\n"
609 " interpret.repeat= True;\n"
610 " interpret.virtualmod = M2;\n"
611 " SetGroup.group = 2;\n"
612 "\n"
613 " interpret a {\n"
614 " virtualmod = M4;\n"
615 " action=SetGroup(group=1);\n"
616 " };\n"
617 " interpret A {\n"
618 " repeat = False;\n"
619 " virtualmod = M1;\n"
620 " action=SetMods(mods=M1);\n"
621 " };\n"
622 " interpret s {\n"
623 " repeat = False;\n"
624 " action=SetGroup(group=2);\n"
625 " useModMapMods=level1;\n"
626 " };\n"
627 " interpret S {\n"
628 " action=SetGroup(group=4);\n"
629 " };\n"
630 "\n"
631 " indicator.modifiers = M2;\n"
632 " indicator.groups = All - 1;\n"
633 " indicator.controls = AudibleBell;\n"
634 "\n"
635 " indicator \"A\" {\n"
636 " modifiers = M4;\n"
637 " whichmodstate = locked;\n"
638 " whichgroupstate = locked;\n"
639 " controls = SlowKeys;\n"
640 " };\n"
641 " indicator \"B\" {\n"
642 " modifiers = M4;\n"
643 " whichmodstate = base;\n"
644 " whichgroupstate = locked;\n"
645 " };\n"
646 " };\n"
647 " xkb_symbols {\n"
648 " name[1] = \"yyy\";\n"
649 "\n"
650 " key <A> { [a, A] };\n"
651 " key <S> { [s, S] };\n"
652 " modifier_map Shift { <A> };\n"
653 " modifier_map Control { <S> };\n"
654 "\n"
655 " key <D> { vmods = M4, repeat = false, [d, D] };\n"
656 " key <F> { vmods = M4, repeat = true , [f, F] };\n"
657 " key <G> { vmods = M3, [g] };\n"
658 " };\n"
659 "};\n"
660 }
661 };
662
663 for (unsigned int k = 0; k < ARRAY_SIZE(tests); k++) {
664 const struct keymap_test_data* const test = &tests[k];
665
666 char title[1024] = { 0 };
667 snprintf(title, sizeof(title), "%s #%u: %s", __func__, k, test->title);
668
669 char path[PATH_MAX] = { 0 };
670 snprintf(path, sizeof(path), GOLDEN_TESTS_OUTPUTS "defaults-%s{{ compiler.suffix }}.xkb",
671 test->file);
672
673 assert(test_compile(ctx, xkb_root, title,
674 test->keymap, strlen(test->keymap),
675 path, !!update));
676 }
677 }
678
679 int
680 main(int argc, char *argv[])
681 {
682 test_init();
683
684 /* Check if we run the tests or just update their outputs */
685 enum update_files update_output_files = NO_UPDATE;
686 if (argc > 1) {
687 if (streq(argv[1], "update")) {
688 /* Update files with *expected* results */
689 update_output_files = UPDATE_USING_TEST_INPUT;
690 } else if (streq(argv[1], "update-obtained")) {
691 /* Update files with *obtained* results */
692 update_output_files = UPDATE_USING_TEST_OUTPUT;
693 } else {
694 fprintf(stderr, "ERROR: unsupported argument: \"%s\".\n", argv[1]);
695 exit(EXIT_FAILURE);
696 }
697 }
698
699 struct xkb_context *ctx = test_get_context(CONTEXT_NO_FLAG);
700 assert(ctx);
701
702 char* xkb_root = test_get_path("");
703 assert(xkb_root);
704
705 {% if compiler.extended_syntax %}
706 test_vmods(ctx, xkb_root, update_output_files);
707 {% endif %}
708 test_compat(ctx, xkb_root, update_output_files);
709 test_merge_modes(ctx, xkb_root, update_output_files);
710 test_defaults(ctx, xkb_root, update_output_files);
711
712 free(xkb_root);
713 xkb_context_unref(ctx);
714
715 return EXIT_SUCCESS;
716 }