---
src/tests/Rakefile | 29 ++++++++++++++++++++++++++
src/tests/agent.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 0 deletions(-)
create mode 100644 src/tests/Rakefile
create mode 100644 src/tests/agent.rb
diff --git a/src/tests/Rakefile b/src/tests/Rakefile
new file mode 100644
index 0000000..a343e7d
--- /dev/null
+++ b/src/tests/Rakefile
@@ -0,0 +1,29 @@
+#
+# Rakefile: ruby build helpers
+#
+# Copyright (C) 2010 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>
+#
+
+require 'rake/clean'
+require 'rake/testtask'
+require 'pathname'
+
+Rake::TestTask.new(:test) do |t|
+ t.test_files = FileList['*.rb']
+end
diff --git a/src/tests/agent.rb b/src/tests/agent.rb
new file mode 100644
index 0000000..016f36c
--- /dev/null
+++ b/src/tests/agent.rb
@@ -0,0 +1,58 @@
+#
+# agent.rb: test routines for matahari agents
+#
+# Copyright (C) 2010 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>
+#
+
+require 'test/unit'
+require 'cqpid'
+require 'qmf2'
+
+class AgentSetup < Test::Unit::TestCase
+ def setup
+ @connection = Cqpid::Connection.new("localhost:49000")
+ @connection.open
+ @session = Qmf2::ConsoleSession.new(@connection)
+ @session.open
+ end
+
+ def teardown
+ @session.close if @session
+ @connection.close if @connection
+ end
+
+ def test_agents
+ @session.set_agent_filter("[eq, _vendor, [quote,
'matahariproject.org']]")
+ net_agent = nil
+ count = 0
+ while :true
+ agent_list = @session.agents
+ agent_list.each do |agent|
+ net_agent = agent if agent.product == 'net'
+ end
+ break if net_agent
+ count = count + 1
+ assert(count < 5)
+ sleep(1)
+ end
+
+ network_agent = net_agent.query("{class:network,
package:'org.matahariproject'}")
+ assert_equal(1, network_agent.length)
+ end
+end
--
1.7.3.4