diff options
Diffstat (limited to 'tests/auto/qtipc/lackey/scripts')
8 files changed, 151 insertions, 0 deletions
diff --git a/tests/auto/qtipc/lackey/scripts/consumer.js b/tests/auto/qtipc/lackey/scripts/consumer.js new file mode 100644 index 0000000..4d12dca --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/consumer.js @@ -0,0 +1,41 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var consumer = new ScriptSharedMemory; +consumer.setKey("market"); + +//print("consumer starting"); +var tries = 0;; +while(!consumer.attach()) { + if (tries == 5000) { + var message = "consumer exiting, waiting too long"; + print(message); + throw(message); + } + ++tries; + consumer.sleep(1); +} +//print("consumer attached"); + + +var i = 0; +while(true) { + QVERIFY(consumer.lock(), "lock"); + if (consumer.get(0) == 'Q') { + consumer.set(0, ++i); + //print ("consumer sets" + i); + } + if (consumer.get(0) == 'E') { + QVERIFY(consumer.unlock(), "unlock"); + break; + } + QVERIFY(consumer.unlock(), "unlock"); + consumer.sleep(10); +} + +//print("consumer detaching"); +QVERIFY(consumer.detach()); diff --git a/tests/auto/qtipc/lackey/scripts/producer.js b/tests/auto/qtipc/lackey/scripts/producer.js new file mode 100644 index 0000000..e02cd8b --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/producer.js @@ -0,0 +1,44 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var producer = new ScriptSharedMemory; +producer.setKey("market"); + +var size = 1024; +if (!producer.create(size)) { + QVERIFY(producer.error() == 4, "create"); + QVERIFY(producer.attach()); +} +//print ("producer created and attached"); + +QVERIFY(producer.lock()); +producer.set(0, 'Q'); +QVERIFY(producer.unlock()); + +var i = 0; +while(i < 5) { + QVERIFY(producer.lock(), "lock"); + if (producer.get(0) == 'Q') { + QVERIFY(producer.unlock(), "unlock"); + producer.sleep(1); + continue; + } + //print("producer: " + i); + ++i; + producer.set(0, 'Q'); + QVERIFY(producer.unlock(), "unlock"); + producer.sleep(1); +} +QVERIFY(producer.lock()); +producer.set(0, 'E'); +QVERIFY(producer.unlock()); + +//print ("producer done"); + +// Sleep for a bit to let all consumers start, otherwise they will get stuck in the attach loop, +// because at least in Symbian the shared memory will be destroyed if there are no active handles to it. +producer.sleep(3000);
\ No newline at end of file diff --git a/tests/auto/qtipc/lackey/scripts/readonly_segfault.js b/tests/auto/qtipc/lackey/scripts/readonly_segfault.js new file mode 100644 index 0000000..3eaf789 --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/readonly_segfault.js @@ -0,0 +1,4 @@ +var sm = new ScriptSharedMemory; +sm.setKey("readonly_segfault"); +sm.createReadOnly(1024); +var data = sm.set(0, "a"); diff --git a/tests/auto/qtipc/lackey/scripts/systemlock_read.js b/tests/auto/qtipc/lackey/scripts/systemlock_read.js new file mode 100644 index 0000000..1048bc7 --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/systemlock_read.js @@ -0,0 +1,11 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var lock = new ScriptSystemLock; +lock.setKey("market"); +QVERIFY(lock.lockReadOnly()); +QVERIFY(lock.unlock());
\ No newline at end of file diff --git a/tests/auto/qtipc/lackey/scripts/systemlock_readwrite.js b/tests/auto/qtipc/lackey/scripts/systemlock_readwrite.js new file mode 100644 index 0000000..fc6367f --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/systemlock_readwrite.js @@ -0,0 +1,11 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var lock = new ScriptSystemLock; +lock.setKey("market"); +QVERIFY(lock.lock()); +QVERIFY(lock.unlock()); diff --git a/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquire.js b/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquire.js new file mode 100644 index 0000000..5cff429 --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquire.js @@ -0,0 +1,18 @@ +#/bin/qscript +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + + +var sem = new ScriptSystemSemaphore; +sem.setKey("store"); + +var count = Number(args[1]); +if (isNaN(count)) + count = 1; +for (var i = 0; i < count; ++i) + QVERIFY(sem.acquire()); +print("done aquiring"); diff --git a/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquirerelease.js b/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquirerelease.js new file mode 100644 index 0000000..cedde3f --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/systemsemaphore_acquirerelease.js @@ -0,0 +1,11 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var lock = new ScriptSystemSemaphore; +lock.setKey("store"); +QVERIFY(lock.acquire()); +QVERIFY(lock.release()); diff --git a/tests/auto/qtipc/lackey/scripts/systemsemaphore_release.js b/tests/auto/qtipc/lackey/scripts/systemsemaphore_release.js new file mode 100644 index 0000000..c805e0f --- /dev/null +++ b/tests/auto/qtipc/lackey/scripts/systemsemaphore_release.js @@ -0,0 +1,11 @@ +function QVERIFY(x, debugInfo) { + if (!(x)) { + print(debugInfo); + throw(debugInfo); + } +} + +var sem = new ScriptSystemSemaphore; +sem.setKey("store"); +QVERIFY(sem.release()); +print ("done releasing"); |