diff --git a/ChangeLog b/ChangeLog index 63e63f9ad..6cbf04a70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-12-15 Vladimir Serbinenko + + New functional test for sleep function. + + This test allows to check sleep without qemu. Keep qemu version as + well as functional test won't notice if all clocks are going too fast + or too slow. + 2013-12-15 Vladimir Serbinenko Add explicit sysv_abi on amd64 asm routines. diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a550032a3..4102e73ba 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1932,6 +1932,11 @@ module = { common = tests/signatures.h; }; +module = { + name = sleep_test; + common = tests/sleep_test.c; +}; + module = { name = xnu_uuid_test; common = tests/xnu_uuid_test.c; diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index b99cb5f68..5be7a58e5 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -64,6 +64,7 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)), grub_dl_load ("xnu_uuid_test"); grub_dl_load ("pbkdf2_test"); grub_dl_load ("signature_test"); + grub_dl_load ("sleep_test"); FOR_LIST_ELEMENTS (test, grub_test_list) ok = !grub_test_run (test) && ok; diff --git a/grub-core/tests/sleep_test.c b/grub-core/tests/sleep_test.c new file mode 100644 index 000000000..98ea57262 --- /dev/null +++ b/grub-core/tests/sleep_test.c @@ -0,0 +1,45 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static void +sleep_test (void) +{ + struct grub_datetime st, en; + grub_int32_t stu, enu; + grub_test_assert (!grub_get_datetime (&st), "Couldn't retrieve start time"); + grub_millisleep (10000); + grub_test_assert (!grub_get_datetime (&en), "Couldn't retrieve end time"); + grub_test_assert (grub_datetime2unixtime (&st, &stu), "Invalid date"); + grub_test_assert (grub_datetime2unixtime (&en, &enu), "Invalid date"); + grub_test_assert (enu - stu >= 9 && enu - stu <= 11, "Interval out of range: %d", enu-stu); + +} + +GRUB_FUNCTIONAL_TEST (sleep_test, sleep_test);