summaryrefslogtreecommitdiff
path: root/qa/qt/qmc_source
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2014-10-26 12:33:50 +0400
committerIgor Pashev <pashev.igor@gmail.com>2014-10-26 12:33:50 +0400
commit47e6e7c84f008a53061e661f31ae96629bc694ef (patch)
tree648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/qt/qmc_source
downloadpcp-debian/3.9.10.tar.gz
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/qt/qmc_source')
-rw-r--r--qa/qt/qmc_source/GNUmakefile27
-rw-r--r--qa/qt/qmc_source/GNUmakefile.install18
-rw-r--r--qa/qt/qmc_source/qmc_source.cpp126
-rw-r--r--qa/qt/qmc_source/qmc_source.pro13
4 files changed, 184 insertions, 0 deletions
diff --git a/qa/qt/qmc_source/GNUmakefile b/qa/qt/qmc_source/GNUmakefile
new file mode 100644
index 0000000..f6f1023
--- /dev/null
+++ b/qa/qt/qmc_source/GNUmakefile
@@ -0,0 +1,27 @@
+TOPDIR = ../../..
+include $(TOPDIR)/src/include/builddefs
+
+COMMAND = qmc_source
+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_source/GNUmakefile.install b/qa/qt/qmc_source/GNUmakefile.install
new file mode 100644
index 0000000..13b7a03
--- /dev/null
+++ b/qa/qt/qmc_source/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_source
+PROJECT = $(COMMAND).pro
+
+default setup install:
+ifeq "$(ENABLE_QT)" "true"
+ $(QTMAKE)
+ $(LNMAKE)
+endif
+
+include $(BUILDRULES)
diff --git a/qa/qt/qmc_source/qmc_source.cpp b/qa/qt/qmc_source/qmc_source.cpp
new file mode 100644
index 0000000..ea753f7
--- /dev/null
+++ b/qa/qt/qmc_source/qmc_source.cpp
@@ -0,0 +1,126 @@
+//
+// Test QmcSource class
+//
+
+#include <QTextStream>
+#include <qmc_source.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';
+
+ fprintf(stderr,"*** Create an archive context ***\n");
+ source = "archives/oview-short";
+ QmcSource* src1 = QmcSource::getSource(PM_CONTEXT_ARCHIVE, source, false);
+
+ if (src1->status() < 0) {
+ pmprintf("%s: Error: Unable to create context to \"oview-short\": %s\n",
+ pmProgname, pmErrStr(src1->status()));
+ pmflush();
+ sts = 1;
+ }
+
+ fprintf(stderr,"\n*** Create an archive context using the host name ***\n");
+ source = QString("snort");
+ QmcSource* src2 = QmcSource::getSource(PM_CONTEXT_HOST, source, true);
+
+ if (src2->status() < 0) {
+ pmprintf("%s: Error: Unable to create context to \"%s\": %s\n",
+ pmProgname, (const char *)source.toAscii(),
+ pmErrStr(src2->status()));
+ pmflush();
+ sts = 1;
+ }
+
+ if (src1 != src2) {
+ pmprintf("%s: Error: Matching host to an archive failed: src1 = %s, src2 = %s\n",
+ pmProgname, (const char *)src1->desc().toAscii(),
+ (const char *)src2->desc().toAscii());
+ pmflush();
+ QmcSource::dumpList(cerr);
+ sts = 1;
+ }
+
+ fprintf(stderr,"\n*** Create two live contexts to the local host ***\n");
+ source = buf;
+ QmcSource* src3 = QmcSource::getSource(PM_CONTEXT_HOST, source);
+ QmcSource* src4 = QmcSource::getSource(PM_CONTEXT_HOST, source);
+
+ if (src3->status() < 0) {
+ pmprintf("%s: Error: Unable to create context to \"%s\": %s\n",
+ pmProgname, buf, pmErrStr(src3->status()));
+ pmflush();
+ }
+
+ if (src4->status() < 0) {
+ pmprintf("%s: Error: Unable to create context to \"%s\": %s\n",
+ pmProgname, buf, pmErrStr(src4->status()));
+ pmflush();
+ }
+
+ if (src3 != src4) {
+ pmprintf("%s: Error: Identical host test failed: src3 = %s, src4 = %s\n",
+ pmProgname, (const char *)src3->desc().toAscii(),
+ (const char *)src4->desc().toAscii());
+ pmflush();
+ QmcSource::dumpList(cerr);
+ sts = 1;
+ }
+
+ fprintf(stderr,"\n*** Create a local context ***\n");
+ source = QString::null;
+ QmcSource* src5 = QmcSource::getSource(PM_CONTEXT_LOCAL, source);
+
+ if (src5->status() < 0) {
+ pmprintf("%s: Error: Unable to create context to localhost: %s\n",
+ pmProgname, pmErrStr(src5->status()));
+ pmflush();
+ sts = 1;
+ }
+
+ fprintf(stderr,"\n*** List all known sources ***\n");
+ QmcSource::dumpList(cout);
+
+ pmflush();
+ return sts;
+}
diff --git a/qa/qt/qmc_source/qmc_source.pro b/qa/qt/qmc_source/qmc_source.pro
new file mode 100644
index 0000000..e0ed9f8
--- /dev/null
+++ b/qa/qt/qmc_source/qmc_source.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+LANGUAGE = C++
+SOURCES = qmc_source.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