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.
This commit is contained in:
Vladimir Serbinenko 2013-12-15 17:57:58 +01:00
parent 39711101fd
commit 04b0285701
4 changed files with 59 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2013-12-15 Vladimir Serbinenko <phcoder@gmail.com>
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 <phcoder@gmail.com>
Add explicit sysv_abi on amd64 asm routines.

View file

@ -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;

View file

@ -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;

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/command.h>
#include <grub/env.h>
#include <grub/test.h>
#include <grub/mm.h>
#include <grub/datetime.h>
#include <grub/time.h>
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);