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>
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>
28 #include <grub/normal.h>
29 #include <grub/time.h>
31 GRUB_MOD_LICENSE ("GPLv3+");
34 static const char testfile
[] =
35 "menuentry \"test\" {\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"
41 "menuentry \" הַרמלל(טוֹבָ) לֶךְ\" --class opensuse --class linux --class os {\n"
44 "menuentry \"الرملل جِداً لِكَ\" --class gentoo --class linux --class os {\n"
47 "menuentry \"ὑπόγυͅον\" --class kubuntu --class linux --class os {\n"
50 "menuentry \"سَّ نِّ نَّ نٌّ نّْ\" --class linuxmint --class linux --class os {\n"
53 /* Chinese & UTF-8 test from Carbon Jiao. */
54 "menuentry \"从硬盘的第一主分区启动\" --class \"windows xp\" --class windows --class os {\n"
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
=
69 .get_contents
= get_test_cfg
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. */
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)
115 font
= grub_font_load ("unicode");
119 grub_test_assert (0, "unicode font not found: %s", grub_errmsg
);
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
++)
130 #if defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_IEEE1275)
131 if (grub_test_video_modes
[i
].width
> 1024)
133 if (grub_strcmp (tests
[j
].name
, "gfxmenu") == 0
134 && grub_test_video_modes
[i
].width
> 800)
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
);
144 grub_test_assert (0, "can't start capture: %d: %s",
145 grub_errno
, grub_errmsg
);
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 ())
156 grub_env_context_open ();
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 ();
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
);