2012-04-15 13:45:18 +02:00
|
|
|
/*
|
|
|
|
* QTest testcase for the M48T59 and M48T08 real-time clocks
|
|
|
|
*
|
|
|
|
* Based on MC146818 RTC test:
|
|
|
|
* Copyright IBM, Corp. 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-02-08 19:08:51 +01:00
|
|
|
#include "qemu/osdep.h"
|
2012-04-15 13:45:18 +02:00
|
|
|
|
2014-02-08 11:41:07 +01:00
|
|
|
#include "libqtest.h"
|
|
|
|
|
2012-04-15 13:45:18 +02:00
|
|
|
#define RTC_SECONDS 0x9
|
|
|
|
#define RTC_MINUTES 0xa
|
|
|
|
#define RTC_HOURS 0xb
|
|
|
|
|
|
|
|
#define RTC_DAY_OF_WEEK 0xc
|
|
|
|
#define RTC_DAY_OF_MONTH 0xd
|
|
|
|
#define RTC_MONTH 0xe
|
|
|
|
#define RTC_YEAR 0xf
|
|
|
|
|
|
|
|
static uint32_t base;
|
|
|
|
static uint16_t reg_base = 0x1ff0; /* 0x7f0 for m48t02 */
|
|
|
|
static int base_year;
|
2018-02-12 13:35:41 +01:00
|
|
|
static const char *base_machine;
|
2012-04-15 13:45:18 +02:00
|
|
|
static bool use_mmio;
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static uint8_t cmos_read_mmio(QTestState *s, uint8_t reg)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
2018-02-12 12:59:46 +01:00
|
|
|
return qtest_readb(s, base + (uint32_t)reg_base + (uint32_t)reg);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static void cmos_write_mmio(QTestState *s, uint8_t reg, uint8_t val)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
|
|
|
uint8_t data = val;
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
qtest_writeb(s, base + (uint32_t)reg_base + (uint32_t)reg, data);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static uint8_t cmos_read_ioio(QTestState *s, uint8_t reg)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
2018-02-12 12:59:46 +01:00
|
|
|
qtest_outw(s, base + 0, reg_base + (uint16_t)reg);
|
|
|
|
return qtest_inb(s, base + 3);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static void cmos_write_ioio(QTestState *s, uint8_t reg, uint8_t val)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
2018-02-12 12:59:46 +01:00
|
|
|
qtest_outw(s, base + 0, reg_base + (uint16_t)reg);
|
|
|
|
qtest_outb(s, base + 3, val);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static uint8_t cmos_read(QTestState *s, uint8_t reg)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
|
|
|
if (use_mmio) {
|
2018-02-12 12:59:46 +01:00
|
|
|
return cmos_read_mmio(s, reg);
|
2012-04-15 13:45:18 +02:00
|
|
|
} else {
|
2018-02-12 12:59:46 +01:00
|
|
|
return cmos_read_ioio(s, reg);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static void cmos_write(QTestState *s, uint8_t reg, uint8_t val)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
|
|
|
if (use_mmio) {
|
2018-02-12 12:59:46 +01:00
|
|
|
cmos_write_mmio(s, reg, val);
|
2012-04-15 13:45:18 +02:00
|
|
|
} else {
|
2018-02-12 12:59:46 +01:00
|
|
|
cmos_write_ioio(s, reg, val);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcd2dec(int value)
|
|
|
|
{
|
|
|
|
return (((value >> 4) & 0x0F) * 10) + (value & 0x0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tm_cmp(struct tm *lhs, struct tm *rhs)
|
|
|
|
{
|
|
|
|
time_t a, b;
|
|
|
|
struct tm d1, d2;
|
|
|
|
|
|
|
|
memcpy(&d1, lhs, sizeof(d1));
|
|
|
|
memcpy(&d2, rhs, sizeof(d2));
|
|
|
|
|
|
|
|
a = mktime(&d1);
|
|
|
|
b = mktime(&d2);
|
|
|
|
|
|
|
|
if (a < b) {
|
|
|
|
return -1;
|
|
|
|
} else if (a > b) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void print_tm(struct tm *tm)
|
|
|
|
{
|
|
|
|
printf("%04d-%02d-%02d %02d:%02d:%02d %+02ld\n",
|
|
|
|
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
|
|
|
tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_gmtoff);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
static void cmos_get_date_time(QTestState *s, struct tm *date)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
|
|
|
int sec, min, hour, mday, mon, year;
|
|
|
|
time_t ts;
|
|
|
|
struct tm dummy;
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
sec = cmos_read(s, RTC_SECONDS);
|
|
|
|
min = cmos_read(s, RTC_MINUTES);
|
|
|
|
hour = cmos_read(s, RTC_HOURS);
|
|
|
|
mday = cmos_read(s, RTC_DAY_OF_MONTH);
|
|
|
|
mon = cmos_read(s, RTC_MONTH);
|
|
|
|
year = cmos_read(s, RTC_YEAR);
|
2012-04-15 13:45:18 +02:00
|
|
|
|
|
|
|
sec = bcd2dec(sec);
|
|
|
|
min = bcd2dec(min);
|
|
|
|
hour = bcd2dec(hour);
|
|
|
|
mday = bcd2dec(mday);
|
|
|
|
mon = bcd2dec(mon);
|
|
|
|
year = bcd2dec(year);
|
|
|
|
|
|
|
|
ts = time(NULL);
|
|
|
|
localtime_r(&ts, &dummy);
|
|
|
|
|
|
|
|
date->tm_isdst = dummy.tm_isdst;
|
|
|
|
date->tm_sec = sec;
|
|
|
|
date->tm_min = min;
|
|
|
|
date->tm_hour = hour;
|
|
|
|
date->tm_mday = mday;
|
|
|
|
date->tm_mon = mon - 1;
|
|
|
|
date->tm_year = base_year + year - 1900;
|
2013-01-26 15:27:59 +01:00
|
|
|
#ifndef __sun__
|
2012-04-15 13:45:18 +02:00
|
|
|
date->tm_gmtoff = 0;
|
2013-01-26 15:27:59 +01:00
|
|
|
#endif
|
2012-04-15 13:45:18 +02:00
|
|
|
|
|
|
|
ts = mktime(date);
|
|
|
|
}
|
|
|
|
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
static QTestState *m48t59_qtest_start(void)
|
|
|
|
{
|
2018-08-06 08:53:43 +02:00
|
|
|
return qtest_initf("-M %s -rtc clock=vm", base_machine);
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bcd_check_time(void)
|
2012-04-15 13:45:18 +02:00
|
|
|
{
|
|
|
|
struct tm start, date[4], end;
|
|
|
|
struct tm *datep;
|
|
|
|
time_t ts;
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
const int wiggle = 2;
|
|
|
|
QTestState *s = m48t59_qtest_start();
|
2012-04-15 13:45:18 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This check assumes a few things. First, we cannot guarantee that we get
|
|
|
|
* a consistent reading from the wall clock because we may hit an edge of
|
|
|
|
* the clock while reading. To work around this, we read four clock readings
|
|
|
|
* such that at least two of them should match. We need to assume that one
|
|
|
|
* reading is corrupt so we need four readings to ensure that we have at
|
|
|
|
* least two consecutive identical readings
|
|
|
|
*
|
|
|
|
* It's also possible that we'll cross an edge reading the host clock so
|
|
|
|
* simply check to make sure that the clock reading is within the period of
|
|
|
|
* when we expect it to be.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ts = time(NULL);
|
|
|
|
gmtime_r(&ts, &start);
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
cmos_get_date_time(s, &date[0]);
|
|
|
|
cmos_get_date_time(s, &date[1]);
|
|
|
|
cmos_get_date_time(s, &date[2]);
|
|
|
|
cmos_get_date_time(s, &date[3]);
|
2012-04-15 13:45:18 +02:00
|
|
|
|
|
|
|
ts = time(NULL);
|
|
|
|
gmtime_r(&ts, &end);
|
|
|
|
|
|
|
|
if (tm_cmp(&date[0], &date[1]) == 0) {
|
|
|
|
datep = &date[0];
|
|
|
|
} else if (tm_cmp(&date[1], &date[2]) == 0) {
|
|
|
|
datep = &date[1];
|
|
|
|
} else if (tm_cmp(&date[2], &date[3]) == 0) {
|
|
|
|
datep = &date[2];
|
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(tm_cmp(&start, datep) <= 0 && tm_cmp(datep, &end) <= 0)) {
|
|
|
|
long t, s;
|
|
|
|
|
|
|
|
start.tm_isdst = datep->tm_isdst;
|
|
|
|
|
|
|
|
t = (long)mktime(datep);
|
|
|
|
s = (long)mktime(&start);
|
|
|
|
if (t < s) {
|
2019-03-01 16:10:18 +01:00
|
|
|
g_test_message("RTC is %ld second(s) behind wall-clock", (s - t));
|
2012-04-15 13:45:18 +02:00
|
|
|
} else {
|
2019-03-01 16:10:18 +01:00
|
|
|
g_test_message("RTC is %ld second(s) ahead of wall-clock", (t - s));
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_cmpint(ABS(t - s), <=, wiggle);
|
|
|
|
}
|
|
|
|
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
qtest_quit(s);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* success if no crash or abort */
|
|
|
|
static void fuzz_registers(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
QTestState *s = m48t59_qtest_start();
|
2012-04-15 13:45:18 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 1000; i++) {
|
|
|
|
uint8_t reg, val;
|
|
|
|
|
|
|
|
reg = (uint8_t)g_test_rand_int_range(0, 16);
|
|
|
|
val = (uint8_t)g_test_rand_int_range(0, 256);
|
|
|
|
|
2013-01-04 17:12:18 +01:00
|
|
|
if (reg == 7) {
|
|
|
|
/* watchdog setup register, may trigger system reset, skip */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-02-12 12:59:46 +01:00
|
|
|
cmos_write(s, reg, val);
|
|
|
|
cmos_read(s, reg);
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
|
|
|
|
qtest_quit(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void base_setup(void)
|
|
|
|
{
|
|
|
|
const char *arch = qtest_get_arch();
|
|
|
|
|
|
|
|
if (g_str_equal(arch, "sparc")) {
|
|
|
|
/* Note: For sparc64, we'd need to map-in the PCI bridge memory first */
|
|
|
|
base = 0x71200000;
|
|
|
|
base_year = 1968;
|
2018-02-12 13:35:41 +01:00
|
|
|
base_machine = "SS-5";
|
|
|
|
use_mmio = true;
|
|
|
|
} else if (g_str_equal(arch, "ppc") || g_str_equal(arch, "ppc64")) {
|
|
|
|
base = 0xF0000000;
|
|
|
|
base_year = 1968;
|
|
|
|
base_machine = "ref405ep";
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
use_mmio = true;
|
|
|
|
} else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
base_setup();
|
2012-04-15 13:45:18 +02:00
|
|
|
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
g_test_init(&argc, &argv, NULL);
|
2012-04-15 13:45:18 +02:00
|
|
|
|
tests/m48t59: Fix and re-enable the test for sparc
The m48t59 test has been disabled in commit baeddded5fe6fa37d13fb94bf8d
("sparc: disable qtest in make check"), likely due to some timing issues
in the bcd_check_time tests which might fail if it gets interrupted for
too long. It should be OK to re-enable this test if we make sure that we
do not run it on timing-sensitive machines, thus it should be OK if we only
run it in the g_test_slow() mode.
Additionally, there are two other issues:
First, the test can not run so easily on sparc64 anymore, since commit
f3b18f35a23c60edbda6420cd ("sun4u: switch m48t59 NVRAM to MMIO access")
moved the m48t59 device to the ebus instead, and for this you first
have to set up the corresponding PCI device (which is currently not
possible from within the m48t59 test). So we can only re-enable this
test on sparc, but not the sparc64 target.
Second, the fuzzing test is executed before the bcd-check-time test
(due to the naming of the tests), without having the base address set
up properly, so the fuzzing test does not really check anything at all.
Fix it by setting up the base address from the main function already
and by moving the qtest_start() to the tests themselves, so that each
test starts with a clean environment (since after the fuzzing, the clock
is unusable for the bcd-check-time test).
Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-12 12:13:38 +01:00
|
|
|
if (g_test_slow()) {
|
|
|
|
/* Do not run this in timing-sensitive environments */
|
|
|
|
qtest_add_func("/rtc/bcd-check-time", bcd_check_time);
|
|
|
|
}
|
2012-04-15 13:45:18 +02:00
|
|
|
qtest_add_func("/rtc/fuzz-registers", fuzz_registers);
|
2018-03-23 15:32:02 +01:00
|
|
|
return g_test_run();
|
2012-04-15 13:45:18 +02:00
|
|
|
}
|