summaryrefslogtreecommitdiff
path: root/qa/qt/qmc_hosts
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_hosts
downloadpcp-debian.tar.gz
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/qt/qmc_hosts')
-rw-r--r--qa/qt/qmc_hosts/GNUmakefile27
-rw-r--r--qa/qt/qmc_hosts/GNUmakefile.install18
-rw-r--r--qa/qt/qmc_hosts/qmc_hosts.cpp115
-rw-r--r--qa/qt/qmc_hosts/qmc_hosts.pro13
4 files changed, 173 insertions, 0 deletions
diff --git a/qa/qt/qmc_hosts/GNUmakefile b/qa/qt/qmc_hosts/GNUmakefile
new file mode 100644
index 0000000..22150a8
--- /dev/null
+++ b/qa/qt/qmc_hosts/GNUmakefile
@@ -0,0 +1,27 @@
+TOPDIR = ../../..
+include $(TOPDIR)/src/include/builddefs
+
+COMMAND = qmc_hosts
+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_hosts/GNUmakefile.install b/qa/qt/qmc_hosts/GNUmakefile.install
new file mode 100644
index 0000000..5a0f3f6
--- /dev/null
+++ b/qa/qt/qmc_hosts/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_hosts
+PROJECT = $(COMMAND).pro
+
+default setup install:
+ifeq "$(ENABLE_QT)" "true"
+ $(QTMAKE)
+ $(LNMAKE)
+endif
+
+include $(BUILDRULES)
diff --git a/qa/qt/qmc_hosts/qmc_hosts.cpp b/qa/qt/qmc_hosts/qmc_hosts.cpp
new file mode 100644
index 0000000..c1d8939
--- /dev/null
+++ b/qa/qt/qmc_hosts/qmc_hosts.cpp
@@ -0,0 +1,115 @@
+//
+// Test host matching algorithm with multiple groups
+//
+
+#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);
+
+#define mesg(str) msg(__LINE__, str)
+
+void
+msg(int line, char const* str)
+{
+ static int count = 1;
+
+ cerr << endl << "*** " << count << ": Line " << line << " - " << str
+ << " ***" << endl;
+ count++;
+}
+
+void
+quit(int err)
+{
+ pmflush();
+ cerr << "Error: " << pmErrStr(err) << endl;
+ exit(1);
+}
+
+int
+main(int argc, char* argv[])
+{
+ int sts = 0;
+ int c;
+ 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*/
+ }
+
+ mesg("Create two groups");
+ QmcGroup group1;
+ pmflush();
+ QmcGroup group2;
+ pmflush();
+
+ mesg("Create an archive context in both groups, but to different hosts");
+ source = "archives/oview-short";
+ sts = group1.use(PM_CONTEXT_ARCHIVE, source);
+
+ if (sts < 0)
+ quit(sts);
+
+ source = "archives/rattle";
+ sts = group2.use(PM_CONTEXT_ARCHIVE, source);
+
+ if (sts < 0)
+ quit(sts);
+
+ mesg("Try to create a host context to snort in group1");
+
+ // Should pass as it will get mapped to the archive
+ source = "snort";
+ sts = group1.use(PM_CONTEXT_HOST, source);
+
+ if (sts < 0)
+ quit(sts);
+
+ mesg("Try to create a host context to snort in group2");
+
+ // Should fail, this group has not seen an archive context for host snort
+ source = "snort";
+ sts = group2.use(PM_CONTEXT_HOST, source);
+
+ if (sts >= 0) {
+ mesg("Test failed: duplicate context created from another group");
+ pmflush();
+ exit(1);
+ }
+
+ pmflush();
+ return 0;
+}
+
diff --git a/qa/qt/qmc_hosts/qmc_hosts.pro b/qa/qt/qmc_hosts/qmc_hosts.pro
new file mode 100644
index 0000000..52634c6
--- /dev/null
+++ b/qa/qt/qmc_hosts/qmc_hosts.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+LANGUAGE = C++
+SOURCES = qmc_hosts.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