]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: avoid spurious failure of nodeinfotest
authorEric Blake <eblake@redhat.com>
Wed, 15 Dec 2010 20:49:00 +0000 (13:49 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 20 Dec 2010 17:31:40 +0000 (10:31 -0700)
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
tests/nodeinfotest.c

index acd3188472ab5cda6209987b85e8ee76f84035b4..22d53e53beeb3169162d7bdba5c37cb9600f32c3 100644 (file)
@@ -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;
index f56247b8541b81cdc2702caeca63f951bd97db5d..c690403503db2f00ff3440148214e2de74f0a4d7 100644 (file)
@@ -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)