[libvirt] [PATCH 3/4] nodeinfotest: Print error if cpuinfo file can't be opened

Michal Privoznik mprivozn at redhat.com
Tue Jun 17 12:48:35 UTC 2014


Currently, we are opening the cpuinfo file via fopen() which if fails
doesn't print any error message. We should do that instead.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tests/nodeinfotest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index f0b8196..650a674 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -39,8 +39,11 @@ linuxTestCompareFiles(const char *cpuinfofile,
         goto fail;
 
     cpuinfo = fopen(cpuinfofile, "r");
-    if (!cpuinfo)
+    if (!cpuinfo) {
+        fprintf(stderr, "unable to open: %s : %s\n",
+                cpuinfofile, strerror(errno));
         goto fail;
+    }
 
     memset(&nodeinfo, 0, sizeof(nodeinfo));
     if (linuxNodeInfoCPUPopulate(cpuinfo, sysfs_dir, arch, &nodeinfo) < 0) {
-- 
1.8.5.5




More information about the libvir-list mailing list