aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkos PASZTORY <ext-akos.pasztory@nokia.com>2009-11-13 09:54:00 +0200
committerAkos PASZTORY <ext-akos.pasztory@nokia.com>2009-11-13 09:54:00 +0200
commit4439a93031c1d7add36705b989ea91509b43d257 (patch)
treebd3dd4d86238bdf9ac97f979e89d6443a04ec708
parent978a1176f30c1caf06d0b9ba6218c5add1c28b9e (diff)
parent8bd67d165d9aac90c330f8dadd16f0cce11de848 (diff)
Merge remote branch 'origin/master' into qjson
Conflicts: libcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py libcontextsubscriber/customer-tests/subscription/multiprovider2.py
-rwxr-xr-xlibcontextsubscriber/customer-tests/asynchronicity/asynchronicity.py6
-rwxr-xr-xlibcontextsubscriber/customer-tests/asynchronicity/rapidchanges.py4
-rwxr-xr-xlibcontextsubscriber/customer-tests/commander/commander_appearing.py4
-rwxr-xr-xlibcontextsubscriber/customer-tests/commander/commander_disabled.py3
-rwxr-xr-xlibcontextsubscriber/customer-tests/commander/commander_nonexistent.py3
-rwxr-xr-xlibcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py1
-rwxr-xr-xlibcontextsubscriber/customer-tests/registry/registry.py7
-rwxr-xr-xlibcontextsubscriber/customer-tests/subscription/multiprovider.py6
-rwxr-xr-xlibcontextsubscriber/customer-tests/subscription/multiprovider2.py6
-rwxr-xr-xlibcontextsubscriber/customer-tests/subscription/subscription.py54
-rw-r--r--libcontextsubscriber/customer-tests/update-contextkit-providers/Battery.Charging_KEYTYPE.expectedbin19 -> 0 bytes
-rwxr-xr-xlibcontextsubscriber/customer-tests/update-contextkit-providers/regen.sh1
-rwxr-xr-xlibcontextsubscriber/customer-tests/update-contextkit-providers/test.sh3
-rwxr-xr-xlibcontextsubscriber/customer-tests/waitforsilence2
-rw-r--r--python/ContextKit/cltool.py10
15 files changed, 62 insertions, 48 deletions
diff --git a/libcontextsubscriber/customer-tests/asynchronicity/asynchronicity.py b/libcontextsubscriber/customer-tests/asynchronicity/asynchronicity.py
index 7eccd1ba..2566ba6f 100755
--- a/libcontextsubscriber/customer-tests/asynchronicity/asynchronicity.py
+++ b/libcontextsubscriber/customer-tests/asynchronicity/asynchronicity.py
@@ -93,9 +93,9 @@ class Asynchronous(unittest.TestCase):
"The arrival time of the fast and slow property is not far enough from each other")
# context_client.printio()
- context_client.close()
- provider_slow.close()
- provider_fast.close()
+ context_client.wait()
+ provider_fast.wait()
+ provider_slow.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(Asynchronous)
diff --git a/libcontextsubscriber/customer-tests/asynchronicity/rapidchanges.py b/libcontextsubscriber/customer-tests/asynchronicity/rapidchanges.py
index 925a1812..f695e91c 100755
--- a/libcontextsubscriber/customer-tests/asynchronicity/rapidchanges.py
+++ b/libcontextsubscriber/customer-tests/asynchronicity/rapidchanges.py
@@ -78,8 +78,8 @@ class RapidChanges(unittest.TestCase):
self.assertFalse(context_client.expect("test.fast =", wantdump = False, timeout=1),
"expected a single valueChanged")
- provider_fast.close()
- context_client.close()
+ context_client.wait()
+ provider_fast.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(RapidChanges)
diff --git a/libcontextsubscriber/customer-tests/commander/commander_appearing.py b/libcontextsubscriber/customer-tests/commander/commander_appearing.py
index 72eef11b..f74ef60c 100755
--- a/libcontextsubscriber/customer-tests/commander/commander_appearing.py
+++ b/libcontextsubscriber/customer-tests/commander/commander_appearing.py
@@ -68,10 +68,12 @@ class CommanderAppearing(unittest.TestCase):
self.assert_(listen.expect(wanted("test.int", "int", "1235")),
"Value after commander has changed it is wrong, wanted 1235")
- commander.close()
+ commander.wait()
listen.comment("Commander killed")
self.assert_(listen.expect(wanted("test.int", "int", "42")),
"Value after killing the commander is wrong, wanted 42")
+ listen.wait()
+ provider.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(CommanderAppearing)
diff --git a/libcontextsubscriber/customer-tests/commander/commander_disabled.py b/libcontextsubscriber/customer-tests/commander/commander_disabled.py
index 87d50d2b..1acf1c65 100755
--- a/libcontextsubscriber/customer-tests/commander/commander_disabled.py
+++ b/libcontextsubscriber/customer-tests/commander/commander_disabled.py
@@ -48,6 +48,9 @@ class CommanderDisabled(unittest.TestCase):
listen = CLTool("context-listen", "test.int")
self.assert_(listen.expect(wanted("test.int", "int", "42")),
"Provider provided value is wrong")
+ listen.wait()
+ commander.wait()
+ provider.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(CommanderDisabled)
diff --git a/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py b/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
index b87e0b21..b10d4a67 100755
--- a/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
+++ b/libcontextsubscriber/customer-tests/commander/commander_nonexistent.py
@@ -65,6 +65,9 @@ class CommanderNonExistent(unittest.TestCase):
self.assert_(listen.expect(wanted("test.string", "int", "42")),
"Non-existent property's type couldn't be overwritten")
+ commander.wait()
+ listen.wait()
+ provider.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(CommanderNonExistent)
result = unittest.TextTestRunner(verbosity=2).run(suiteInstallation)
diff --git a/libcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py b/libcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py
index 7038d679..a1ee1fbe 100755
--- a/libcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py
+++ b/libcontextsubscriber/customer-tests/pluginchanging/pluginchanging.py
@@ -62,6 +62,7 @@ class Subscription(unittest.TestCase):
# Expect value coming from plugin libcontextsubscribertime2
self.assert_(self.context_client.expect("Test.Time = QString:\"Time2:"))
+ self.context_client.wait()
if __name__ == "__main__":
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
diff --git a/libcontextsubscriber/customer-tests/registry/registry.py b/libcontextsubscriber/customer-tests/registry/registry.py
index 35cefdca..0511a7ce 100755
--- a/libcontextsubscriber/customer-tests/registry/registry.py
+++ b/libcontextsubscriber/customer-tests/registry/registry.py
@@ -42,7 +42,8 @@ class PrintInfoRunning(unittest.TestCase):
returnValue = info_client.wait()
self.assertEqual(returnValue, 0, "context-ls exited with return value != 0")
- provider.close()
+ info_client.wait()
+ provider.wait()
class PrintingProperties(unittest.TestCase):
def tearDown(self):
@@ -66,7 +67,9 @@ class PrintingProperties(unittest.TestCase):
"^Documentation: A phony but very flexible property.$"]),
"Bad introspection result from context-ls")
- provider.close()
+ info_client.wait()
+ provider.wait()
+
def runTests():
suitePrintInfoRunning = unittest.TestLoader().loadTestsFromTestCase(PrintInfoRunning)
diff --git a/libcontextsubscriber/customer-tests/subscription/multiprovider.py b/libcontextsubscriber/customer-tests/subscription/multiprovider.py
index 1e68c897..47709a2c 100755
--- a/libcontextsubscriber/customer-tests/subscription/multiprovider.py
+++ b/libcontextsubscriber/customer-tests/subscription/multiprovider.py
@@ -69,14 +69,14 @@ class MultiProvider(unittest.TestCase):
provider_y.expect("Setting key")
self.assert_(client.expect(wanted("test.prop", "int", "99")))
- provider_y.close()
+ provider_y.wait()
os.unlink("y.context")
self.assert_(client.expect(wanted("test.prop", "int", "55")))
- provider_x.close()
+ provider_x.wait()
os.unlink("x.context")
self.assert_(client.expect(wantedUnknown("test.prop")))
- client.close()
+ client.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(MultiProvider)
diff --git a/libcontextsubscriber/customer-tests/subscription/multiprovider2.py b/libcontextsubscriber/customer-tests/subscription/multiprovider2.py
index 22fe40bf..34a3c3ae 100755
--- a/libcontextsubscriber/customer-tests/subscription/multiprovider2.py
+++ b/libcontextsubscriber/customer-tests/subscription/multiprovider2.py
@@ -71,9 +71,9 @@ class MultiProvider(unittest.TestCase):
client.send("value test.prop")
self.assert_(client.expect("^value: int:22$"))
- client.close()
- provider_x.close()
- provider_y.close()
+ client.wait()
+ provider_y.wait()
+ provider_y.wait()
def runTests():
suiteInstallation = unittest.TestLoader().loadTestsFromTestCase(MultiProvider)
diff --git a/libcontextsubscriber/customer-tests/subscription/subscription.py b/libcontextsubscriber/customer-tests/subscription/subscription.py
index c0d8e4fe..3e941de7 100755
--- a/libcontextsubscriber/customer-tests/subscription/subscription.py
+++ b/libcontextsubscriber/customer-tests/subscription/subscription.py
@@ -102,8 +102,11 @@ class Subscription(unittest.TestCase):
listen.expect("^key: test.int$"),
"Key command returned wrong value")
- provider.close()
- listen.close()
+ # Because of a python threading / process / CLTool
+ # issue, processes need to be waited for in the
+ # opposite order as they are started.
+ listen.wait()
+ provider.wait()
def testInfos(self):
"""
@@ -153,8 +156,8 @@ class Subscription(unittest.TestCase):
self.assert_(
listen.expect("^type: DOUBLE$"),
"type didn't work")
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
def testTypes(self):
provider = CLTool("context-provide", "--v2", "com.nokia.test",
@@ -192,8 +195,8 @@ class Subscription(unittest.TestCase):
self.assert_(
listen.expect("^type:$"))
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
def testProviders(self):
provider = CLTool("context-provide", "--v2", "com.nokia.test",
@@ -218,8 +221,8 @@ class Subscription(unittest.TestCase):
listen.send("providers test.fake")
self.assert_(
listen.expect("^providers:$"))
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
def testAllDataTypes(self):
"""
@@ -256,8 +259,8 @@ class Subscription(unittest.TestCase):
"^test.string = QString:\"foobar\"$",
"^test.truth = bool:true$"]),
"Actual key values pairs do not match expected")
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
def testTruthTypePermutations(self):
"""
@@ -299,8 +302,8 @@ class Subscription(unittest.TestCase):
self.assert_(
listen.expect("^test.truth = bool:true$"),
"setting to true didn't work")
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
def testStringTypePermutations(self):
"""
@@ -342,8 +345,8 @@ class Subscription(unittest.TestCase):
listen.expect(wantedUnknown("test.string")),
"setting to null didn't work")
- provider.close()
- listen.close()
+ listen.wait()
+ provider.wait()
class MultipleSubscribers(unittest.TestCase):
def setUp(self):
@@ -361,12 +364,11 @@ class MultipleSubscribers(unittest.TestCase):
self.context_client4 = CLTool("context-listen","test.int","test.double","test.string")
def tearDown(self):
- self.flexiprovider.send("exit")
- self.flexiprovider.close()
- self.context_client1.close()
- self.context_client2.close()
- self.context_client3.close()
- self.context_client4.close()
+ self.context_client4.wait()
+ self.context_client3.wait()
+ self.context_client2.wait()
+ self.context_client1.wait()
+ self.flexiprovider.wait()
os.unlink('./context-provide.context')
def testInitialSubscription(self):
@@ -497,14 +499,14 @@ class MultipleProviders(unittest.TestCase):
self.assert_(
listen.expect("^test.truth = bool:false$"))
- provider1.close()
- provider2.close()
- listen.close()
+ listen.wait()
+ provider2.wait()
+ provider1.wait()
class SubscriptionPause (unittest.TestCase):
def tearDown(self):
- self.provider.close()
- self.listen.close()
+ self.listen.wait()
+ self.provider.wait()
os.unlink('context-provide.context')
def testPause(self):
@@ -620,7 +622,7 @@ class SubscriptionWaitError (unittest.TestCase):
self.assert_(context_client.expect("wait finished for test.nonexistent"),
"Wait for subscription is probably in a dead state")
- context_client.close()
+ context_client.wait()
if __name__ == "__main__":
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
diff --git a/libcontextsubscriber/customer-tests/update-contextkit-providers/Battery.Charging_KEYTYPE.expected b/libcontextsubscriber/customer-tests/update-contextkit-providers/Battery.Charging_KEYTYPE.expected
deleted file mode 100644
index 3815ca9d..00000000
--- a/libcontextsubscriber/customer-tests/update-contextkit-providers/Battery.Charging_KEYTYPE.expected
+++ /dev/null
Binary files differ
diff --git a/libcontextsubscriber/customer-tests/update-contextkit-providers/regen.sh b/libcontextsubscriber/customer-tests/update-contextkit-providers/regen.sh
index 9f28424d..bcc8fa9a 100755
--- a/libcontextsubscriber/customer-tests/update-contextkit-providers/regen.sh
+++ b/libcontextsubscriber/customer-tests/update-contextkit-providers/regen.sh
@@ -8,7 +8,6 @@ export CONTEXT_CORE_DECLARATIONS=.
../../update-contextkit-providers/update-contextkit-providers .
regendb "KEYS" "KEYS"
-regendb "Battery.Charging:KEYTYPE" "Battery.Charging_KEYTYPE"
regendb "Battery.Charging:KEYDOC" "Battery.Charging_KEYDOC"
regendb "Battery.Charging:PROVIDERS" "Battery.Charging_PROVIDERS"
echo "Regen succeeded!"
diff --git a/libcontextsubscriber/customer-tests/update-contextkit-providers/test.sh b/libcontextsubscriber/customer-tests/update-contextkit-providers/test.sh
index 7f800ce2..ada1b255 100755
--- a/libcontextsubscriber/customer-tests/update-contextkit-providers/test.sh
+++ b/libcontextsubscriber/customer-tests/update-contextkit-providers/test.sh
@@ -30,9 +30,6 @@ function dotest {
querydb "KEYS" "KEYS"
compare "KEYS.expected" "KEYS.actual"
- querydb "Battery.Charging:KEYTYPE" "Battery.Charging_KEYTYPE"
- compare "Battery.Charging_KEYTYPE.expected" "Battery.Charging_KEYTYPE.actual"
-
querydb "Battery.Charging:KEYDOC" "Battery.Charging_KEYDOC"
compare "Battery.Charging_KEYDOC.expected" "Battery.Charging_KEYDOC.actual"
diff --git a/libcontextsubscriber/customer-tests/waitforsilence b/libcontextsubscriber/customer-tests/waitforsilence
index 6489f557..d96fc4f0 100755
--- a/libcontextsubscriber/customer-tests/waitforsilence
+++ b/libcontextsubscriber/customer-tests/waitforsilence
@@ -3,7 +3,7 @@
# Wait until the load is below 2, but not more than 2 minutes. Plus, dump
# some information for post-mortem troubleshooting.
-exec >/tmp/xyzzy.log 2>&1;
+exec >/tmp/xyzzy.log 2>&1 </dev/null;
echo ==== PWD ====; pwd;
echo ==== UPTIME ====; uptime;
echo ==== PS ====; ps;
diff --git a/python/ContextKit/cltool.py b/python/ContextKit/cltool.py
index 454b5101..8051aadc 100644
--- a/python/ContextKit/cltool.py
+++ b/python/ContextKit/cltool.py
@@ -66,7 +66,7 @@ class CLTool:
def __init__(self, *cline):
self.process = Popen(cline, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
- preexec_fn=self._preexec)
+ preexec_fn=self._preexec, close_fds=True)
self.io = []
self.iolock = Lock()
self.reader = Reader(self)
@@ -97,8 +97,12 @@ class CLTool:
"""Writes STRING to the standard input of the child."""
with self.iolock:
self.io.append((time.time(), CLTool.STDIN, string))
- print >>self.process.stdin, string
- self.process.stdin.flush()
+ try:
+ print >>self.process.stdin, string
+ self.process.stdin.flush()
+ except:
+ self.printio()
+ raise
def _return_event(self, wantdump):
with self.iolock: