On Wed, Jan 22, 2014 at 10:53:45AM +0100, Ján Tomko wrote:
Check if cpu stats are read correctly from a sample
/proc/stat collected from a 24 CPU machine.
---
src/libvirt_linux.syms | 1 +
src/nodeinfo.c | 6 +-
tests/nodeinfodata/linux-cpustat-24cpu.out | 150 ++++++++++++++++++++++++++++
tests/nodeinfodata/linux-cpustat-24cpu.stat | 25 +++++
tests/nodeinfotest.c | 131 ++++++++++++++++++++++++
5 files changed, 312 insertions(+), 1 deletion(-)
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.out
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.stat
diff --git a/src/libvirt_linux.syms b/src/libvirt_linux.syms
index 3500898..b3b2384 100644
--- a/src/libvirt_linux.syms
+++ b/src/libvirt_linux.syms
@@ -3,6 +3,7 @@
#
# nodeinfo.h
+linuxNodeGetCPUStats;
linuxNodeInfoCPUPopulate;
# util/virstatslinux.h
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index cba2fc1..9c236cd 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -193,6 +193,10 @@ freebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params,
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
const char *sysfs_dir,
virNodeInfoPtr nodeinfo);
+int linuxNodeGetCPUStats(FILE *procstat,
+ int cpuNum,
+ virNodeCPUStatsPtr params,
+ int *nparams);
/* Return the positive decimal contents of the given
* DIR/cpu%u/FILE, or -1 on error. If DEFAULT_VALUE is non-negative
@@ -681,7 +685,7 @@ cleanup:
# define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK))
-static int
+int
linuxNodeGetCPUStats(FILE *procstat,
int cpuNum,
virNodeCPUStatsPtr params,
[snip]
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 74f6d4d..6101551 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -31,6 +31,13 @@ extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
char *sysfs_dir,
virNodeInfoPtr nodeinfo);
+extern int
+linuxNodeGetCPUStats(FILE *procstat,
+ int cpuNum,
+ virNodeCPUStatsPtr params,
+ int *nparams);
Ewww.
The preferred way to handle testing of what would otherwise be a
static function is to export it in a 'priv' header, eg nodeinfopriv.h
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|