提交 bb11c553 编写于 作者: E Eric Blake

tests: avoid spurious failure of nodeinfotest

When running 'make check' under a multi-cpu Dom0 xen machine,
nodeinfotest had a spurious failure it was reading from
/sys/devices/system/cpu, but xen has no notion of topology.  The test
was intended to be isolated from reading any real system files; the
regression was introduced in Mar 2010 with commit aa2f6f96.

Fix things by allowing an early exit for the testsuite.

* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Add parameter.
(nodeGetInfo): Adjust caller.
* tests/nodeinfotest.c (linuxTestCompareFiles): Likewise.
上级 630fe36f
......@@ -61,7 +61,8 @@
/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
virNodeInfoPtr nodeinfo);
virNodeInfoPtr nodeinfo,
bool need_hyperthreads);
/* Return the positive decimal contents of the given
* CPU_SYS_PATH/cpu%u/FILE, or -1 on error. If MISSING_OK and the
......@@ -167,7 +168,8 @@ static int parse_socket(unsigned int cpu)
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
virNodeInfoPtr nodeinfo)
virNodeInfoPtr nodeinfo,
bool need_hyperthreads)
{
char line[1024];
DIR *cpudir = NULL;
......@@ -244,6 +246,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
return -1;
}
if (!need_hyperthreads)
return 0;
/* OK, we've parsed what we can out of /proc/cpuinfo. Get the socket
* and thread information from /sys
*/
......@@ -338,7 +343,7 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
_("cannot open %s"), CPUINFO_PATH);
return -1;
}
ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo);
ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo, true);
VIR_FORCE_FCLOSE(cpuinfo);
if (ret < 0)
return -1;
......
......@@ -26,7 +26,8 @@ static char *abs_srcdir;
# define MAX_FILE 4096
extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo);
extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo,
bool need_hyperthreads);
static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) {
char actualData[MAX_FILE];
......@@ -43,7 +44,7 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
return -1;
memset(&nodeinfo, 0, sizeof(nodeinfo));
if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) {
if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo, false) < 0) {
if (virTestGetDebug()) {
virErrorPtr error = virSaveLastError();
if (error && error->code != VIR_ERR_OK)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册