From: Mark Doffman Date: Fri, 6 Jun 2008 16:10:59 +0000 (+0100) Subject: 2008-06-06 Mark Doffman X-Git-Tag: AT_SPI2_ATK_2_12_0~674^2~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=commitdiff_plain;h=ef25f02aa5044192c07e7d07b2a9c7b61582ddfe 2008-06-06 Mark Doffman * tests/Makefile.am Run the test framework on make check. * tests/data/* Add results directory, and results for single test. * tests/clients/* Changes for passing environment variables needed to find test libraries and data. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 15f1aff..dd9a234 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,12 @@ -SUBDIRS=dummyatk apps clients +SUBDIRS = dummyatk apps clients +EXTRA_DIST = testrunner.py runtests.sh -EXTRA_DIST = testrunner.py +TESTS=testrunner.py +TESTS_ENVIRONMENT = PYTHONPATH=$(abs_top_srcdir)/python \ + ATSPI_INTROSPECTION_PATH=$(top_srcdir)/xml/introspection \ + testdata=$(abs_top_srcdir)/tests/data \ + atspilib=$(abs_top_srcdir)/atk-adaptor/.libs/libspiatk.so \ + testmodules=$(abs_top_srcdir)/tests/apps/.libs \ + testapp=$(abs_top_srcdir)/tests/apps/test-application + +CLEANFILES = *.pyc diff --git a/tests/clients/Makefile.am b/tests/clients/Makefile.am index 2777638..a0d9ea1 100644 --- a/tests/clients/Makefile.am +++ b/tests/clients/Makefile.am @@ -1,5 +1,6 @@ EXTRA_DIST = \ accessibleobject.py \ __init__.py \ - object-test-stage1.xml \ testutil.py + +CLEANFILES = *.pyc diff --git a/tests/clients/accessibleobject.py b/tests/clients/accessibleobject.py index 480b3f7..f63490d 100644 --- a/tests/clients/accessibleobject.py +++ b/tests/clients/accessibleobject.py @@ -40,10 +40,16 @@ class AccessibleObjectTestCase(unittest.TestCase): def runTest(self): root = self._cache.getRootAccessible() + doc = minidom.Document() createNode(root, doc) answer = doc.toprettyxml() - correct = os.path.join(testutil.testdata, "object-test-stage1.xml") + + correct = os.path.join(testutil.testdata, "object-test-stage1-results.xml") file = open(correct) cstring = file.read() + + #import difflib + #print ''.join(difflib.unified_diff(answer.splitlines(), cstring.splitlines())) + self.assertEqual(answer, cstring, "Object tree not passed correctly") diff --git a/tests/clients/testutil.py b/tests/clients/testutil.py index a5bc9dd..c7d8e0f 100644 --- a/tests/clients/testutil.py +++ b/tests/clients/testutil.py @@ -17,11 +17,21 @@ testmodules = "../apps/.libs" #Atk to at-spi adaptor library location. atspilib = "../../atk-adaptor/.libs/libspiatk.so" -from subprocess import Popen -from os.path import join def runTestApp(module_name): - testmodule = join(testmodules, module_name) - print testmodule - print testapp - return Popen([testapp , "-a", atspilib, "-t", testmodule, "-d", testdata]) + import os + from subprocess import Popen + + testmodule = os.path.join(testmodules, module_name) + pop = Popen([testapp , "-a", atspilib, "-t", testmodule, "-d", testdata]) + + wait_envar = "TEST_APP_WAIT_FOR_DEBUG" + + wait_message = """ + The test application %s has been started with PID %d. + + To continue the test press ENTER.\n\n + """ + + if (wait_envar in os.environ.keys()): + raw_input(wait_message % (module_name, pop.pid)) diff --git a/tests/data/object-test-stage1-results.xml b/tests/data/object-test-stage1-results.xml new file mode 100644 index 0000000..9a0ebd3 --- /dev/null +++ b/tests/data/object-test-stage1-results.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/clients/object-test-stage1.xml b/tests/data/object-test-stage1.xml similarity index 100% rename from tests/clients/object-test-stage1.xml rename to tests/data/object-test-stage1.xml diff --git a/tests/runtests.sh b/tests/runtests.sh new file mode 100755 index 0000000..0cc27a1 --- /dev/null +++ b/tests/runtests.sh @@ -0,0 +1,9 @@ +export PYTHONPATH=../python +export ATSPI_INTROSPECTION_PATH=../xml/introspection + +export testdata=../tests/data +export atspilib=../atk-adaptor/.libs/libspiatk.so +export testmodules=../tests/apps/.libs +export testapp=../tests/apps/test-application + +./testrunner.py diff --git a/tests/testrunner.py b/tests/testrunner.py old mode 100644 new mode 100755 index 5684c75..feafc33 --- a/tests/testrunner.py +++ b/tests/testrunner.py @@ -1,17 +1,10 @@ +#!/usr/bin/python + import sys +import os import unittest import clients -from optparse import OptionParser - -parser = OptionParser() -parser.add_option("-d", "--testdata", dest="testdata", help="Location of test data directory") -parser.add_option("-a", "--atspilib", dest="atspilib", help="Location of atk to atspi adaptor") -parser.add_option("-t", "--testmodules", dest="testmodules", help="Location of test application libraries") -parser.add_option("-r", "--testapp", dest="testapp", help="Location of test application executable") -parser.add_option("-b", "--busname", dest="busname", help="D-Bus name of test application") -parser.add_option("-o", "--objectpath", dest="objectpath", help="Object path of test applicaiton tree interface") - optionvars = ["testdata", "atspilib", "testmodules", @@ -19,18 +12,23 @@ optionvars = ["testdata", "busname", "objectpath"] -def set_data(options, name): - val = getattr(options, name) - if val is not None: - setattr(clients.testutil, name, val) def main(argv): - (options, args) = parser.parse_args() - [set_data(options, name) for name in optionvars] + def set_data(name): + if name in os.environ.keys(): + setattr(clients.testutil, name, os.environ[name]) + + [set_data(name) for name in optionvars] runner = unittest.TextTestRunner() testsuite = unittest.defaultTestLoader.loadTestsFromModule(clients) - runner.run(testsuite) + result = runner.run(testsuite) + + if result.wasSuccessful(): + return 0 + else: + return 1 + if __name__=="__main__": sys.exit(main(sys.argv))