diff options
Diffstat (limited to 'qa/qt/qmc_indom')
-rw-r--r-- | qa/qt/qmc_indom/GNUmakefile | 27 | ||||
-rw-r--r-- | qa/qt/qmc_indom/GNUmakefile.install | 18 | ||||
-rw-r--r-- | qa/qt/qmc_indom/qmc_indom.cpp | 133 | ||||
-rw-r--r-- | qa/qt/qmc_indom/qmc_indom.pro | 13 |
4 files changed, 191 insertions, 0 deletions
diff --git a/qa/qt/qmc_indom/GNUmakefile b/qa/qt/qmc_indom/GNUmakefile new file mode 100644 index 0000000..6ac877f --- /dev/null +++ b/qa/qt/qmc_indom/GNUmakefile @@ -0,0 +1,27 @@ +TOPDIR = ../../.. +include $(TOPDIR)/src/include/builddefs + +COMMAND = qmc_indom +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_indom/GNUmakefile.install b/qa/qt/qmc_indom/GNUmakefile.install new file mode 100644 index 0000000..90709fc --- /dev/null +++ b/qa/qt/qmc_indom/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_indom +PROJECT = $(COMMAND).pro + +default setup install: +ifeq "$(ENABLE_QT)" "true" + $(QTMAKE) + $(LNMAKE) +endif + +include $(BUILDRULES) diff --git a/qa/qt/qmc_indom/qmc_indom.cpp b/qa/qt/qmc_indom/qmc_indom.cpp new file mode 100644 index 0000000..6b82913 --- /dev/null +++ b/qa/qt/qmc_indom/qmc_indom.cpp @@ -0,0 +1,133 @@ +// +// Test QmcIndom class +// + +#include <QTextStream> +#include <qmc_context.h> +#include <qmc_source.h> +#include <qmc_desc.h> +#include <qmc_indom.h> + +QTextStream cerr(stderr); +QTextStream cout(stdout); + +int +main(int argc, char* argv[]) +{ + int sts = 0; + int c; + + 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*/ + } + + fprintf(stderr, "*** Lookup an indom ***\n"); + QString source = QString("archives/oview-short"); + QmcSource *src = QmcSource::getSource(PM_CONTEXT_ARCHIVE, source, false); + + if (src->status() < 0) { + pmprintf("%s: Error: Unable to create context to \"%s\": %s\n", + pmProgname, (const char *)source.toAscii(), + pmErrStr(src->status())); + pmflush(); + return 1; + } + + pmID hinv_map_cpu = pmid_build(1, 26, 9); + QmcDesc hinv_map_cpu_pmc(hinv_map_cpu); + + if (hinv_map_cpu_pmc.status() < 0) { + pmprintf("\n%s: Error: hinv.map.cpu: %s\n", + pmProgname, pmErrStr(hinv_map_cpu_pmc.status())); + pmflush(); + return 1; + } + + QmcIndom indom(PM_CONTEXT_ARCHIVE, hinv_map_cpu_pmc); + + if (indom.status() < 0) { + pmprintf("%s: Error: hinv.map.cpu: %s\n", + pmProgname, pmErrStr(indom.status())); + pmflush(); + return 1; + } + + indom.dump(cout); + + if (indom.diffProfile()) { + pmprintf("%s: Error: Profile requires updating but there is nothing in it\n", + pmProgname); + sts = 1; + } + + fprintf(stderr, "\n*** Reference one instance ***\n"); + indom.lookup("cpu:1.3.a"); + + if (!indom.diffProfile()) { + pmprintf("%s: Error: Profile should require updating but flag not set\n", + pmProgname); + sts = 1; + } + + indom.dump(cout); + indom.genProfile(); + + __pmProfile* profile = __pmHandleToPtr(pmWhichContext())->c_instprof; + __pmDumpProfile(stderr, PM_INDOM_NULL, profile); + + if (indom.diffProfile()) { + pmprintf("%s: Error: Profile just generated but flag still set\n", + pmProgname); + sts = 1; + } + + fprintf(stderr, "\n*** Reference all instances ***\n"); + indom.refAll(); + + if (!indom.diffProfile()) { + pmprintf("%s: Error: All instances referenced but profile flag unset\n", + pmProgname); + sts = 1; + } + + indom.dump(cout); + indom.genProfile(); + + profile = __pmHandleToPtr(pmWhichContext())->c_instprof; + __pmDumpProfile(stderr, PM_INDOM_NULL, profile); + + if (indom.diffProfile()) { + pmprintf("%s: Error: Profile just generated but flag still set\n", + pmProgname); + sts = 1; + } + + pmflush(); + return sts; +} diff --git a/qa/qt/qmc_indom/qmc_indom.pro b/qa/qt/qmc_indom/qmc_indom.pro new file mode 100644 index 0000000..bdf8cdb --- /dev/null +++ b/qa/qt/qmc_indom/qmc_indom.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +LANGUAGE = C++ +SOURCES = qmc_indom.cpp +CONFIG += qt warn_on +release:DESTDIR = build/debug +debug:DESTDIR = build/release +INCLUDEPATH += ../../../src/include +INCLUDEPATH += ../../../src/libpcp_qmc/src +LIBS += -L../../../src/libpcp/src +LIBS += -L../../../src/libpcp_qmc/src +LIBS += -L../../../src/libpcp_qmc/src/$$DESTDIR +LIBS += -lpcp_qmc -lpcp +QT -= gui |