mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
tests: sysinfo: Run all sysinfo tests all the time
There's no reason why we should avoid running all sysinfo tests on all platforms. Refactor the test to get rid of the conditionally compiled cruft.
This commit is contained in:
parent
c58d95b7a0
commit
2847cb5d9c
@ -42,14 +42,8 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#if defined (__linux__)
|
|
||||||
|
|
||||||
# if defined(__s390__) || defined(__s390x__) || \
|
|
||||||
defined(__powerpc__) || defined(__powerpc64__) || \
|
|
||||||
defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
|
|
||||||
defined(__arm__) || defined(__aarch64__)
|
|
||||||
|
|
||||||
struct testSysinfoData {
|
struct testSysinfoData {
|
||||||
|
virSysinfoDefPtr (*func)(void); /* sysinfo gathering function */
|
||||||
char *decoder; /* name of dmi decoder binary/script */
|
char *decoder; /* name of dmi decoder binary/script */
|
||||||
char *sysinfo; /* name of /proc/sysinfo substitute file */
|
char *sysinfo; /* name of /proc/sysinfo substitute file */
|
||||||
char *cpuinfo; /* name of /proc/cpuinfo substitute file */
|
char *cpuinfo; /* name of /proc/cpuinfo substitute file */
|
||||||
@ -68,7 +62,7 @@ testSysinfo(const void *data)
|
|||||||
virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinfo);
|
virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinfo);
|
||||||
|
|
||||||
if (!testdata->expected ||
|
if (!testdata->expected ||
|
||||||
!(ret = virSysinfoRead()))
|
!(ret = testdata->func()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virSysinfoFormat(&buf, ret) < 0)
|
if (virSysinfoFormat(&buf, ret) < 0)
|
||||||
@ -91,6 +85,7 @@ testSysinfo(const void *data)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
sysinfotest_run(const char *test,
|
sysinfotest_run(const char *test,
|
||||||
|
virSysinfoDefPtr (*func)(void),
|
||||||
const char *decoder,
|
const char *decoder,
|
||||||
const char *sysinfo,
|
const char *sysinfo,
|
||||||
const char *cpuinfo,
|
const char *cpuinfo,
|
||||||
@ -99,6 +94,8 @@ sysinfotest_run(const char *test,
|
|||||||
struct testSysinfoData testdata = { NULL };
|
struct testSysinfoData testdata = { NULL };
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
|
testdata.func = func;
|
||||||
|
|
||||||
if ((decoder &&
|
if ((decoder &&
|
||||||
virAsprintf(&testdata.decoder, "%s/%s", abs_srcdir, decoder) < 0) ||
|
virAsprintf(&testdata.decoder, "%s/%s", abs_srcdir, decoder) < 0) ||
|
||||||
(sysinfo &&
|
(sysinfo &&
|
||||||
@ -122,91 +119,34 @@ sysinfotest_run(const char *test,
|
|||||||
VIR_FREE(testdata.expected);
|
VIR_FREE(testdata.expected);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(__s390__) || defined(__s390x__)
|
#define TEST_FULL(name, func, decoder) \
|
||||||
static int
|
if (sysinfotest_run(name " sysinfo", func, decoder, \
|
||||||
test_s390(void)
|
"/sysinfodata/" name "sysinfo.data", \
|
||||||
{
|
"/sysinfodata/" name "cpuinfo.data", \
|
||||||
return sysinfotest_run("s390 sysinfo",
|
"/sysinfodata/" name "sysinfo.expect") != EXIT_SUCCESS) \
|
||||||
NULL,
|
ret = EXIT_FAILURE
|
||||||
"/sysinfodata/s390sysinfo.data",
|
|
||||||
"/sysinfodata/s390cpuinfo.data",
|
|
||||||
"/sysinfodata/s390sysinfo.expect");
|
|
||||||
}
|
|
||||||
|
|
||||||
VIRT_TEST_MAIN(test_s390)
|
|
||||||
# elif defined(__powerpc__) || defined(__powerpc64__)
|
|
||||||
static int
|
|
||||||
test_ppc(void)
|
|
||||||
{
|
|
||||||
return sysinfotest_run("ppc sysinfo",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
"/sysinfodata/ppccpuinfo.data",
|
|
||||||
"/sysinfodata/ppcsysinfo.expect");
|
|
||||||
}
|
|
||||||
|
|
||||||
VIRT_TEST_MAIN(test_ppc)
|
#define TEST(name, func) \
|
||||||
# elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
|
TEST_FULL(name, func, NULL)
|
||||||
static int
|
|
||||||
test_x86(void)
|
|
||||||
{
|
|
||||||
return sysinfotest_run("x86 sysinfo",
|
|
||||||
"/sysinfodata/dmidecode.sh",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
"/sysinfodata/x86sysinfo.expect");
|
|
||||||
}
|
|
||||||
|
|
||||||
VIRT_TEST_MAIN(test_x86)
|
|
||||||
# elif defined(__arm__)
|
|
||||||
static int
|
static int
|
||||||
test_arm(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
if (sysinfotest_run("arm sysinfo",
|
TEST("s390", virSysinfoReadS390);
|
||||||
NULL,
|
TEST("ppc", virSysinfoReadPPC);
|
||||||
NULL,
|
TEST_FULL("x86", virSysinfoReadX86, "/sysinfodata/dmidecode.sh");
|
||||||
"/sysinfodata/armcpuinfo.data",
|
TEST("arm", virSysinfoReadARM);
|
||||||
"/sysinfodata/armsysinfo.expect") != EXIT_SUCCESS)
|
TEST("arm-rpi2", virSysinfoReadARM);
|
||||||
ret = EXIT_FAILURE;
|
TEST("aarch64", virSysinfoReadARM);
|
||||||
|
|
||||||
if (sysinfotest_run("Raspberry Pi 2 sysinfo",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
"/sysinfodata/arm-rpi2cpuinfo.data",
|
|
||||||
"/sysinfodata/arm-rpi2sysinfo.expect") != EXIT_SUCCESS)
|
|
||||||
ret = EXIT_FAILURE;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRT_TEST_MAIN(test_arm)
|
#undef TEST
|
||||||
# elif defined(__aarch64__)
|
#undef TEST_FULL
|
||||||
static int
|
|
||||||
test_aarch64(void)
|
|
||||||
{
|
|
||||||
return sysinfotest_run("aarch64 sysinfo",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
"/sysinfodata/aarch64cpuinfo.data",
|
|
||||||
"/sysinfodata/aarch64sysinfo.expect");
|
|
||||||
}
|
|
||||||
|
|
||||||
VIRT_TEST_MAIN(test_aarch64)
|
VIRT_TEST_MAIN(mymain)
|
||||||
# else
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
return EXIT_AM_SKIP;
|
|
||||||
}
|
|
||||||
# endif /* defined(__s390__) ... */
|
|
||||||
#else
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
return EXIT_AM_SKIP;
|
|
||||||
}
|
|
||||||
#endif /* defined(__linux__) */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user