summaryrefslogtreecommitdiff
path: root/qa/qt/qmc_event
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qt/qmc_event')
-rw-r--r--qa/qt/qmc_event/GNUmakefile27
-rw-r--r--qa/qt/qmc_event/GNUmakefile.install18
-rw-r--r--qa/qt/qmc_event/qmc_event.cpp85
-rw-r--r--qa/qt/qmc_event/qmc_event.pro13
4 files changed, 143 insertions, 0 deletions
diff --git a/qa/qt/qmc_event/GNUmakefile b/qa/qt/qmc_event/GNUmakefile
new file mode 100644
index 0000000..b125bca
--- /dev/null
+++ b/qa/qt/qmc_event/GNUmakefile
@@ -0,0 +1,27 @@
+TOPDIR = ../../..
+include $(TOPDIR)/src/include/builddefs
+
+COMMAND = qmc_event
+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_event/GNUmakefile.install b/qa/qt/qmc_event/GNUmakefile.install
new file mode 100644
index 0000000..35c201c
--- /dev/null
+++ b/qa/qt/qmc_event/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_event
+PROJECT = $(COMMAND).pro
+
+default setup install:
+ifeq "$(ENABLE_QT)" "true"
+ $(QTMAKE)
+ $(LNMAKE)
+endif
+
+include $(BUILDRULES)
diff --git a/qa/qt/qmc_event/qmc_event.cpp b/qa/qt/qmc_event/qmc_event.cpp
new file mode 100644
index 0000000..3b32e57
--- /dev/null
+++ b/qa/qt/qmc_event/qmc_event.cpp
@@ -0,0 +1,85 @@
+//
+// Test event tracing functionality in libqmc
+//
+// Caller can setup deterministic output by calling
+// "pmstore sample.event.reset 1" beforehand.
+//
+
+#include <errno.h>
+#include <QTextStream>
+#include <qmc_context.h>
+#include <qmc_group.h>
+#include <qmc_metric.h>
+#include <qmc_indom.h>
+
+QTextStream cerr(stderr);
+QTextStream cout(stdout);
+
+int
+main(int argc, char* argv[])
+{
+ int sts = 0;
+ int c;
+
+ __pmSetProgname(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*/
+ }
+
+ cerr << "*** Create a single fetch group ***" << endl;
+ QmcGroup group;
+ pmflush();
+
+ cerr << endl << "*** Event metric ***" << endl;
+ QmcMetric* sample_records = group.addMetric("sample.event.records");
+ if (sample_records->status() < 0)
+ sts = 1;
+ else
+ sample_records->dump(cerr);
+ pmflush();
+
+ QmcMetric* sample_seconds = group.addMetric("sample.seconds");
+ if (sample_seconds->status() < 0)
+ sts = 1;
+ else
+ sample_seconds->dump(cerr);
+ pmflush();
+
+ //
+ // pmdasample provides a 4-phase fetch pattern for sample.event
+ //
+ for (int i = 0; i < 4; i++) {
+ sleep(1);
+ cerr << endl << "*** Group Fetch " << i << " ***" << endl;
+ group.fetch();
+ sample_records->dump(cerr);
+ sample_seconds->dump(cerr);
+ }
+
+ cerr << endl << "*** Exiting ***" << endl;
+ return sts;
+}
diff --git a/qa/qt/qmc_event/qmc_event.pro b/qa/qt/qmc_event/qmc_event.pro
new file mode 100644
index 0000000..0f3c1e8
--- /dev/null
+++ b/qa/qt/qmc_event/qmc_event.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+LANGUAGE = C++
+SOURCES = qmc_event.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