Indentation fix, cleanup.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / tests / gfxterm_menu.c
blob8f63dc27a35bd769ecb5d94599de3ba9e97cf5dc
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2013 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 /* All tests need to include test.h for GRUB testing framework. */
20 #include <grub/test.h>
21 #include <grub/dl.h>
22 #include <grub/video.h>
23 #include <grub/video_fb.h>
24 #include <grub/command.h>
25 #include <grub/font.h>
26 #include <grub/procfs.h>
27 #include <grub/env.h>
28 #include <grub/normal.h>
29 #include <grub/time.h>
31 GRUB_MOD_LICENSE ("GPLv3+");
34 static const char testfile[] =
35 "menuentry \"test\" {\n"
36 "\ttrue\n"
37 "}\n"
38 "menuentry \"s̛ ơ t o̒ s̒ u o̕̚ 8.04 m̂ñåh̊z̆x̣ a̡ b̢g̢ u᷎ô᷎ ô᷎ O̷ a̖̣ ȃ̐\" --class ubuntu --class linux --class os {\n"
39 "\ttrue\n"
40 "}\n"
41 "menuentry \" הַרמלל(טוֹבָ) לֶךְ\" --class opensuse --class linux --class os {\n"
42 "\ttrue\n"
43 "}\n"
44 "menuentry \"الرملل جِداً لِكَ\" --class gentoo --class linux --class os {\n"
45 "\ttrue\n"
46 "}\n"
47 "menuentry \"ὑπόγυͅον\" --class kubuntu --class linux --class os {\n"
48 "\ttrue\n"
49 "}\n"
50 "menuentry \"سَّ نِّ نَّ نٌّ نّْ\" --class linuxmint --class linux --class os {\n"
51 "\ttrue\n"
52 "}\n"
53 /* Chinese & UTF-8 test from Carbon Jiao. */
54 "menuentry \"从硬盘的第一主分区启动\" --class \"windows xp\" --class windows --class os {\n"
55 "\ttrue\n"
56 "}\n"
57 "timeout=3\n";
59 static char *
60 get_test_cfg (grub_size_t *sz)
62 *sz = grub_strlen (testfile);
63 return grub_strdup (testfile);
66 struct grub_procfs_entry test_cfg =
68 .name = "test.cfg",
69 .get_contents = get_test_cfg
72 struct
74 const char *name;
75 const char *var;
76 const char *val;
77 } tests[] =
79 { "gfxterm_menu", NULL, NULL },
80 { "gfxmenu", "theme", "starfield/theme.txt" },
81 { "gfxterm_ar", "lang", "en@arabic" },
82 { "gfxterm_cyr", "lang", "en@cyrillic" },
83 { "gfxterm_heb", "lang", "en@hebrew" },
84 { "gfxterm_gre", "lang", "en@greek" },
85 { "gfxterm_ru", "lang", "ru" },
86 { "gfxterm_fr", "lang", "fr" },
87 { "gfxterm_quot", "lang", "en@quot" },
88 { "gfxterm_piglatin", "lang", "en@piglatin" },
89 { "gfxterm_ch", "lang", "de_CH" },
90 { "gfxterm_red", "menu_color_normal", "red/blue" },
91 { "gfxterm_high", "menu_color_highlight", "blue/red" },
94 #define FONT_NAME "Unknown Regular 16"
96 /* Functional test main method. */
97 static void
98 gfxterm_menu (void)
100 unsigned i, j;
101 grub_font_t font;
103 grub_dl_load ("png");
104 grub_dl_load ("gettext");
105 grub_dl_load ("gfxterm");
107 grub_errno = GRUB_ERR_NONE;
109 grub_dl_load ("gfxmenu");
111 font = grub_font_get (FONT_NAME);
112 if (font && grub_strcmp (font->name, FONT_NAME) != 0)
113 font = 0;
114 if (!font)
115 font = grub_font_load ("unicode");
117 if (!font)
119 grub_test_assert (0, "unicode font not found: %s", grub_errmsg);
120 return;
123 grub_procfs_register ("test.cfg", &test_cfg);
125 for (j = 0; j < ARRAY_SIZE (tests); j++)
126 for (i = 0; i < GRUB_TEST_VIDEO_SMALL_N_MODES; i++)
128 grub_uint64_t start;
130 #if defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_IEEE1275)
131 if (grub_test_video_modes[i].width > 1024)
132 continue;
133 if (grub_strcmp (tests[j].name, "gfxmenu") == 0
134 && grub_test_video_modes[i].width > 800)
135 continue;
136 #endif
137 start = grub_get_time_ms ();
139 grub_video_capture_start (&grub_test_video_modes[i],
140 grub_video_fbstd_colors,
141 grub_test_video_modes[i].number_of_colors);
142 if (grub_errno)
144 grub_test_assert (0, "can't start capture: %d: %s",
145 grub_errno, grub_errmsg);
146 return;
148 grub_terminal_input_fake_sequence ((int []) { -1, -1, -1, GRUB_TERM_KEY_DOWN, -1, 'e',
149 -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, '\e', -1, '\e' }, 14);
151 grub_video_checksum (tests[j].name);
153 if (grub_test_use_gfxterm ())
154 return;
156 grub_env_context_open ();
157 if (tests[j].var)
158 grub_env_set (tests[j].var, tests[j].val);
159 grub_normal_execute ("(proc)/test.cfg", 1, 0);
160 grub_env_context_close ();
162 grub_test_use_gfxterm_end ();
164 grub_terminal_input_fake_sequence_end ();
165 grub_video_checksum_end ();
166 grub_video_capture_end ();
168 if (tests[j].var)
169 grub_env_unset (tests[j].var);
170 grub_printf ("%s %dx%dx%s done %lld ms\n", tests[j].name,
171 grub_test_video_modes[i].width,
172 grub_test_video_modes[i].height,
173 grub_video_checksum_get_modename (), (long long) (grub_get_time_ms () - start));
176 grub_procfs_unregister (&test_cfg);
179 /* Register example_test method as a functional test. */
180 GRUB_FUNCTIONAL_TEST (gfxterm_menu, gfxterm_menu);