/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* VasEBoot 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.
*
* VasEBoot 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 VasEBoot. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
VasEBoot_MOD_LICENSE ("GPLv3+");
static void
sleep_test (void)
{
struct VasEBoot_datetime st, en;
VasEBoot_int32_t stu = 0, enu = 0;
int is_delayok;
VasEBoot_test_assert (!VasEBoot_get_datetime (&st), "Couldn't retrieve start time");
VasEBoot_millisleep (10000);
VasEBoot_test_assert (!VasEBoot_get_datetime (&en), "Couldn't retrieve end time");
VasEBoot_test_assert (VasEBoot_datetime2unixtime (&st, &stu), "Invalid date");
VasEBoot_test_assert (VasEBoot_datetime2unixtime (&en, &enu), "Invalid date");
is_delayok = (enu - stu >= 9 && enu - stu <= 11);
#ifdef __arm__
/* Ignore QEMU bug */
if (enu - stu >= 15 && enu - stu <= 17)
is_delayok = 1;
#endif
VasEBoot_test_assert (is_delayok, "Interval out of range: %d", enu-stu);
}
VasEBoot_FUNCTIONAL_TEST (sleep_test, sleep_test);