[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv2 5/7] 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 aa2f6f96dd.

Fix things by allowing an early exit for the testsuite.

* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Add parameter.
(nodeGetInfo): Adjust caller.
* tests/nodeinfotest.c (linuxTestCompareFiles): Likewise.
---
 src/nodeinfo.c       |   11 ++++++++---
 tests/nodeinfotest.c |    5 +++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index acd3188..22d53e5 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -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;
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index f56247b..c690403 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -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)
-- 
1.7.3.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]