2021-05-14 11:10:03 +02:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
|
|
|
|
#include <ft/widgets/gscreen.h>
|
|
|
|
#include <ft/widgets/fbrowser.h>
|
2021-05-18 11:39:33 +02:00
|
|
|
#include <ft/widgets/flist.h>
|
|
|
|
#include <ft/widgets/flog.h>
|
2021-05-14 11:10:03 +02:00
|
|
|
#include <ft/test.h>
|
|
|
|
#include <ft/all-tests.h>
|
|
|
|
|
2021-06-08 10:46:32 +02:00
|
|
|
#include <fxlibc/printf.h>
|
|
|
|
|
2021-05-23 15:56:20 +02:00
|
|
|
#include <gint/hardware.h>
|
|
|
|
#include <bits/cpucap.h>
|
|
|
|
|
2021-06-08 10:46:32 +02:00
|
|
|
/* We don't initialize the test result fields in the ft_list objects below */
|
2021-05-14 11:10:03 +02:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
|
|
|
|
|
|
|
ft_list headers_libc[] = {
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("ctype.h", "<ctype.h>"), (ft_test*[]){
|
2021-05-21 10:13:30 +02:00
|
|
|
&ft_ctype_classes,
|
|
|
|
&ft_ctype_conversion,
|
2021-05-14 11:10:03 +02:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("inttypes.h", "<inttypes.h>"), (ft_test*[]){
|
2021-05-18 22:48:56 +02:00
|
|
|
&ft_inttypes_sizes,
|
|
|
|
&ft_inttypes_functions,
|
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("locale.h", "<locale.h>"), NULL },
|
|
|
|
{ _("setjmp.h", "<setjmp.h>"), (ft_test*[]){
|
2021-05-29 18:55:05 +02:00
|
|
|
&ft_setjmp_simple,
|
|
|
|
&ft_setjmp_massive,
|
2021-05-30 10:44:27 +02:00
|
|
|
&ft_setjmp_interrupt,
|
2021-05-29 18:55:05 +02:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("signal.h", "<signal.h>"), (ft_test*[]){
|
2021-05-30 10:51:52 +02:00
|
|
|
&ft_signal_signal,
|
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("stdio.h", "<stdio.h>"), (ft_test*[]){
|
2021-06-08 10:46:32 +02:00
|
|
|
&ft_stdio_printf_basics,
|
|
|
|
&ft_stdio_printf_formats,
|
|
|
|
&ft_stdio_printf_fp,
|
2022-01-02 21:00:04 +01:00
|
|
|
&ft_stdio_open,
|
2021-06-08 10:46:32 +02:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("stdlib.h", "<stdlib.h>"), (ft_test*[]){
|
2021-05-18 22:48:02 +02:00
|
|
|
&ft_stdlib_arith,
|
2021-05-19 21:45:04 +02:00
|
|
|
&ft_stdlib_sizes,
|
2021-05-20 10:59:19 +02:00
|
|
|
&ft_stdlib_llconv,
|
|
|
|
&ft_stdlib_lconv,
|
2021-05-21 22:48:45 +02:00
|
|
|
&ft_stdlib_fpconv,
|
2021-06-08 11:46:48 +02:00
|
|
|
&ft_stdlib_rand,
|
2021-06-08 10:46:32 +02:00
|
|
|
&ft_stdlib_exit,
|
|
|
|
&ft_stdlib__Exit,
|
|
|
|
&ft_stdlib_abort,
|
2021-05-18 22:48:02 +02:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("string.h", "<string.h>"), (ft_test*[]){
|
2021-05-14 11:10:03 +02:00
|
|
|
&ft_string_memset,
|
|
|
|
&ft_string_memcpy,
|
|
|
|
&ft_string_memmove,
|
2021-05-22 09:09:28 +02:00
|
|
|
&ft_string_memcmp,
|
2021-05-23 13:18:18 +02:00
|
|
|
&ft_string_memchr,
|
2021-05-23 15:56:45 +02:00
|
|
|
&ft_string_strlen,
|
2021-05-23 17:43:14 +02:00
|
|
|
&ft_string_naive,
|
|
|
|
&ft_string_strerror,
|
2021-05-14 11:10:03 +02:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 22:00:40 +01:00
|
|
|
{ _("time.h", "<time.h>"), (ft_test*[]){
|
|
|
|
&ft_time_clock,
|
|
|
|
&ft_time_functions,
|
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ _("uchar.h", "<uchar.h>"), NULL },
|
|
|
|
{ _("wchar.h", "<wchar.h>"), NULL },
|
|
|
|
{ _("wctype.h", "<wctype.h>"), NULL },
|
2021-05-14 11:10:03 +02:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
ft_list headers_posix[] = {
|
2021-12-23 01:20:41 +01:00
|
|
|
{ "<dirent.h>", (ft_test*[]) {
|
|
|
|
&ft_dirent_glob,
|
|
|
|
&ft_dirent_open_folders,
|
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-04 21:20:37 +01:00
|
|
|
{ "<fcntl.h>", (ft_test*[]){
|
|
|
|
&ft_fcntl_open,
|
|
|
|
NULL,
|
|
|
|
}},
|
|
|
|
{ "<unistd.h>", (ft_test*[]){
|
2021-12-23 01:20:41 +01:00
|
|
|
&ft_unistd_path,
|
2021-12-04 21:20:37 +01:00
|
|
|
&ft_unistd_simple_write,
|
|
|
|
&ft_unistd_write_odd,
|
2021-12-13 18:40:19 +01:00
|
|
|
&ft_unistd_simple_read,
|
|
|
|
&ft_unistd_seek_patterns,
|
2021-12-23 01:20:41 +01:00
|
|
|
&ft_unistd_folders,
|
2021-12-04 21:20:37 +01:00
|
|
|
NULL,
|
|
|
|
}},
|
2021-12-30 18:14:33 +01:00
|
|
|
{ "<sys/stat.h>", (ft_test*[]){
|
|
|
|
&ft_sysstat_stat,
|
|
|
|
NULL,
|
|
|
|
}},
|
2021-05-14 11:10:03 +02:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2021-05-23 15:56:20 +02:00
|
|
|
/* Set up the capabilities for the standard library implementation */
|
|
|
|
/* TODO: Set up capabilities directly in gint! */
|
|
|
|
if(isSH4())
|
|
|
|
__cpucap |= __CPUCAP_SH4ALDSP;
|
|
|
|
|
2021-06-08 10:46:32 +02:00
|
|
|
__printf_enable_fp();
|
|
|
|
__printf_enable_fixed();
|
2021-05-21 22:48:45 +02:00
|
|
|
|
2021-05-14 11:10:03 +02:00
|
|
|
// Initialize test results
|
|
|
|
for(int i = 0; headers_libc[i].name; i++)
|
|
|
|
ft_list_init(&headers_libc[i]);
|
|
|
|
for(int i = 0; headers_posix[i].name; i++)
|
|
|
|
ft_list_init(&headers_posix[i]);
|
|
|
|
|
|
|
|
// Create GUI
|
2021-12-04 21:20:37 +01:00
|
|
|
gscreen *scr = gscreen_create2("FxLibc tests", &img_fbar_main,
|
2021-05-14 11:10:03 +02:00
|
|
|
"FxLibc regression and performance tests", "/LIBC;/POSIX;;;;#RUN");
|
|
|
|
fbrowser *browser = fbrowser_create(NULL);
|
|
|
|
int selected_set = 0;
|
|
|
|
|
|
|
|
gscreen_add_tab(scr, browser, NULL);
|
2021-12-04 21:20:37 +01:00
|
|
|
gscreen_set_tab_title_visible(scr, 0, _(false, true));
|
2021-05-14 11:10:03 +02:00
|
|
|
fbrowser_set_headers(browser, headers_libc, false);
|
|
|
|
|
|
|
|
jwidget *results = jwidget_create(NULL);
|
2021-06-08 10:46:32 +02:00
|
|
|
jlayout_set_stack(results);
|
2021-05-14 11:10:03 +02:00
|
|
|
gscreen_add_tab(scr, results, NULL);
|
2021-12-04 21:20:37 +01:00
|
|
|
gscreen_set_tab_title_visible(scr, 1, _(false, true));
|
2021-05-14 11:10:03 +02:00
|
|
|
gscreen_set_tab_fkeys_visible(scr, 1, false);
|
|
|
|
|
2021-05-18 11:39:33 +02:00
|
|
|
flog *testlog = flog_create(NULL);
|
2021-12-04 21:20:37 +01:00
|
|
|
flog_set_line_spacing(testlog, _(1,3));
|
|
|
|
flog_set_font(testlog, _(&font_mini, dfont_default()));
|
2021-05-18 11:39:33 +02:00
|
|
|
gscreen_add_tab(scr, testlog, testlog);
|
2021-12-04 21:20:37 +01:00
|
|
|
gscreen_set_tab_title_visible(scr, 2, _(false, true));
|
2021-05-18 11:39:33 +02:00
|
|
|
gscreen_set_tab_fkeys_visible(scr, 2, false);
|
|
|
|
|
2021-05-14 11:10:03 +02:00
|
|
|
// Event handling
|
|
|
|
while(1) {
|
|
|
|
jevent e = jscene_run(scr->scene);
|
|
|
|
int tab = gscreen_current_tab(scr);
|
|
|
|
|
|
|
|
int key = 0;
|
2021-05-30 10:43:15 +02:00
|
|
|
if(e.type == JWIDGET_KEY && e.key.type == KEYEV_DOWN) key = e.key.key;
|
2021-05-14 11:10:03 +02:00
|
|
|
|
|
|
|
if(e.type == JSCENE_PAINT) {
|
|
|
|
dclear(C_WHITE);
|
|
|
|
jscene_render(scr->scene);
|
|
|
|
dupdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Switch lists on F1/F2
|
|
|
|
if(tab == 0 && key == KEY_F1 && selected_set != 0) {
|
|
|
|
fbrowser_set_headers(browser, headers_libc, false);
|
|
|
|
selected_set = 0;
|
|
|
|
}
|
|
|
|
if(tab == 0 && key == KEY_F2 && selected_set != 1) {
|
|
|
|
fbrowser_set_headers(browser, headers_posix, false);
|
|
|
|
selected_set = 1;
|
|
|
|
}
|
|
|
|
|
2021-05-23 12:30:45 +02:00
|
|
|
// Update F-keys when tests are selected
|
|
|
|
if((e.type == FLIST_SELECTED || e.type == JWIDGET_FOCUS_IN ||
|
|
|
|
e.type == JWIDGET_FOCUS_OUT) && e.source == browser->tests) {
|
|
|
|
|
|
|
|
ft_test *test = NULL;
|
|
|
|
if(jscene_focused_widget(scr->scene) == browser->tests)
|
|
|
|
test = fbrowser_current_test(browser);
|
|
|
|
|
|
|
|
jfkeys_set_override(scr->fkeys, 4,
|
|
|
|
(test && test->run && test->log) ? "@LOG" : NULL);
|
|
|
|
jfkeys_set_override(scr->fkeys, 5,
|
|
|
|
(test && test->run && test->widget) ? "@VISUAL" : NULL);
|
|
|
|
}
|
|
|
|
|
2021-05-14 11:10:03 +02:00
|
|
|
// Run tests
|
|
|
|
if(tab == 0 && key == KEY_F6) {
|
|
|
|
ft_list *header = fbrowser_current_header(browser);
|
|
|
|
ft_test *test = fbrowser_current_test(browser);
|
|
|
|
|
|
|
|
if(test) {
|
|
|
|
ft_test_run(test);
|
|
|
|
ft_list_aggregate(header);
|
|
|
|
browser->widget.update = 1;
|
|
|
|
}
|
|
|
|
else if(header) {
|
|
|
|
ft_list_run(header);
|
|
|
|
browser->widget.update = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(int i = 0; headers_libc[i].name; i++)
|
|
|
|
ft_list_run(&headers_libc[i]);
|
|
|
|
for(int i = 0; headers_posix[i].name; i++)
|
|
|
|
ft_list_run(&headers_posix[i]);
|
|
|
|
browser->widget.update = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Browse test results
|
2021-05-23 12:30:45 +02:00
|
|
|
ft_test *test_visual = NULL;
|
|
|
|
ft_test *test_log = NULL;
|
|
|
|
|
2021-05-14 11:10:03 +02:00
|
|
|
if(tab == 0 && e.type == FBROWSER_VALIDATED && e.source == browser) {
|
|
|
|
ft_test *test = fbrowser_current_test(browser);
|
2021-05-23 12:30:45 +02:00
|
|
|
test_visual = test;
|
|
|
|
test_log = test;
|
|
|
|
}
|
|
|
|
if(key == KEY_F4) {
|
|
|
|
test_log = fbrowser_current_test(browser);
|
|
|
|
}
|
|
|
|
if(key == KEY_F5) {
|
|
|
|
test_visual = fbrowser_current_test(browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(test_visual && test_visual->run && test_visual->widget) {
|
|
|
|
jwidget *w = test_visual->widget(test_visual);
|
|
|
|
if(w) {
|
|
|
|
jwidget_add_child(results, w);
|
|
|
|
gscreen_show_tab(scr, 1);
|
|
|
|
jscene_set_focused_widget(scr->scene, w);
|
2021-05-18 11:39:33 +02:00
|
|
|
}
|
2021-05-14 11:10:03 +02:00
|
|
|
}
|
2021-05-23 12:30:45 +02:00
|
|
|
else if(test_log && test_log->run && test_log->log) {
|
|
|
|
flog_set_log(testlog, test_log->log, test_log->log_size);
|
|
|
|
gscreen_show_tab(scr, 2);
|
|
|
|
}
|
2021-05-14 11:10:03 +02:00
|
|
|
|
|
|
|
// Close test results
|
|
|
|
if(tab == 1 && key == KEY_EXIT) {
|
|
|
|
jscene_set_focused_widget(scr->scene, browser->tests);
|
|
|
|
gscreen_show_tab(scr, 0);
|
|
|
|
while(results->child_count > 0) {
|
|
|
|
jwidget_destroy(results->children[0]);
|
|
|
|
}
|
|
|
|
}
|
2021-05-18 11:39:33 +02:00
|
|
|
if(tab == 2 && key == KEY_EXIT) {
|
|
|
|
flog_set_log(testlog, NULL, -1);
|
|
|
|
gscreen_show_tab(scr, 0);
|
|
|
|
}
|
2021-05-14 11:10:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gscreen_destroy(scr);
|
|
|
|
return 1;
|
|
|
|
}
|