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 /* Chinese & UTF-8 test from Carbon Jiao. */
37 "The quick brown fox jumped over the lazy dog.\n"
39 Code point Description UTF-8 encoding
40 ----------- ------------------------------ --------------
41 U+263A unfilled smiley face E2 98 BA
42 U+00A1 inverted exclamation point C2 A1
43 U+00A3 British pound currency symbol C2 A3
44 U+03C4 Greek tau CF 84
45 U+00E4 lowercase letter a with umlaut C3 A4
46 U+2124 set 'Z' symbol (integers) E2 84 A4
47 U+2286 subset symbol E2 8A 86
48 U+211D set 'R' symbol (real numbers) E2 84 9D */
49 "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
50 " \xC2\xA1\xCF\x84\xC3\xA4u! "
51 " \xE2\x84\xA4\xE2\x8A\x86\xE2\x84\x9D\n"
52 /* Test handling of bad (non-UTF8) sequences*/
53 "\x99Hello\xc2Hello\xc1\x81Hello\n";
57 get_test_txt (grub_size_t
*sz
)
59 *sz
= grub_strlen (testfile
);
60 return grub_strdup (testfile
);
63 struct grub_procfs_entry test_txt
=
66 .get_contents
= get_test_txt
69 #define FONT_NAME "Unknown Regular 16"
71 /* Functional test main method. */
73 cmdline_cat_test (void)
78 grub_dl_load ("gfxterm");
79 grub_errno
= GRUB_ERR_NONE
;
81 font
= grub_font_get (FONT_NAME
);
82 if (font
&& grub_strcmp (font
->name
, FONT_NAME
) != 0)
85 font
= grub_font_load ("unicode");
89 grub_test_assert (0, "unicode font not found: %s", grub_errmsg
);
93 grub_procfs_register ("test.txt", &test_txt
);
95 for (i
= 0; i
< GRUB_TEST_VIDEO_SMALL_N_MODES
; i
++)
97 grub_video_capture_start (&grub_test_video_modes
[i
],
98 grub_video_fbstd_colors
,
99 grub_test_video_modes
[i
].number_of_colors
);
100 grub_terminal_input_fake_sequence ((int [])
101 { 'c', 'a', 't', ' ',
102 '(', 'p', 'r', 'o', 'c', ')',
103 '/', 't', 'e', 's', 't', '.',
106 GRUB_TERM_NO_KEY
, '\e'},
109 grub_video_checksum ("cmdline_cat");
111 if (!grub_test_use_gfxterm ())
112 grub_cmdline_run (1, 0);
114 grub_test_use_gfxterm_end ();
116 grub_terminal_input_fake_sequence_end ();
117 grub_video_checksum_end ();
118 grub_video_capture_end ();
121 grub_procfs_unregister (&test_txt
);
124 /* Register example_test method as a functional test. */
125 GRUB_FUNCTIONAL_TEST (cmdline_cat_test
, cmdline_cat_test
);