From 773aa3b86b969169bfca8e20d527ae4704901be4 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 25 Jul 2007 23:16:30 +0000 Subject: [PATCH] Split out generic nodeinfo API --- ChangeLog | 12 ++ docs/apibuild.py | 2 + src/Makefile.am | 1 + src/internal.h | 2 + src/nodeinfo.c | 193 ++++++++++++++++++++ src/nodeinfo.h | 39 ++++ src/openvz_driver.c | 10 +- src/qemu_driver.c | 96 +--------- tests/.cvsignore | 1 + tests/Makefile.am | 10 +- tests/nodeinfodata/linux-nodeinfo-1.cpuinfo | 46 +++++ tests/nodeinfodata/linux-nodeinfo-1.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-1.txt | 1 + tests/nodeinfodata/linux-nodeinfo-2.cpuinfo | 48 +++++ tests/nodeinfodata/linux-nodeinfo-2.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-2.txt | 1 + tests/nodeinfodata/linux-nodeinfo-3.cpuinfo | 99 ++++++++++ tests/nodeinfodata/linux-nodeinfo-3.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-3.txt | 1 + tests/nodeinfodata/linux-nodeinfo-4.cpuinfo | 96 ++++++++++ tests/nodeinfodata/linux-nodeinfo-4.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-4.txt | 1 + tests/nodeinfodata/linux-nodeinfo-5.cpuinfo | 96 ++++++++++ tests/nodeinfodata/linux-nodeinfo-5.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-5.txt | 1 + tests/nodeinfodata/linux-nodeinfo-6.cpuinfo | 96 ++++++++++ tests/nodeinfodata/linux-nodeinfo-6.meminfo | 28 +++ tests/nodeinfodata/linux-nodeinfo-6.txt | 1 + tests/nodeinfotest.c | 117 ++++++++++++ 29 files changed, 1043 insertions(+), 95 deletions(-) create mode 100644 src/nodeinfo.c create mode 100644 src/nodeinfo.h create mode 100644 tests/nodeinfodata/linux-nodeinfo-1.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-1.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-1.txt create mode 100644 tests/nodeinfodata/linux-nodeinfo-2.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-2.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-2.txt create mode 100644 tests/nodeinfodata/linux-nodeinfo-3.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-3.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-3.txt create mode 100644 tests/nodeinfodata/linux-nodeinfo-4.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-4.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-4.txt create mode 100644 tests/nodeinfodata/linux-nodeinfo-5.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-5.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-5.txt create mode 100644 tests/nodeinfodata/linux-nodeinfo-6.cpuinfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-6.meminfo create mode 100644 tests/nodeinfodata/linux-nodeinfo-6.txt create mode 100644 tests/nodeinfotest.c diff --git a/ChangeLog b/ChangeLog index fceba73de7..909b6c9dc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Jul 25 19:13:43 EST 2007 Daniel P. berrange + + * src/nodeinfo.h, src/nodeinfo.c: Generic impl of virNodeGetInfo + * src/qemu_driver.c, src/openvz_driver: Switch to generic impl + of virNodeGetInfo + * src/internal.h: Add STREQLEN STRNEQLEN + * src/Makefile.am: Add nodeinfo.{c,h} + * docs/apibuild.py: Ignore nodeinfo files + * tests/nodeinfotest.c, tests/Makefile.am: Test case for the + nodeinfo.c APIs + * tests/nodeinfodata/*: Data files for the test suite + Tue Jul 24 17:32:23 CEST 2007 Daniel Veillard * libvirt.spec.in NEWS docs/* po/*: preparing release 0.3.1 diff --git a/docs/apibuild.py b/docs/apibuild.py index f86fd3b28a..7d71b063ce 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -63,6 +63,8 @@ ignored_files = { "uuid.c": "internal code", "util.h": "internal code", "util.c": "internal code", + "nodeinfo.h": "internal code", + "nodeinfo.c": "internal code", } ignored_words = { diff --git a/src/Makefile.am b/src/Makefile.am index ff8e86d94e..dbd1cc5551 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,7 @@ CLIENT_SOURCES = \ qemu_conf.c qemu_conf.h \ openvz_conf.c openvz_conf.h \ openvz_driver.c openvz_driver.h \ + nodeinfo.h nodeinfo.c \ util.c util.h SERVER_SOURCES = \ diff --git a/src/internal.h b/src/internal.h index a278596fdb..dd073a2f5f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -36,6 +36,8 @@ extern "C" { #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) #define STRNEQ(a,b) (strcmp((a),(b)) != 0) #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0) +#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) +#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0) /** * ATTRIBUTE_UNUSED: diff --git a/src/nodeinfo.c b/src/nodeinfo.c new file mode 100644 index 0000000000..01d7e28e66 --- /dev/null +++ b/src/nodeinfo.c @@ -0,0 +1,193 @@ +/* + * nodeinfo.c: Helper routines for OS specific node information + * + * Copyright (C) 2006, 2007 Red Hat, Inc. + * Copyright (C) 2006 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Daniel P. Berrange + */ + +#include +#include +#include +#include +#include +#include + +#include "nodeinfo.h" + +#ifdef __linux__ +#define MEMINFO_PATH "/proc/meminfo" +#define CPUINFO_PATH "/proc/cpuinfo" + +/* NB, these are not static as we need to call them from testsuite */ +int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo); +int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, virNodeInfoPtr nodeinfo); + +int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo) { + char line[1024]; + + nodeinfo->cpus = 0; + nodeinfo->mhz = 0; + nodeinfo->nodes = nodeinfo->sockets = nodeinfo->cores = nodeinfo->threads = 1; + + /* NB: It is impossible to fill our nodes, since cpuinfo + * has not knowledge of NUMA nodes */ + + /* XXX hyperthreads */ + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + char *buf = line; + if (STREQLEN(buf, "processor", 9)) { /* aka a single logical CPU */ + buf += 9; + while (*buf && isspace(*buf)) + buf++; + if (*buf != ':') { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "parsing cpuinfo processor"); + return -1; + } + nodeinfo->cpus++; + } else if (STREQLEN(buf, "cpu MHz", 7)) { + buf += 9; + while (*buf && isspace(*buf)) + buf++; + if (*buf != ':' || !buf[1]) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "parsing cpuinfo cpu MHz"); + return -1; + } + nodeinfo->mhz = (unsigned int)strtol(buf+1, NULL, 10); + } else if (STREQLEN(buf, "cpu cores", 9)) { /* aka cores */ + unsigned int id; + buf += 9; + while (*buf && isspace(*buf)) + buf++; + if (*buf != ':' || !buf[1]) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "parsing cpuinfo cpu cores %c", *buf); + return -1; + } + id = (unsigned int)strtol(buf+1, NULL, 10); + if (id > nodeinfo->cores) + nodeinfo->cores = id; + } + } + + if (!nodeinfo->cpus) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "no cpus found"); + return -1; + } + + /* + * Can't reliably count sockets from proc metadata, so + * infer it based on total CPUs vs cores. + * XXX hyperthreads + */ + nodeinfo->sockets = nodeinfo->cpus / nodeinfo->cores; + + return 0; +} + + +int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, virNodeInfoPtr nodeinfo) { + char line[1024]; + + nodeinfo->memory = 0; + + while (fgets(line, sizeof(line), meminfo) != NULL) { + if (STREQLEN(line, "MemTotal:", 9)) { + nodeinfo->memory = (unsigned int)strtol(line + 10, NULL, 10); + } + } + if (!nodeinfo->memory) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "no memory found"); + return -1; + } + + return 0; +} + + +#endif + +int virNodeInfoPopulate(virConnectPtr conn, + virNodeInfoPtr nodeinfo) { + struct utsname info; +#ifdef __linux__ + int ret; + FILE *cpuinfo, *meminfo; +#endif + + if (uname(&info) < 0) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "cannot extract machine type %s", strerror(errno)); + return -1; + } + + strncpy(nodeinfo->model, info.machine, sizeof(nodeinfo->model)-1); + nodeinfo->model[sizeof(nodeinfo->model)-1] = '\0'; + +#ifdef __linux__ + cpuinfo = fopen(CPUINFO_PATH, "r"); + if (!cpuinfo) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "cannot open %s %s", CPUINFO_PATH, strerror(errno)); + return -1; + } + ret = linuxNodeInfoCPUPopulate(conn, cpuinfo, nodeinfo); + fclose(cpuinfo); + if (ret < 0) + return -1; + + meminfo = fopen(MEMINFO_PATH, "r"); + if (!meminfo) { + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "cannot open %s %s", MEMINFO_PATH, strerror(errno)); + return -1; + } + ret = linuxNodeInfoMemPopulate(conn, meminfo, nodeinfo); + fclose(meminfo); + + return ret; +#else + /* XXX Solaris will need an impl later if they port QEMU driver */ + __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + "%s:%s not implemented on this platform\n", __FILE__, __FUNCTION__); + return -1; +#endif +} + + +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/nodeinfo.h b/src/nodeinfo.h new file mode 100644 index 0000000000..d0d0bb29c8 --- /dev/null +++ b/src/nodeinfo.h @@ -0,0 +1,39 @@ +/* + * nodeinfo.c: Helper routines for OS specific node information + * + * Copyright (C) 2006, 2007 Red Hat, Inc. + * Copyright (C) 2006 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Daniel P. Berrange + */ + +#ifndef __VIR_NODEINFO_H__ +#define __VIR_NODEINFO_H__ + +#include "internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + + int virNodeInfoPopulate(virConnectPtr conn, virNodeInfoPtr nodeinfo); + +#ifdef __cplusplus +} +#endif + +#endif /* __VIR_NODEINFO_H__*/ diff --git a/src/openvz_driver.c b/src/openvz_driver.c index e85aa8606f..84d514cb97 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -55,12 +55,14 @@ #include "util.h" #include "openvz_driver.h" #include "openvz_conf.h" +#include "nodeinfo.h" #define openvzLog(level, msg...) fprintf(stderr, msg) static virDomainPtr openvzDomainLookupByID(virConnectPtr conn, int id); static char *openvzGetOSType(virDomainPtr dom); +static int openvzGetNodeInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo); static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid); static virDomainPtr openvzDomainLookupByName(virConnectPtr conn, const char *name); static int openvzDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info); @@ -327,6 +329,12 @@ static const char *openvzGetType(virConnectPtr conn ATTRIBUTE_UNUSED) { } +static int openvzGetNodeInfo(virConnectPtr conn, + virNodeInfoPtr nodeinfo) { + return virNodeInfoPopulate(conn, nodeinfo); +} + + static int openvzListDomains(virConnectPtr conn, int *ids, int nids) { int got = 0; int veid, pid, outfd, errfd; @@ -431,7 +439,7 @@ static virDriver openvzDriver = { NULL, /* hostname */ NULL, /* uri */ NULL, /* getMaxVcpus */ - NULL, /* nodeGetInfo */ + openvzGetNodeInfo, /* nodeGetInfo */ NULL, /* getCapabilities */ openvzListDomains, /* listDomains */ openvzNumDomains, /* numOfDomains */ diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 0e3e658c20..fdbaf66e9a 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -53,6 +53,7 @@ #include "util.h" #include "qemu_driver.h" #include "qemu_conf.h" +#include "nodeinfo.h" static int qemudShutdown(void); @@ -1358,81 +1359,6 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED, } -static int qemudGetMemInfo(unsigned long *memory) { - FILE *meminfo = fopen("/proc/meminfo", "r"); - char line[1024]; - - *memory = 0; - - if (!meminfo) { - return -1; - } - - /* XXX NUMA and hyperthreads ? */ - while (fgets(line, sizeof(line), meminfo) != NULL) { - if (!strncmp(line, "MemTotal:", 9)) { - *memory = (unsigned int)strtol(line + 10, NULL, 10); - } - } - fclose(meminfo); - return 0; -} - -static int qemudGetCPUInfo(unsigned int *cpus, unsigned int *mhz, - unsigned int *nodes, unsigned int *sockets, - unsigned int *cores, unsigned int *threads) { - FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); - char line[1024]; - - *cpus = 0; - *mhz = 0; - *nodes = *sockets = *cores = *threads = 1; - - if (!cpuinfo) { - return -1; - } - - /* XXX NUMA and hyperthreads ? */ - while (fgets(line, sizeof(line), cpuinfo) != NULL) { - if (!strncmp(line, "processor\t", 10)) { /* aka a single logical CPU */ - (*cpus)++; - } else if (!strncmp(line, "cpu MHz\t", 8)) { - char *offset = strchr(line, ':'); - if (!offset) - continue; - offset++; - if (!*offset) - continue; - *mhz = (unsigned int)strtol(offset, NULL, 10); - } else if (!strncmp(line, "physical id\t", 12)) { /* aka socket */ - unsigned int id; - char *offset = strchr(line, ':'); - if (!offset) - continue; - offset++; - if (!*offset) - continue; - id = (unsigned int)strtol(offset, NULL, 10); - if ((id+1) > *sockets) - *sockets = (id + 1); - } else if (!strncmp(line, "cpu cores\t", 9)) { /* aka cores */ - unsigned int id; - char *offset = strchr(line, ':'); - if (!offset) - continue; - offset++; - if (!*offset) - continue; - id = (unsigned int)strtol(offset, NULL, 10); - if (id > *cores) - *cores = id; - } - } - fclose(cpuinfo); - - return 0; -} - static virDrvOpenStatus qemudOpen(virConnectPtr conn, const char *name, int flags ATTRIBUTE_UNUSED) { @@ -1485,23 +1411,9 @@ static int qemudGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, return -1; } -static int qemudGetNodeInfo(virConnectPtr conn ATTRIBUTE_UNUSED, - virNodeInfoPtr node) { - struct utsname info; - - if (uname(&info) < 0) - return -1; - - strncpy(node->model, info.machine, sizeof(node->model)-1); - node->model[sizeof(node->model)-1] = '\0'; - - if (qemudGetMemInfo(&(node->memory)) < 0) - return -1; - - if (qemudGetCPUInfo(&(node->cpus), &(node->mhz), &(node->nodes), - &(node->sockets), &(node->cores), &(node->threads)) < 0) - return -1; - return 0; +static int qemudGetNodeInfo(virConnectPtr conn, + virNodeInfoPtr nodeinfo) { + return virNodeInfoPopulate(conn, nodeinfo); } static char *qemudGetCapabilities(virConnectPtr conn ATTRIBUTE_UNUSED) { diff --git a/tests/.cvsignore b/tests/.cvsignore index a254efafa1..4d29888538 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore @@ -12,6 +12,7 @@ xmconfigtest xencapstest qemuxml2xmltest qemuxml2argvtest +nodeinfotest *.gcda *.gcno diff --git a/tests/Makefile.am b/tests/Makefile.am index 9eb5e8b5a3..d38b86844e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,10 +32,11 @@ LDADDS = \ EXTRA_DIST = xmlrpcserver.py test_conf.sh noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \ - reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest + reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest \ + nodeinfotest TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest \ - xencapstest qemuxml2argvtest qemuxml2xmltest + xencapstest qemuxml2argvtest qemuxml2xmltest nodeinfotest if ENABLE_XEN_TESTS TESTS += reconnect endif @@ -99,6 +100,11 @@ xencapstest_SOURCES = \ xencapstest_LDFLAGS = xencapstest_LDADD = $(LDADDS) +nodeinfotest_SOURCES = \ + nodeinfotest.c testutils.h testutils.c +nodeinfotest_LDFLAGS = +nodeinfotest_LDADD = $(LDADDS) + reconnect_SOURCES = \ reconnect.c reconnect_LDFLAGS = diff --git a/tests/nodeinfodata/linux-nodeinfo-1.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-1.cpuinfo new file mode 100644 index 0000000000..3f11640a62 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-1.cpuinfo @@ -0,0 +1,46 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 15 +model : 4 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 8 +cpu MHz : 2800.000 +cache size : 2048 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr lahf_lm +bogomips : 5590.67 +clflush size : 64 +cache_alignment : 128 +address sizes : 36 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 15 +model : 4 +model name : Intel(R) Xeon(TM) CPU 2.80GHz +stepping : 8 +cpu MHz : 2800.000 +cache size : 2048 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr lahf_lm +bogomips : 5586.49 +clflush size : 64 +cache_alignment : 128 +address sizes : 36 bits physical, 48 bits virtual +power management: + diff --git a/tests/nodeinfodata/linux-nodeinfo-1.meminfo b/tests/nodeinfodata/linux-nodeinfo-1.meminfo new file mode 100644 index 0000000000..dd5565ecf3 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-1.meminfo @@ -0,0 +1,28 @@ +MemTotal: 2053960 kB +MemFree: 157792 kB +Buffers: 209440 kB +Cached: 660788 kB +SwapCached: 76 kB +Active: 1416036 kB +Inactive: 178872 kB +SwapTotal: 2064376 kB +SwapFree: 2063940 kB +Dirty: 1736 kB +Writeback: 0 kB +AnonPages: 723984 kB +Mapped: 105208 kB +Slab: 225000 kB +SReclaimable: 172568 kB +SUnreclaim: 52432 kB +PageTables: 40224 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 3091356 kB +Committed_AS: 1270588 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 30640 kB +VmallocChunk: 34359705907 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-1.txt b/tests/nodeinfodata/linux-nodeinfo-1.txt new file mode 100644 index 0000000000..1a38ad1822 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-1.txt @@ -0,0 +1 @@ +CPUs: 2, MHz: 2800, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1, Memory: 2053960 diff --git a/tests/nodeinfodata/linux-nodeinfo-2.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-2.cpuinfo new file mode 100644 index 0000000000..8f524b62b2 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-2.cpuinfo @@ -0,0 +1,48 @@ +processor : 0 +vendor_id : AuthenticAMD +cpu family : 15 +model : 75 +model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ +stepping : 2 +cpu MHz : 2211.364 +cache size : 512 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 4424.80 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 1 +vendor_id : AuthenticAMD +cpu family : 15 +model : 75 +model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ +stepping : 2 +cpu MHz : 2211.364 +cache size : 512 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 4422.14 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + diff --git a/tests/nodeinfodata/linux-nodeinfo-2.meminfo b/tests/nodeinfodata/linux-nodeinfo-2.meminfo new file mode 100644 index 0000000000..e1d9b86547 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-2.meminfo @@ -0,0 +1,28 @@ +MemTotal: 4059540 kB +MemFree: 3525008 kB +Buffers: 24480 kB +Cached: 282300 kB +SwapCached: 0 kB +Active: 230980 kB +Inactive: 243276 kB +SwapTotal: 2031608 kB +SwapFree: 2031608 kB +Dirty: 200 kB +Writeback: 0 kB +AnonPages: 167376 kB +Mapped: 31204 kB +Slab: 34904 kB +SReclaimable: 15544 kB +SUnreclaim: 19360 kB +PageTables: 7704 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 4061376 kB +Committed_AS: 265176 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 1736 kB +VmallocChunk: 34359736147 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-2.txt b/tests/nodeinfodata/linux-nodeinfo-2.txt new file mode 100644 index 0000000000..1c31a0c82c --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-2.txt @@ -0,0 +1 @@ +CPUs: 2, MHz: 2211, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1, Memory: 4059540 diff --git a/tests/nodeinfodata/linux-nodeinfo-3.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-3.cpuinfo new file mode 100644 index 0000000000..94e3c016a1 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-3.cpuinfo @@ -0,0 +1,99 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 15 +model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz +stepping : 6 +cpu MHz : 1595.925 +cache size : 4096 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 10 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov +pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc +pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm +bogomips : 3193.88 +clflush size : 64 +cache_alignment : 64 +address sizes : 36 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 15 +model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz +stepping : 6 +cpu MHz : 1595.925 +cache size : 4096 KB +physical id : 3 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 10 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov +pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc +pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm +bogomips : 3191.89 +clflush size : 64 +cache_alignment : 64 +address sizes : 36 bits physical, 48 bits virtual +power management: + +processor : 2 +vendor_id : GenuineIntel +cpu family : 6 +model : 15 +model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz +stepping : 6 +cpu MHz : 1595.925 +cache size : 4096 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 10 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov +pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc +pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm +bogomips : 3191.88 +clflush size : 64 +cache_alignment : 64 +address sizes : 36 bits physical, 48 bits virtual +power management: + +processor : 3 +vendor_id : GenuineIntel +cpu family : 6 +model : 15 +model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz +stepping : 6 +cpu MHz : 1595.925 +cache size : 4096 KB +physical id : 3 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 10 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov +pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall lm constant_tsc +pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm +bogomips : 3191.87 +clflush size : 64 +cache_alignment : 64 +address sizes : 36 bits physical, 48 bits virtual +power management: diff --git a/tests/nodeinfodata/linux-nodeinfo-3.meminfo b/tests/nodeinfodata/linux-nodeinfo-3.meminfo new file mode 100644 index 0000000000..6bb8f64626 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-3.meminfo @@ -0,0 +1,28 @@ +MemTotal: 4059272 kB +MemFree: 3532828 kB +Buffers: 16644 kB +Cached: 286152 kB +SwapCached: 0 kB +Active: 252032 kB +Inactive: 220148 kB +SwapTotal: 2031608 kB +SwapFree: 2031608 kB +Dirty: 76 kB +Writeback: 0 kB +AnonPages: 169548 kB +Mapped: 25456 kB +Slab: 27260 kB +SReclaimable: 9512 kB +SUnreclaim: 17748 kB +PageTables: 7552 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 4061244 kB +Committed_AS: 278572 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 2044 kB +VmallocChunk: 34359736107 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-3.txt b/tests/nodeinfodata/linux-nodeinfo-3.txt new file mode 100644 index 0000000000..e2cc841172 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-3.txt @@ -0,0 +1 @@ +CPUs: 4, MHz: 1595, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 diff --git a/tests/nodeinfodata/linux-nodeinfo-4.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-4.cpuinfo new file mode 100644 index 0000000000..4686f03d33 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-4.cpuinfo @@ -0,0 +1,96 @@ +processor : 0 +vendor_id : AuthenticAMD +cpu family : 16 +model : 2 +model name : AMD Processor model unknown +stepping : 0 +cpu MHz : 1000.000 +cache size : 512 KB +physical id : 0 +siblings : 4 +core id : 0 +cpu cores : 4 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw +bogomips : 4131.46 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 48 bits physical, 48 bits virtual +power management: ts ttp tm stc 100mhzsteps hwpstate [8] + +processor : 1 +vendor_id : AuthenticAMD +cpu family : 16 +model : 2 +model name : AMD Processor model unknown +stepping : 0 +cpu MHz : 1000.000 +cache size : 512 KB +physical id : 0 +siblings : 4 +core id : 1 +cpu cores : 4 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw +bogomips : 3200.13 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 48 bits physical, 48 bits virtual +power management: ts ttp tm stc 100mhzsteps hwpstate [8] + +processor : 2 +vendor_id : AuthenticAMD +cpu family : 16 +model : 2 +model name : AMD Processor model unknown +stepping : 0 +cpu MHz : 1000.000 +cache size : 512 KB +physical id : 0 +siblings : 4 +core id : 2 +cpu cores : 4 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw +bogomips : 3200.14 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 48 bits physical, 48 bits virtual +power management: ts ttp tm stc 100mhzsteps hwpstate [8] + +processor : 3 +vendor_id : AuthenticAMD +cpu family : 16 +model : 2 +model name : AMD Processor model unknown +stepping : 0 +cpu MHz : 1000.000 +cache size : 512 KB +physical id : 0 +siblings : 4 +core id : 3 +cpu cores : 4 +fpu : yes +fpu_exception : yes +cpuid level : 5 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw +bogomips : 3200.01 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 48 bits physical, 48 bits virtual +power management: ts ttp tm stc 100mhzsteps hwpstate [8] + diff --git a/tests/nodeinfodata/linux-nodeinfo-4.meminfo b/tests/nodeinfodata/linux-nodeinfo-4.meminfo new file mode 100644 index 0000000000..6bb8f64626 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-4.meminfo @@ -0,0 +1,28 @@ +MemTotal: 4059272 kB +MemFree: 3532828 kB +Buffers: 16644 kB +Cached: 286152 kB +SwapCached: 0 kB +Active: 252032 kB +Inactive: 220148 kB +SwapTotal: 2031608 kB +SwapFree: 2031608 kB +Dirty: 76 kB +Writeback: 0 kB +AnonPages: 169548 kB +Mapped: 25456 kB +Slab: 27260 kB +SReclaimable: 9512 kB +SUnreclaim: 17748 kB +PageTables: 7552 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 4061244 kB +Committed_AS: 278572 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 2044 kB +VmallocChunk: 34359736107 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-4.txt b/tests/nodeinfodata/linux-nodeinfo-4.txt new file mode 100644 index 0000000000..2c75ea3552 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-4.txt @@ -0,0 +1 @@ +CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 1, Cores: 4, Threads: 1, Memory: 4059272 diff --git a/tests/nodeinfodata/linux-nodeinfo-5.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-5.cpuinfo new file mode 100644 index 0000000000..b52ae8ac64 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-5.cpuinfo @@ -0,0 +1,96 @@ +processor : 0 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2220 +stepping : 3 +cpu MHz : 2814.921 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 5633.58 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 1 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2220 +stepping : 3 +cpu MHz : 2814.921 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 5629.01 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 2 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2220 +stepping : 3 +cpu MHz : 2814.921 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 5628.94 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 3 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2220 +stepping : 3 +cpu MHz : 2814.921 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy +bogomips : 5628.86 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + diff --git a/tests/nodeinfodata/linux-nodeinfo-5.meminfo b/tests/nodeinfodata/linux-nodeinfo-5.meminfo new file mode 100644 index 0000000000..6bb8f64626 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-5.meminfo @@ -0,0 +1,28 @@ +MemTotal: 4059272 kB +MemFree: 3532828 kB +Buffers: 16644 kB +Cached: 286152 kB +SwapCached: 0 kB +Active: 252032 kB +Inactive: 220148 kB +SwapTotal: 2031608 kB +SwapFree: 2031608 kB +Dirty: 76 kB +Writeback: 0 kB +AnonPages: 169548 kB +Mapped: 25456 kB +Slab: 27260 kB +SReclaimable: 9512 kB +SUnreclaim: 17748 kB +PageTables: 7552 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 4061244 kB +Committed_AS: 278572 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 2044 kB +VmallocChunk: 34359736107 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-5.txt b/tests/nodeinfodata/linux-nodeinfo-5.txt new file mode 100644 index 0000000000..01fee523ac --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-5.txt @@ -0,0 +1 @@ +CPUs: 4, MHz: 2814, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 diff --git a/tests/nodeinfodata/linux-nodeinfo-6.cpuinfo b/tests/nodeinfodata/linux-nodeinfo-6.cpuinfo new file mode 100644 index 0000000000..7b5625e334 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-6.cpuinfo @@ -0,0 +1,96 @@ +processor : 0 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2218 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy +bogomips : 1999.99 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 1 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2218 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 0 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy +bogomips : 1999.99 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 2 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2218 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy +bogomips : 1999.99 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + +processor : 3 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2218 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 1 +cpu cores : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy +bogomips : 1999.99 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc + diff --git a/tests/nodeinfodata/linux-nodeinfo-6.meminfo b/tests/nodeinfodata/linux-nodeinfo-6.meminfo new file mode 100644 index 0000000000..6bb8f64626 --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-6.meminfo @@ -0,0 +1,28 @@ +MemTotal: 4059272 kB +MemFree: 3532828 kB +Buffers: 16644 kB +Cached: 286152 kB +SwapCached: 0 kB +Active: 252032 kB +Inactive: 220148 kB +SwapTotal: 2031608 kB +SwapFree: 2031608 kB +Dirty: 76 kB +Writeback: 0 kB +AnonPages: 169548 kB +Mapped: 25456 kB +Slab: 27260 kB +SReclaimable: 9512 kB +SUnreclaim: 17748 kB +PageTables: 7552 kB +NFS_Unstable: 0 kB +Bounce: 0 kB +CommitLimit: 4061244 kB +Committed_AS: 278572 kB +VmallocTotal: 34359738367 kB +VmallocUsed: 2044 kB +VmallocChunk: 34359736107 kB +HugePages_Total: 0 +HugePages_Free: 0 +HugePages_Rsvd: 0 +Hugepagesize: 2048 kB diff --git a/tests/nodeinfodata/linux-nodeinfo-6.txt b/tests/nodeinfodata/linux-nodeinfo-6.txt new file mode 100644 index 0000000000..a7a2cfe5cf --- /dev/null +++ b/tests/nodeinfodata/linux-nodeinfo-6.txt @@ -0,0 +1 @@ +CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c new file mode 100644 index 0000000000..604f5a4f65 --- /dev/null +++ b/tests/nodeinfotest.c @@ -0,0 +1,117 @@ +#include +#include + +#include "config.h" + +#include + +#include "testutils.h" +#include "internal.h" +#include "nodeinfo.h" + +static char *progname; + +#define MAX_FILE 4096 + +#ifdef __linux__ + +extern int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo); +extern int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, virNodeInfoPtr nodeinfo); + +static int linuxTestCompareFiles(const char *cpuinfofile, const char *meminfofile, const char *outputfile) { + char actualData[MAX_FILE]; + char expectData[MAX_FILE]; + char *expect = &expectData[0]; + virNodeInfo nodeinfo; + FILE *cpuinfo, *meminfo; + + if (virtTestLoadFile(outputfile, &expect, MAX_FILE) < 0) + return -1; + + cpuinfo = fopen(cpuinfofile, "r"); + if (!cpuinfo) + return -1; + if (linuxNodeInfoCPUPopulate(NULL, cpuinfo, &nodeinfo) < 0) { + fclose(cpuinfo); + return -1; + } + fclose(cpuinfo); + + meminfo = fopen(meminfofile, "r"); + if (!meminfo) + return -1; + if (linuxNodeInfoMemPopulate(NULL, meminfo, &nodeinfo) < 0) { + fclose(meminfo); + return -1; + } + fclose(meminfo); + + snprintf(actualData, MAX_FILE, + "CPUs: %u, MHz: %u, Nodes: %u, Sockets: %u, Cores: %u, Threads: %u, Memory: %lu\n", + nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets, + nodeinfo.cores, nodeinfo.threads, nodeinfo.memory); + + if (STRNEQ(actualData, expectData)) { + if (getenv("DEBUG_TESTS")) { + printf("Expect %d '%s'\n", (int)strlen(expectData), expectData); + printf("Actual %d '%s'\n", (int)strlen(actualData), actualData); + } + return -1; + } + + return 0; +} + + +static int linuxTestNodeInfo(const void *data) { + char cpuinfo[PATH_MAX]; + char meminfo[PATH_MAX]; + char output[PATH_MAX]; + snprintf(cpuinfo, PATH_MAX, "nodeinfodata/linux-%s.cpuinfo", (const char*)data); + snprintf(meminfo, PATH_MAX, "nodeinfodata/linux-%s.meminfo", (const char*)data); + snprintf(output, PATH_MAX, "nodeinfodata/linux-%s.txt", (const char*)data); + return linuxTestCompareFiles(cpuinfo, meminfo, output); +} +#endif + + +int +main(int argc, char **argv) +{ + int ret = 0; +#ifdef __linux__ + int i; + const char *nodeData[] = { + "nodeinfo-1", + "nodeinfo-2", + "nodeinfo-3", + "nodeinfo-4", + "nodeinfo-5", + "nodeinfo-6", + }; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + exit(EXIT_FAILURE); + } + + virInitialize(); + + for (i = 0 ; i < (sizeof(nodeData)/sizeof(nodeData[0])) ; i++) + if (virtTestRun(nodeData[i], 1, linuxTestNodeInfo, nodeData[i]) != 0) + ret = -1; +#endif + + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ -- GitLab