diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/qt/qmc_desc | |
download | pcp-debian.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/qt/qmc_desc')
-rw-r--r-- | qa/qt/qmc_desc/GNUmakefile | 27 | ||||
-rw-r--r-- | qa/qt/qmc_desc/GNUmakefile.install | 18 | ||||
-rw-r--r-- | qa/qt/qmc_desc/qmc_desc.cpp | 102 | ||||
-rw-r--r-- | qa/qt/qmc_desc/qmc_desc.pro | 13 |
4 files changed, 160 insertions, 0 deletions
diff --git a/qa/qt/qmc_desc/GNUmakefile b/qa/qt/qmc_desc/GNUmakefile new file mode 100644 index 0000000..f535da2 --- /dev/null +++ b/qa/qt/qmc_desc/GNUmakefile @@ -0,0 +1,27 @@ +TOPDIR = ../../.. +include $(TOPDIR)/src/include/builddefs + +COMMAND = qmc_desc +PROJECT = $(COMMAND).pro +SOURCES = $(COMMAND).cpp +TESTDIR = $(PCP_VAR_DIR)/testsuite/qt/$(COMMAND) + +LSRCFILES = $(PROJECT) $(SOURCES) +LDIRDIRT = build $(COMMAND).xcodeproj +LDIRT = $(COMMAND) *.o Makefile + +default default_pcp: +ifeq "$(ENABLE_QT)" "true" + $(QTMAKE) + $(LNMAKE) +endif + +install install_pcp: default + $(INSTALL) -m 755 -d $(TESTDIR) + $(INSTALL) -m 644 GNUmakefile.install $(TESTDIR)/GNUmakefile + $(INSTALL) -m 644 $(PROJECT) $(SOURCES) $(TESTDIR) +ifeq "$(ENABLE_QT)" "true" + $(INSTALL) -m 755 $(BINARY) $(TESTDIR)/$(COMMAND) +endif + +include $(BUILDRULES) diff --git a/qa/qt/qmc_desc/GNUmakefile.install b/qa/qt/qmc_desc/GNUmakefile.install new file mode 100644 index 0000000..42a3c92 --- /dev/null +++ b/qa/qt/qmc_desc/GNUmakefile.install @@ -0,0 +1,18 @@ +ifdef PCP_CONF +include $(PCP_CONF) +else +include $(PCP_DIR)/etc/pcp.conf +endif +PATH = $(shell . $(PCP_DIR)/etc/pcp.env; echo $$PATH) +include $(PCP_INC_DIR)/builddefs + +COMMAND = qmc_desc +PROJECT = $(COMMAND).pro + +default setup install: +ifeq "$(ENABLE_QT)" "true" + $(QTMAKE) + $(LNMAKE) +endif + +include $(BUILDRULES) diff --git a/qa/qt/qmc_desc/qmc_desc.cpp b/qa/qt/qmc_desc/qmc_desc.cpp new file mode 100644 index 0000000..fcce0b4 --- /dev/null +++ b/qa/qt/qmc_desc/qmc_desc.cpp @@ -0,0 +1,102 @@ +// +// Test QmcDesc class +// + +#include <QTextStream> +#include <qmc_source.h> +#include <qmc_desc.h> + +QTextStream cerr(stderr); +QTextStream cout(stdout); + +int +main(int argc, char* argv[]) +{ + int sts = 0; + int c; + char buf[MAXHOSTNAMELEN]; + QString source; + + pmProgname = basename(argv[0]); + + while ((c = getopt(argc, argv, "D:?")) != EOF) { + switch (c) { + case 'D': + sts = __pmParseDebug(optarg); + if (sts < 0) { + pmprintf("%s: unrecognized debug flag specification (%s)\n", + pmProgname, optarg); + sts = 1; + } + else { + pmDebug |= sts; + sts = 0; + } + break; + case '?': + default: + sts = 1; + break; + } + } + + if (sts) { + pmprintf("Usage: %s\n", pmProgname); + pmflush(); + exit(1); + /*NOTREACHED*/ + } + + (void)gethostname(buf, MAXHOSTNAMELEN); + buf[MAXHOSTNAMELEN-1] = '\0'; + source = buf; + + fprintf(stderr,"*** Compare metric descriptor with pminfo output ***\n"); + QmcSource *src = QmcSource::getSource(PM_CONTEXT_HOST, source, false); + + if (src->status() < 0) { + pmprintf("%s: Error: Unable to create context to \"%s\": %s\n", + pmProgname, buf, pmErrStr(src->status())); + pmflush(); + return 1; + } + + /* Linux hinv.ncpu PMID: 60.0.32 */ + pmID hinv_ncpu = pmid_build(60, 0, 32); + QmcDesc hinv_ncpu_pmc(hinv_ncpu); + pmDesc hinv_ncpu_desc = hinv_ncpu_pmc.desc(); + + if (hinv_ncpu_pmc.status() < 0) { + pmprintf("\n%s: Error: hinv.ncpu: %s\n", + pmProgname, pmErrStr(hinv_ncpu_pmc.status())); + pmflush(); + sts = 1; + } + + printf("hinv.ncpu\n"); + __pmPrintDesc(stdout, &hinv_ncpu_desc); + fflush(stdout); + fflush(stderr); + if (system("pminfo -d hinv.ncpu") < 0) { + pmprintf("%s: Error: Unable to run pminfo\n", pmProgname); + pmflush(); + sts = 1; + } + fflush(stdout); + fflush(stderr); + + fprintf(stderr, "\n*** Fetch a bad descriptor ***\n"); + pmID bad = pmid_build(42,42,42); + QmcDesc bad_pmc(bad); + + if (bad_pmc.status() < 0) { + pmprintf("%s: Error: Bogus metric: %s\n", + pmProgname, pmErrStr(bad_pmc.status())); + pmflush(); + } + else + sts = 1; + + return sts; +} + diff --git a/qa/qt/qmc_desc/qmc_desc.pro b/qa/qt/qmc_desc/qmc_desc.pro new file mode 100644 index 0000000..5d1e68d --- /dev/null +++ b/qa/qt/qmc_desc/qmc_desc.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +LANGUAGE = C++ +SOURCES = qmc_desc.cpp +CONFIG += qt warn_on +INCLUDEPATH += ../../../src/include +INCLUDEPATH += ../../../src/libpcp_qmc/src +release:DESTDIR = build/debug +debug:DESTDIR = build/release +LIBS += -L../../../src/libpcp/src +LIBS += -L../../../src/libpcp_qmc/src +LIBS += -L../../../src/libpcp_qmc/src/$$DESTDIR +LIBS += -lpcp_qmc -lpcp +QT -= gui |