2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2010 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 #ifndef GRUB_TEST_HEADER
20 #define GRUB_TEST_HEADER
23 #include <grub/list.h>
24 #include <grub/misc.h>
25 #include <grub/types.h>
26 #include <grub/symbol.h>
28 #include <grub/video.h>
29 #include <grub/video_fb.h>
38 struct grub_test
*next
;
39 struct grub_test
**prev
;
44 /* The test main function. */
47 typedef struct grub_test
*grub_test_t
;
49 extern grub_test_t grub_test_list
;
51 void grub_test_register (const char *name
, void (*test
) (void));
52 void grub_test_unregister (const char *name
);
54 /* Execute a test and print results. */
55 int grub_test_run (grub_test_t test
);
57 /* Test `cond' for nonzero; log failure otherwise. */
58 void grub_test_nonzero (int cond
, const char *file
,
59 const char *func
, grub_uint32_t line
,
61 __attribute__ ((format (GNU_PRINTF
, 5, 6)));
63 /* Macro to fill in location details and an optional error message. */
64 void grub_test_assert_helper (int cond
, const char *file
,
65 const char *func
, grub_uint32_t line
,
66 const char *condstr
, const char *fmt
, ...)
67 __attribute__ ((format (GNU_PRINTF
, 6, 7)));
69 #define grub_test_assert(cond, ...) \
70 grub_test_assert_helper(cond, GRUB_FILE, __FUNCTION__, __LINE__, \
71 #cond, ## __VA_ARGS__);
73 void grub_unit_test_init (void);
74 void grub_unit_test_fini (void);
76 /* Macro to define a unit test. */
77 #define GRUB_UNIT_TEST(name, funp) \
78 void grub_unit_test_init (void) \
80 grub_test_register (name, funp); \
83 void grub_unit_test_fini (void) \
85 grub_test_unregister (name); \
88 /* Macro to define a functional test. */
89 #define GRUB_FUNCTIONAL_TEST(name, funp) \
92 grub_test_register (#name, funp); \
97 grub_test_unregister (#name); \
101 grub_video_checksum (const char *basename_in
);
103 grub_video_checksum_end (void);
105 grub_terminal_input_fake_sequence (int *seq_in
, int nseq_in
);
107 grub_terminal_input_fake_sequence_end (void);
109 grub_video_checksum_get_modename (void);
112 #define GRUB_TEST_VIDEO_SMALL_N_MODES 7
113 #define GRUB_TEST_VIDEO_ALL_N_MODES 31
115 extern struct grub_video_mode_info grub_test_video_modes
[GRUB_TEST_VIDEO_ALL_N_MODES
];
118 grub_test_use_gfxterm (void);
119 void grub_test_use_gfxterm_end (void);
125 #endif /* ! GRUB_TEST_HEADER */