added functional tests to make-check
This commit is contained in:
parent
6fc804ffbb
commit
169b1cd2d8
7 changed files with 41 additions and 41 deletions
19
Makefile.in
19
Makefile.in
|
@ -141,7 +141,6 @@ PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES)
|
|||
SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS) \
|
||||
$(lib_SCRIPTS)
|
||||
INFOS = $(info_INFOS)
|
||||
TESTS = $(check_UNITTESTS) $(check_FUNCTIONALTESTS) $(check_SCRIPTEDTESTS)
|
||||
|
||||
CLEANFILES =
|
||||
MOSTLYCLEANFILES =
|
||||
|
@ -461,19 +460,27 @@ distcheck: dist
|
|||
@echo "$(distdir).tar.gz is ready for distribution" | \
|
||||
sed 'h;s/./=/g;p;x;p;x'
|
||||
|
||||
$(TESTS): $(check_SCRIPTS) $(check_MODULES) $(check_PROGRAMS)
|
||||
TESTS = $(check_UTILITIES) $(check_SCRIPTS) $(check_MODULES)
|
||||
$(TESTS): $(test_framework_SCRIPTS) $(test_framework_MODULES)
|
||||
|
||||
check: all $(TESTS)
|
||||
@list="$(check_UNITTESTS) $(check_SCRIPTEDTESTS)"; \
|
||||
@list="$(check_UTILITIES)"; \
|
||||
for file in $$list; do \
|
||||
$(builddir)/$$file; \
|
||||
done
|
||||
@list="$(check_SCRIPTS)"; \
|
||||
for file in $$list; do \
|
||||
echo "$$file:"; \
|
||||
if $(builddir)/$$file; then \
|
||||
echo "$$file: PASS"; \
|
||||
else \
|
||||
echo "$$file: FAIL"; \
|
||||
fi; \
|
||||
done
|
||||
@list="$(check_FUNCTIONALTESTS)"; \
|
||||
for test in $$list; do \
|
||||
echo "insmod functional_test; insmod $test; functional_test" \
|
||||
@list="$(check_MODULES)"; \
|
||||
for file in $$list; do \
|
||||
mod=`basename $$file .mod`; \
|
||||
echo "insmod functional_test; insmod $$mod; functional_test" \
|
||||
| $(builddir)/grub-shell; \
|
||||
done
|
||||
|
||||
|
|
|
@ -4,38 +4,38 @@
|
|||
grub-shell: tests/util/grub-shell.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
check_SCRIPTS += grub-shell
|
||||
test_framework_SCRIPTS += grub-shell
|
||||
CLEANFILES += grub-shell
|
||||
|
||||
# For grub-shell-tester
|
||||
grub-shell-tester: tests/util/grub-shell-tester.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
check_SCRIPTS += grub-shell-tester
|
||||
test_framework_SCRIPTS += grub-shell-tester
|
||||
CLEANFILES += grub-shell-tester
|
||||
|
||||
check_MODULES += functional_test.mod
|
||||
test_framework_MODULES += functional_test.mod
|
||||
functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c
|
||||
functional_test_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# Unit tests
|
||||
|
||||
check_UNITTESTS += example_unit_test
|
||||
check_UTILITIES += example_unit_test
|
||||
example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c
|
||||
example_unit_test_CFLAGS = -Wno-format
|
||||
|
||||
# Functional tests
|
||||
|
||||
check_FUNCTIONALTESTS += example_functional_test.mod
|
||||
check_MODULES += example_functional_test.mod
|
||||
example_functional_test_mod_SOURCES = tests/example_functional_test.c
|
||||
example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS)
|
||||
example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# Scripted tests
|
||||
|
||||
check_SCRIPTEDTESTS += example_scripted_test
|
||||
check_SCRIPTS += example_scripted_test
|
||||
example_scripted_test_SOURCES = tests/example_scripted_test.in
|
||||
|
||||
check_SCRIPTEDTESTS += example_grub_script_test
|
||||
check_SCRIPTS += example_grub_script_test
|
||||
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
||||
|
|
6
genmk.rb
6
genmk.rb
|
@ -407,12 +407,12 @@ while l = gets
|
|||
Image.new(prefix, img)
|
||||
end
|
||||
|
||||
when 'MODULES', 'FUNCTIONALTESTS'
|
||||
when 'MODULES'
|
||||
pmodules += args.split(/\s+/).collect do |pmod|
|
||||
PModule.new(prefix, pmod)
|
||||
end
|
||||
|
||||
when 'UTILITIES', 'UNITTESTS'
|
||||
when 'UTILITIES'
|
||||
utils += args.split(/\s+/).collect do |util|
|
||||
Utility.new(prefix, util)
|
||||
end
|
||||
|
@ -422,7 +422,7 @@ while l = gets
|
|||
Program.new(prefix, prog)
|
||||
end
|
||||
|
||||
when 'SCRIPTS', 'SCRIPTEDTESTS'
|
||||
when 'SCRIPTS'
|
||||
scripts += args.split(/\s+/).collect do |script|
|
||||
Script.new(prefix, script)
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ void EXPORT_FUNC (grub_test_register) (const char *name, void (*test) (void));
|
|||
void EXPORT_FUNC (grub_test_unregister) (const char *name);
|
||||
|
||||
/* Execute a test and print results. */
|
||||
int grub_test_run (const char *name);
|
||||
int grub_test_run (grub_test_t test);
|
||||
|
||||
/* Test `cond' for nonzero; log failure otherwise. */
|
||||
void grub_test_nonzero (int cond, const char *file,
|
||||
|
|
|
@ -45,19 +45,16 @@ grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)),
|
|||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
grub_test_t test;
|
||||
auto int run_test (grub_test_t test);
|
||||
int run_test (grub_test_t test)
|
||||
{
|
||||
grub_test_run (test);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = 0;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list),
|
||||
args[i]);
|
||||
status = grub_test_run (test->name) ? : status;
|
||||
}
|
||||
|
||||
return status;
|
||||
grub_list_iterate (GRUB_AS_LIST (grub_test_list),
|
||||
(grub_list_hook_t) run_test);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
|
|
@ -117,10 +117,8 @@ grub_test_unregister (const char *name)
|
|||
}
|
||||
|
||||
int
|
||||
grub_test_run (const char *name)
|
||||
grub_test_run (grub_test_t test)
|
||||
{
|
||||
grub_test_t test;
|
||||
|
||||
auto int print_failure (grub_test_failure_t item);
|
||||
int print_failure (grub_test_failure_t item)
|
||||
{
|
||||
|
@ -133,18 +131,16 @@ grub_test_run (const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list), name);
|
||||
if (!test)
|
||||
return GRUB_ERR_FILE_NOT_FOUND;
|
||||
|
||||
test->main ();
|
||||
|
||||
if (!failure_list)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
grub_test_printf ("%s:\n", test->name);
|
||||
grub_list_iterate (GRUB_AS_LIST (failure_list),
|
||||
(grub_list_hook_t) print_failure);
|
||||
if (!failure_list)
|
||||
grub_test_printf ("%s: PASS\n", test->name);
|
||||
else
|
||||
grub_test_printf ("%s: FAIL\n", test->name);
|
||||
|
||||
free_failures ();
|
||||
return GRUB_ERR_TEST_FAILURE;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ main (int argc __attribute__ ((unused)),
|
|||
auto int run_test (grub_test_t test);
|
||||
int run_test (grub_test_t test)
|
||||
{
|
||||
status = grub_test_run (test->name) ? : status;
|
||||
status = grub_test_run (test) ? : status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue