[PATCH] Perform host domain lookup in t_dnssrv.c
by Antoine van Gelder
Perform host domain lookup in t_dnssrv.c
Added gethostdomain()
Modified test to use gethostdomain() for domain lookup
Modified test to do SRV lookup for _matahari._tcp as per Bug# 688199
Signed-off-by: Antoine van Gelder <antoine(a)7degrees.co.za>
---
src/tests/t_dnssrv.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/src/tests/t_dnssrv.c b/src/tests/t_dnssrv.c
index 91b2772..855a6f3 100644
--- a/src/tests/t_dnssrv.c
+++ b/src/tests/t_dnssrv.c
@@ -16,22 +16,70 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <sys/utsname.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdio.h>
#include <glib.h>
#include "dnssrv_private.h"
+
+int
+gethostdomain(char* domain, size_t domainlen)
+{
+ struct utsname sysinfo;
+ struct addrinfo hints, *res, *p;
+ int error;
+ char* offset;
+
+ if (uname(&sysinfo) != 0) {
+ return -1;
+ }
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
+ if ((error = getaddrinfo(sysinfo.nodename, NULL, &hints, &res)) != 0) {
+ printf("warning: %s", gai_strerror(error));
+ goto fail;
+ }
+
+ /* strip host from fqdn */
+ if ((offset = strchr(res->ai_canonname, '.')) == NULL) {
+ goto fail;
+ }
+ strncpy(domain, ++offset, domainlen);
+ freeaddrinfo(res);
+
+ return 0;
+
+fail:
+ freeaddrinfo(res);
+ return -1;
+}
+
+
int main(int argc, char **argv)
{
struct srv_reply **srvl = NULL, *srv = NULL;
int i;
- if (srvl = srv_lookup("qpid-broker", "tcp", "qpid-broker:49000")) {
+ char hostdomain[MAX_NAME_LEN];
+ if (gethostdomain(hostdomain, sizeof hostdomain) != 0) {
+ perror("Could not determine host domain");
+ return 0;
+ }
+
+ if (srvl = srv_lookup("matahari", "tcp", hostdomain)) {
srv = *srvl;
for (i = 1; srvl[i]; i++) {
if (srvl[i]->prio < srv->prio)
srv = srvl[i];
}
- fprintf("\tAccessible QPID Broker: %s\n", srv->name);
+ printf("\tAccessible QPID Broker: %s\n", srv->name);
return 0;
}
return -1;
--
1.7.5.2
12 years, 8 months
[PATCH] Misc fixes for dnssrv_linux.c compilation
by Antoine van Gelder
Compilation of dnssrv_linux.c was failing.
Fixed typos
Reformatted according to coding guidelines
Added conditional compilation for resolver includes
Include string.h for memcpy
Signed-off-by: Antoine van Gelder <antoine(a)7degrees.co.za>
---
src/lib/dnssrv_linux.c | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/lib/dnssrv_linux.c b/src/lib/dnssrv_linux.c
index c1e11d8..ee18848 100644
--- a/src/lib/dnssrv_linux.c
+++ b/src/lib/dnssrv_linux.c
@@ -17,15 +17,18 @@
*/
#include <netinet/in.h>
+#include <string.h>
+#include <glib.h>
+
+#ifdef HAVE_RESOLV_A
#include <arpa/nameser.h>
#include <resolv.h>
-#include <glib.h>
+#endif
#include "dnssrv_private.h"
-struct srv_reply **srv_lookup(char *service,
- char *protocol,
- char *domain)
+struct srv_reply **
+srv_lookup(char *service, char *protocol, char *domain)
{
struct srv_reply **replies = NULL;
#ifdef HAVE_RESOLV_A
@@ -35,39 +38,39 @@ struct srv_reply **srv_lookup(char *service,
const unsigned char *buf;
ns_msg nsh;
ns_rr rr;
- int, i, n, len, size;
+ int i, n, len, size;
g_snprintf(name, sizeof(name), "_%s._%s.%s", service, protocol, domain);
- if((size = res_query(name, C_IN, T_SRV, querybuf, sizeof(querybuf))) < 0) {
+ if ((size = res_query(name, C_IN, T_SRV, querybuf, sizeof(querybuf))) < 0) {
return NULL;
}
- if(ns_initparse(querybuf, size, &nsh) != 0) {
- reutnr NULL;
+ if (ns_initparse(querybuf, size, &nsh) != 0) {
+ return NULL;
}
n = 0;
- while(ns_parserr(&nsh, ns_s_an, n, &rr) == 0) {
+ while (ns_parserr(&nsh, ns_s_an, n, &rr) == 0) {
size = ns_rr_rdlen(rr);
buf = ns_rr_rdata(rr);
len = 0;
- for(i=6; i < size && buf[i]; i+= buf[i] + 1) {
+ for (i = 6; i < size && buf[i]; i+= buf[i] + 1) {
len += buf[i] + 1;
}
- if(i > size) {
+ if (i > size) {
break;
}
reply = g_malloc(sizeof(struct srv_reply) + len);
memcpy(reply->name, buf+7, len);
- for(i=buf[6]; i < len && buf[7+i]; i += buf[7+i] + 1) {
+ for (i = buf[6]; i < len && buf[7 + i]; i += buf[7 + i] + 1) {
reply->name[i] = '.';
}
- if(i > len) {
+ if (i > len) {
g_free(reply);
break;
}
@@ -77,9 +80,9 @@ struct srv_reply **srv_lookup(char *service,
reply->port = (buf[4] << 8) | buf[5];
n++;
replies = g_renew(struct srv_reply *, replies, n+1);
- replies[n-1] = reply;
+ replies[n - 1] = reply;
}
- if(replies) {
+ if (replies) {
replies[n] = NULL;
}
#endif
@@ -89,11 +92,11 @@ struct srv_reply **srv_lookup(char *service,
void srv_free(struct srv_reply **srv)
{
int i;
- if(srv == NULL) {
+ if (srv == NULL) {
return;
}
- for(i = 0; srv[i]; i++) {
+ for (i = 0; srv[i]; i++) {
g_free(srv[i]);
}
g_free(srv);
--
1.7.5.2
12 years, 10 months
[PATCH 1/3] Introduction to cxxtest
by Adam Stokes
From: Adam Stokes <astokes(a)fedoraproject.org>
- Using core c api's for unittesting with cxxtest
---
src/CMakeLists.txt | 8 +++++
src/tests/CMakeLists.txt | 3 ++
src/tests/mh_api_network.h | 56 +++++++++++++++++++++++++++++++++++
src/tests/mh_api_network_unittest.h | 47 +++++++++++++++++++++++++++++
4 files changed, 114 insertions(+), 0 deletions(-)
create mode 100644 src/tests/CMakeLists.txt
create mode 100644 src/tests/mh_api_network.h
create mode 100644 src/tests/mh_api_network_unittest.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4636ee2..8c9736c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,13 @@
#set(CMAKE_VERBOSE_MAKEFILE ON)
+find_package(CxxTest)
+if(CXXTEST_FOUND)
+ include_directories(${CXXTEST_INCLUDE_DIR})
+ ENABLE_TESTING()
+ CXXTEST_ADD_TEST(mh_api_network_unittest mh_api_network_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/mh_api_network.h)
+ target_link_libraries(mh_api_network_unittest mh_api_network_unittest)
+endif(CXXTEST_FOUND)
+
if(WIN32)
set(VARIANT "windows")
set(SUPPORT_TRACING 0)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
new file mode 100644
index 0000000..21bc609
--- /dev/null
+++ b/src/tests/CMakeLists.txt
@@ -0,0 +1,3 @@
+file(GLOB SRCS "*.cpp")
+file(GLOB HEADERS "*.h")
+#install(FILES ${SRCS} ${HEADERS} DESTINATION share/matahari/tests)
diff --git a/src/tests/mh_api_network.h b/src/tests/mh_api_network.h
new file mode 100644
index 0000000..30b9888
--- /dev/null
+++ b/src/tests/mh_api_network.h
@@ -0,0 +1,56 @@
+#ifndef __MH_API_NETWORK_UNITTEST_H
+#define __MH_API_NETWORK_UNITTEST_H
+#include <iostream>
+#include <string>
+#include <utility>
+#include <vector>
+#include <cstdlib>
+#include <cstdio>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <cxxtest/TestSuite.h>
+
+extern "C" {
+#include "matahari/network.h"
+#include "matahari/host.h"
+#include <sigar.h>
+#include <sigar_format.h>
+#include <glib.h>
+};
+
+using namespace std;
+
+class MhApiNetworkSuite : public CxxTest::TestSuite
+{
+ public:
+ GList *plist;
+ GList *interface_list;
+ sigar_net_interface_config_t *ifconfig;
+ vector<char*> iface_names;
+
+ void setUp (void)
+ {
+ interface_list = mh_network_get_interfaces();
+ for (plist = g_list_first(interface_list); plist;
+ plist = g_list_next(plist)) {
+ ifconfig = (sigar_net_interface_config_t *)plist->data;
+ iface_names.push_back(ifconfig->name);
+ }
+ }
+
+ void tearDown (void)
+ {
+ g_list_free(interface_list);
+ }
+
+ void testListNetworkDevices(void)
+ {
+ unsigned int i;
+
+ for(i=0; i<iface_names.size(); i++) {
+ TS_ASSERT(iface_names[i]);
+ }
+ }
+};
+
+#endif
diff --git a/src/tests/mh_api_network_unittest.h b/src/tests/mh_api_network_unittest.h
new file mode 100644
index 0000000..9e69462
--- /dev/null
+++ b/src/tests/mh_api_network_unittest.h
@@ -0,0 +1,47 @@
+#ifndef __MH_API_NETWORK_UNITTEST_H
+#define __MH_API_NETWORK_UNITTEST_H
+#include <iostream>
+#include <string>
+#include <utility>
+#include <vector>
+#include <cstdlib>
+#include <cstdio>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <cxxtest/TestSuite.h>
+
+extern "C" {
+#include "matahari/network.h"
+#include "matahari/host.h"
+#include <sigar.h>
+#include <sigar_format.h>
+#include <glib.h>
+};
+
+using namespace std;
+
+class MhApiNetworkSuite : public CxxTest::TestSuite
+{
+ public:
+ void setUp (void)
+ {
+ // will be setup
+ }
+
+ void tearDown (void)
+ {
+ // teardown
+
+ }
+
+ void testListNetworkDevices(void)
+ {
+ GList *plist = NULL;
+ GList *interface_list = NULL;
+
+ interface_list = mh_network_get_interfaces();
+ TS_ASSERT (!interface_list.empty());
+ }
+};
+
+#endif
--
1.7.4.4
12 years, 11 months
Build error with qmf-gen
by Antoine van Gelder
Hiya,
I've written up some notes of my experience building matahari from source on F14/15.
I also describe one way to work around the missing patch in the distribution-provided qpid packages.
- antoine
--
# Matahari development environment notes
## Install Dependencies
You'll need the following for the `make linux.build` target:
yum install cmake sigar-devel pcre-devel dbus-devel \
dbus-glib-devel polkit-devel libxslt
You'll need these for the `make windows.build` target:
yum install mingw32-gcc-c++ mingw32-boost mingw32-libxslt \
mingw32-gnutls mingw32-filesystem mingw32-glib2 \
mingw32-pcre mingw32-sigar
If you want to use mock to build matahari RPM's you'll also want:
yum install mock
## Build Patched RPM's for qpid-cpp
The version of `qpid` shipping with Fedora 14 & 15 is missing a patch
that adds v2.0 API support to the `qmf-gen` tool. To build matahari
you will first need to install a newer version of the qpid-cpp-*
packages.
> See: https://fedorahosted.org/pipermail/matahari/2011-March/000662.html
This short guide will walk you through the process of building updated
packages and creating a local repo that can also be used by the `make
PROFILE=... mock` build target.
Download source RPM from:
http://kojipkgs.fedoraproject.org/packages/qpid-cpp/0.8/8.fc16/src/
Build RPM's:
rpmbuild --rebuild qpid-cpp-0.8-8.fc16.src.rpm
Create local repo:
createrepo ~/rpmbuild/RPMS
Add repo to yum, edit: `/etc/yum.repos.d/matahari-qpid.repo`
[matahari-qpid]
name=matahari-qpid
baseurl=file:///home/<user>/rpmbuild/RPMS
enabled=1
gpgcheck=0
Disable distribution-provided matahari & qpid, edit: `/etc/yum.repos.d/fedora.repo`
[fedora]
name=Fedora $releasever - $basearch
.
.
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
exclude=qmf-* python-qmf* mingw32-matahari* matahari* ruby-qmf* mingw32-qpid-* qpid-* python-qpid*
You can now install the patched qpid using yum:
yum install qpid-qmf qpid-cpp-client-devel qpid-qmf-devel \
qpid-cpp-server qpid-cpp-server-ssl qpid-cpp-client \
qpid-cpp-client-ssl qpid-tools python-qpid-qmf
## Compile sources
Compile for Linux:
make linux.build
Cross-compile for Windows:
make windows.build
## Build packages with mock
Create a new mock profile:
cp /etc/mock/`rpm --eval fedora-%{fedora}-%{_arch}`.cfg /etc/mock/`rpm --eval fedora-%{fedora}-%{_arch}`-matahari.cfg
Add matahari-qpid repo to new mock profile, edit:
.
.
[matahari-qpid]
name=matahari-qpid
baseurl=file:///home/<user>/rpmbuild/RPMS
enabled=1
gpgcheck=0
You'll also need to make a few changes to matahari.spec to accommodate
qpid package name changes:
diff --git a/matahari.spec b/matahari.spec
index 9801099..c14b2c7 100644
--- a/matahari.spec
+++ b/matahari.spec
@@ -23,7 +23,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# NOTE: The host API uses dbus for the machine uuid
Requires: dbus
-Requires: qmf > 0.7
+Requires: qpid-qmf > 0.7
Requires: pcre
BuildRequires: cmake
@@ -35,7 +35,7 @@ BuildRequires: sigar-devel
%if %{with qmf}
BuildRequires: qpid-cpp-client-devel > 0.7
-BuildRequires: qmf-devel > 0.7
+BuildRequires: qpid-qmf-devel > 0.7
%endif
%if %{with dbus}
@@ -63,7 +63,7 @@ Group: Applications/System
Requires: %{name} = %{version}-%{release}
Requires: qpid-cpp-server > 0.7
Requires: qpid-cpp-server-ssl > 0.7
-Requires: qmf > 0.7
+Requires: qpid-qmf > 0.7
%description broker
Optional AMQP Broker for Matahari
@@ -146,7 +146,7 @@ Requires: %{name} = %{version}-%{release}
Requires: %{name}-lib = %{version}-%{release}
Requires: %{name}-agent-lib = %{version}-%{release}
Requires: qpid-cpp-client-devel > 0.7
-Requires: qmf-devel > 0.7
+Requires: qpid-qmf-devel > 0.7
Requires: glib2-devel
You can now build matahari packages with your new mock profile:
make PROFILE=`rpm --eval fedora-%{fedora}-%{_arch}`-matahari mock
## Test build
Start matahari broker:
service matahari-broker start
Start the matahari host agent:
cd src/host
./matahari-qmf-hostd -b localhost -p 49000
Query agent with `qmf-tool`:
qmf-tool localhost:49000
list agents
set default <# of matahari agent>
query Host org.matahariproject
show <# of message>
12 years, 11 months
[PATCH] Fixes for unittest to compile on mingw32
by Adam Stokes
---
mingw32-matahari.spec | 4 ++--
src/tests/CMakeLists.txt | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/mingw32-matahari.spec b/mingw32-matahari.spec
index 429c8f7..7cf280b 100644
--- a/mingw32-matahari.spec
+++ b/mingw32-matahari.spec
@@ -2,8 +2,8 @@
%global __objdump %{_mingw32_objdump}
-%global specversion 13
-%global upstream_version f70d325
+%global specversion 14
+%global upstream_version d73be21
# Keep around for when/if required
%global alphatag %{upstream_version}.git
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 17e3cac..71c0fd3 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -4,11 +4,11 @@ if(CXXTEST_FOUND)
include_directories(${CXXTEST_INCLUDE_DIR})
ENABLE_TESTING()
CXXTEST_ADD_TEST(mh_api_network_unittest mh_api_network_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_network.h)
- target_link_libraries(mh_api_network_unittest mnetwork)
CXXTEST_ADD_TEST(mh_api_host_unittest mh_api_host_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_host.h)
- add_library(mh_tester SHARED mh_test_utilities.c ../lib/utilities.c)
- target_link_libraries(mh_api_network_unittest mnetwork mh_tester)
- target_link_libraries(mh_api_host_unittest mhost pcre mh_tester)
+ add_library(mh_tester SHARED mh_test_utilities.c)
+ target_link_libraries(mh_tester ${pcre_LIBRARIES} mcommon mnetwork mhost)
+ target_link_libraries(mh_api_network_unittest mh_tester)
+ target_link_libraries(mh_api_host_unittest mh_tester)
endif(CXXTEST_FOUND)
file(GLOB SRCS "*.cpp")
--
1.7.5.2
12 years, 11 months
A fully functional console for the services API (and other assorted items)
by Andrew Beekhof
[PATCH 1/8] Build: Add back the dissappearing doxygen-www target
[PATCH 2/8] Build: Tweak the srpm and overlay targets
[PATCH 3/8] Core: Add uname and uuid attributes to all agents to
[PATCH 4/8] Services: Further refine the schema for consistency and
[PATCH 5/8] Build: Add the Qpid types library conditionally on it
[PATCH 6/8] Build: Remove some additional scratch files
[PATCH 7/8] Build: Remove unnecessary re-linkage to wsock32 on
[PATCH 8/8] Services: Add a CLI for the QMFv2 API
12 years, 11 months
Misc fixes to allow compilation
by Andrew Beekhof
[PATCH 1/3] Core: Fix windows compilation and allow consoles to use
[PATCH 2/3] Config: Fix the SO version
[PATCH 3/3] Build: Add a target for publishing the latest API
12 years, 11 months
[PATCH 1/2] Add regex support to network unittest
by Adam Stokes
From: Adam Stokes <astokes(a)fedoraproject.org>
- test utility library added in order to do some pattern matching on
our api results. this can of course be extended beyond regex use
during unittests
---
src/tests/CMakeLists.txt | 5 +++-
src/tests/mh_api_network.h | 45 ++++++++++++++++++++++++-------
src/tests/mh_test_utilities.c | 60 +++++++++++++++++++++++++++++++++++++++++
src/tests/mh_test_utilities.h | 28 +++++++++++++++++++
4 files changed, 127 insertions(+), 11 deletions(-)
create mode 100644 src/tests/mh_test_utilities.c
create mode 100644 src/tests/mh_test_utilities.h
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 99ae968..3cbd8cc 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -4,7 +4,10 @@ if(CXXTEST_FOUND)
include_directories(${CXXTEST_INCLUDE_DIR})
ENABLE_TESTING()
CXXTEST_ADD_TEST(mh_api_network_unittest mh_api_network_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_network.h)
- target_link_libraries(mh_api_network_unittest mnetwork)
+ CXXTEST_ADD_TEST(mh_api_host_unittest mh_api_host_unittest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mh_api_host.h)
+ add_library(mh_tester SHARED mh_test_utilities.c)
+ target_link_libraries(mh_api_network_unittest mnetwork mh_tester)
+ target_link_libraries(mh_api_host_unittest mhost pcre mh_tester)
message(STATUS "Testing Found.")
endif(CXXTEST_FOUND)
diff --git a/src/tests/mh_api_network.h b/src/tests/mh_api_network.h
index 30b9888..1b2b629 100644
--- a/src/tests/mh_api_network.h
+++ b/src/tests/mh_api_network.h
@@ -16,6 +16,7 @@ extern "C" {
#include <sigar.h>
#include <sigar_format.h>
#include <glib.h>
+#include "mh_test_utilities.h"
};
using namespace std;
@@ -27,30 +28,54 @@ class MhApiNetworkSuite : public CxxTest::TestSuite
GList *interface_list;
sigar_net_interface_config_t *ifconfig;
vector<char*> iface_names;
-
- void setUp (void)
+
+ void init()
{
interface_list = mh_network_get_interfaces();
for (plist = g_list_first(interface_list); plist;
- plist = g_list_next(plist)) {
+ plist = g_list_next(plist)) {
ifconfig = (sigar_net_interface_config_t *)plist->data;
iface_names.push_back(ifconfig->name);
}
+ g_list_free(interface_list);
}
-
- void tearDown (void)
- {
- g_list_free(interface_list);
- }
-
+
void testListNetworkDevices(void)
{
unsigned int i;
-
+
+ /* only initialize on first test in suite */
+ init();
+
for(i=0; i<iface_names.size(); i++) {
+ TS_TRACE(iface_names[i]);
TS_ASSERT(iface_names[i]);
}
}
+
+ void testGetNetworkIP(void)
+ {
+ unsigned int i;
+ const char *ip = NULL;
+ for(i=0; i<iface_names.size(); i++) {
+ ip = mh_network_get_ip_address(iface_names[i]);
+ TS_TRACE(ip);
+ TS_ASSERT((is_match("^\\d+\\.\\d+\\.\\d+\\.\\d+",
+ ip)) >= 0);
+ }
+ }
+
+ void testGetNetworkMAC(void)
+ {
+ unsigned int i;
+ const char *mac = NULL;
+ for(i=0; i<iface_names.size(); i++) {
+ mac = mh_network_get_mac_address(iface_names[i]);
+ TS_TRACE(mac);
+ TS_ASSERT((is_match("^([0-9a-fA-F]{2}([:-]|$)){6}$",
+ mac)) >= 0);
+ }
+ }
};
#endif
diff --git a/src/tests/mh_test_utilities.c b/src/tests/mh_test_utilities.c
new file mode 100644
index 0000000..1c3456d
--- /dev/null
+++ b/src/tests/mh_test_utilities.c
@@ -0,0 +1,60 @@
+/*
+ * mh_test_utilities.c: util functions for testing
+ *
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Adam Stokes <astokes(a)fedoraproject.org>
+ */
+
+#include "mh_test_utilities.h"
+#include <pcre.h>
+#include <string.h>
+
+#define OVECCOUNT 30
+
+int
+is_match(const char *pattern, const char *subject)
+{
+ int erroroffset;
+ int ovector[OVECCOUNT];
+ const char *error;
+ pcre *re;
+ int rc;
+
+ re = pcre_compile(pattern,
+ 0,
+ &error,
+ &erroroffset,
+ NULL);
+ if (re == NULL) {
+ return PCRE_ERROR_NULL;
+ }
+
+ rc = pcre_exec(
+ re,
+ NULL,
+ subject,
+ strlen(subject),
+ 0,
+ 0,
+ ovector,
+ OVECCOUNT);
+
+ /* Since we only care about return code for now free the regex */
+ pcre_free(re);
+ return rc;
+}
diff --git a/src/tests/mh_test_utilities.h b/src/tests/mh_test_utilities.h
new file mode 100644
index 0000000..f75df05
--- /dev/null
+++ b/src/tests/mh_test_utilities.h
@@ -0,0 +1,28 @@
+/*
+ * mh_test_utilities.h: util functions for unittest
+ *
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Adam Stokes <astokes(a)fedoraproject.org>
+ */
+
+#ifndef __MH_TEST_UTILITIES_H
+#define __MH_TEST_UTILITIES_H
+
+extern int is_match(const char *pattern, const char *subject);
+
+#endif /* __MH_TEST_UTILITIES */
--
1.7.4.4
12 years, 11 months
[PATCH 1/2] DBus agents use per-agent schema.xml
by Radek Novacek
Signed-off-by: Radek Novacek <rnovacek(a)redhat.com>
---
src/CMakeLists.txt | 8 --------
src/cmake/modules/MatahariMacros.cmake | 20 ++++++++------------
src/host/CMakeLists.txt | 5 ++++-
src/network/CMakeLists.txt | 5 ++++-
src/service/CMakeLists.txt | 5 ++++-
5 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4636ee2..6e29a08 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -113,14 +113,6 @@ else(WITH-DBUS STREQUAL "ON")
endif(NOT polkit_FOUND)
endif(WITH-DBUS STREQUAL "ON")
-if(WITH-DBUS)
- message(STATUS "DBus is enabled")
- # Create src/dbus directory and generate DBus XML definition files into it
- generate_dbus_interface(${SCHEMAS})
-else(WITH-DBUS)
- message(STATUS "DBus is disabled")
-endif(WITH-DBUS)
-
## qpid
if(WITH-QMF)
# Defines
diff --git a/src/cmake/modules/MatahariMacros.cmake b/src/cmake/modules/MatahariMacros.cmake
index ea976eb..0c48b29 100644
--- a/src/cmake/modules/MatahariMacros.cmake
+++ b/src/cmake/modules/MatahariMacros.cmake
@@ -32,20 +32,16 @@ macro(generate_dbus_headers API XML)
endmacro(generate_dbus_headers)
# This macro will transform QMF interface XML to DBus interface XML file
-# Arguments SCHEMAS - paths to XML schema files
-macro(generate_dbus_interface SCHEMAS)
+# Argument SCHEMA - path to XML schema file
+macro(generate_dbus_interface SCHEMA)
find_file(SCHEMA_TO_DBUS schema-to-dbus.xsl
- ${CMAKE_CURRENT_SOURCE_DIR} /usr/share/matahari)
+ ${CMAKE_CURRENT_SOURCE_DIR}/.. /usr/share/matahari)
find_file(XSLTPROC xsltproc)
- # Create dbus subdirectory
- execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/dbus)
- foreach(SCHEMA ${SCHEMAS})
- # Generate files for each schema
- execute_process(
- COMMAND ${XSLTPROC} ${SCHEMA_TO_DBUS} ${SCHEMA}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dbus
- )
- endforeach(SCHEMA ${SCHEMAS})
+ # Generate files
+ execute_process(
+ COMMAND ${XSLTPROC} ${SCHEMA_TO_DBUS} ${SCHEMA}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
endmacro(generate_dbus_interface)
# This macro will generate QMF definition files from QMF schema
diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt
index 0e3f8c6..38f5e0f 100644
--- a/src/host/CMakeLists.txt
+++ b/src/host/CMakeLists.txt
@@ -33,7 +33,10 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- generate_dbus_headers(${BASE} ${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Host.xml)
+ generate_dbus_headers(${BASE} ${CMAKE_CURRENT_BINARY_DIR}/org.matahariproject.Host.xml)
+ # Create src/dbus directory and generate DBus XML definition files into it
+ generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/schema.xml)
+
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index 8c9fc86..3791191 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -33,7 +33,10 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- generate_dbus_headers(${BASE} ${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Network.xml)
+ generate_dbus_headers(${BASE} ${CMAKE_CURRENT_BINARY_DIR}/org.matahariproject.Network.xml)
+ # Create src/dbus directory and generate DBus XML definition files into it
+ generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/schema.xml)
+
# Must be included to find API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt
index 7f15a88..fba3cba 100644
--- a/src/service/CMakeLists.txt
+++ b/src/service/CMakeLists.txt
@@ -33,7 +33,10 @@ endif(WITH-QMF)
# DBus daemon
if(WITH-DBUS)
# Auto-generated stuff
- generate_dbus_headers(${BASE} ${CMAKE_BINARY_DIR}/src/dbus/org.matahariproject.Services.xml)
+ generate_dbus_headers(${BASE} ${CMAKE_CURRENT_BINARY_DIR}/org.matahariproject.Services.xml)
+ # Create src/dbus directory and generate DBus XML definition files into it
+ generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/schema.xml)
+
# Must be included to find matahari-API-dbus-properties.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
--
1.7.5.1
12 years, 11 months