aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/archive_tests.py24
-rw-r--r--tests/worker.py148
l---------tests/worker_link1
-rw-r--r--tests/ziptest0
l---------tests/ziptest_link1
5 files changed, 13 insertions, 161 deletions
diff --git a/tests/archive_tests.py b/tests/archive_tests.py
index 01c46395..f982be0a 100644
--- a/tests/archive_tests.py
+++ b/tests/archive_tests.py
@@ -24,28 +24,28 @@ class ZipFileArchiveTest(unittest.TestCase):
self.zf.close()
def test_add_file(self):
- self.zf.add_file('tests/worker.py')
+ self.zf.add_file('tests/ziptest')
self.zf.close()
- self.check_for_file('test/tests/worker.py')
+ self.check_for_file('test/tests/ziptest')
def test_add_dir(self):
self.zf.add_file('tests/')
self.zf.close()
- self.check_for_file('test/tests/worker.py')
+ self.check_for_file('test/tests/ziptest')
def test_add_renamed(self):
- self.zf.add_file('tests/worker.py', dest='tests/worker_renamed.py')
+ self.zf.add_file('tests/ziptest', dest='tests/ziptest_renamed')
self.zf.close()
- self.check_for_file('test/tests/worker_renamed.py')
+ self.check_for_file('test/tests/ziptest_renamed')
def test_add_renamed_dir(self):
self.zf.add_file('tests/', 'tests_renamed/')
self.zf.close()
- self.check_for_file('test/tests_renamed/worker.py')
+ self.check_for_file('test/tests_renamed/ziptest')
def test_add_string(self):
self.zf.add_string('this is content', 'tests/string_test.txt')
@@ -84,28 +84,28 @@ class TarFileArchiveTest(unittest.TestCase):
self.assertTrue(os.path.exists('test.tar'))
def test_add_file(self):
- self.tf.add_file('tests/worker.py')
+ self.tf.add_file('tests/ziptest')
self.tf.close()
- self.check_for_file('test/tests/worker.py')
+ self.check_for_file('test/tests/ziptest')
def test_add_dir(self):
self.tf.add_file('tests/')
self.tf.close()
- self.check_for_file('test/tests/worker.py')
+ self.check_for_file('test/tests/ziptest')
def test_add_renamed(self):
- self.tf.add_file('tests/worker.py', dest='tests/worker_renamed.py')
+ self.tf.add_file('tests/ziptest', dest='tests/ziptest_renamed')
self.tf.close()
- self.check_for_file('test/tests/worker_renamed.py')
+ self.check_for_file('test/tests/ziptest_renamed')
def test_add_renamed_dir(self):
self.tf.add_file('tests/', 'tests_renamed/')
self.tf.close()
- self.check_for_file('test/tests_renamed/worker.py')
+ self.check_for_file('test/tests_renamed/ziptest')
def test_add_string(self):
self.tf.add_string('this is content', 'tests/string_test.txt')
diff --git a/tests/worker.py b/tests/worker.py
deleted file mode 100644
index cf121f38..00000000
--- a/tests/worker.py
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/usr/bin/env python
-
-import unittest
-import pexpect
-
-from re import search, escape
-from os import kill
-from signal import SIGINT, SIGUSR1
-
-class WorkerTests(unittest.TestCase):
-
- __exec_echo_lol_output__ = '0\r\n4\r\nlol\r\n\r\n0\r\n\r\n'
-
- def prompt(self, n):
- return ('#%i#\r\n' % n)
-
- def interrupted(self, n):
- return ('#%i# INTERRUPTED\r\n' % n)
-
- def setUp(self):
- self.worker = pexpect.spawn('python ../worker/worker.py')
- # worker should always be very fast to span
- self.expect(self.prompt(0))
-
- def sig(self, sig):
- kill(self.worker.pid, sig)
-
- def lose_expect(self, v, timeout = 3):
- self.worker.expect(v, timeout)
-
- def expect(self, v, timeout = 3):
- self.lose_expect(v, timeout)
- self.assertEqual(self.worker.before, '')
-
- def send(self, text):
- self.worker.send(text)
- self.expect(escape(text))
-
- def sendlines(self, lines):
- for line in lines:
- self.worker.send(line+'\n')
- for line in lines:
- self.expect(escape(line)+'\r\n')
-
- def __finishes_ok__(self):
- self.expect(pexpect.EOF)
- self.worker.close()
- self.assertEqual(self.worker.exitstatus, 0)
-
- def test_exit(self):
- self.sendlines(['exit'])
- self.__finishes_ok__()
-
- def test_ctrlc_when_running(self):
- self.sendlines(['exec', 'sleep 1; exec echo lol'])
- self.sig(SIGINT)
- self.expect(self.interrupted(0)+self.prompt(1))
- self.test_exit()
-
- def test_ctrlc_on_cmd_prompt(self):
- self.sig(SIGINT)
- self.expect(self.interrupted(0)+self.prompt(1))
- self.test_exit()
-
- def test_ctrlc_when_entering_command(self):
- # "Mon clavier se blo" -- French reference
- self.send('glo')
- self.sig(SIGINT)
- self.expect(self.interrupted(0)+self.prompt(1))
- self.test_exit()
-
- def test_ctrlc_on_readparms_drops(self):
- self.sendlines(['exec'])
- self.sig(SIGINT)
- self.expect(self.interrupted(0)+self.prompt(1))
- self.sendlines(['glob'])
- self.sig(SIGINT)
- self.expect(self.interrupted(1)+self.prompt(2))
- self.test_exit()
-
- def test_basic_noop(self):
- self.sendlines(['noop'])
- self.expect(self.prompt(1))
- self.test_exit()
-
- def test_basic_ping(self):
- self.sendlines(['ping'])
- self.expect('ALIVE\r\n' + self.prompt(1))
- self.test_exit()
-
- def test_basic_glob(self):
- self.sendlines(['glob', '/*bin'])
- self.expect('2\r\n(/bin\r\n/sbin|/sbin\r\n/bin)\r\n'+self.prompt(1))
- self.test_exit()
-
- def test_empty_glob(self):
- self.sendlines(['glob', '/?kyzh?'])
- self.expect('0\r\n'+self.prompt(1))
- self.test_exit()
-
- def test_basic_sigusr1(self):
- self.sig(SIGUSR1)
- self.expect('ALIVE\r\n')
- self.test_exit()
-
- def test_sigusr1_when_entering_command(self):
- self.worker.send('pin')
- self.sig(SIGUSR1)
- self.expect('pinALIVE\r\n')
- self.sendlines(['g'])
- self.expect('ALIVE\r\n' + self.prompt(1))
- self.test_exit()
-
- def test_sigusr1_on_readparms(self):
- self.worker.send('exec\nech')
- self.sig(SIGUSR1)
- self.worker.send('o lol\n')
- self.expect('exec\r\nechALIVE\r\no lol\r\n'+
- self.__exec_echo_lol_output__ + self.prompt(1))
- self.test_exit()
-
- def test_exec_continues_after_sigusr1(self):
- self.worker.send('exec\nsleep 0.1; exec echo lol\n')
- self.sig(SIGUSR1)
- self.expect('exec\r\nsleep 0.1; exec echo lol\r\nALIVE\r\n'+
- self.__exec_echo_lol_output__ + self.prompt(1))
- self.test_exit()
-
- def test_increasing_counter(self):
- for req_counter in range(1, 5):
- self.sendlines(['noop'])
- self.expect(self.prompt(req_counter))
- for req_counter in range(5, 10):
- self.sendlines(['ping'])
- self.expect('ALIVE\r\n'+self.prompt(req_counter))
- self.test_exit()
-
- def test_queuecommands(self):
- self.worker.send('ping\n'*5)
- self.worker.send('exec\necho lol\n'*5)
- for req_counter in range(1,6):
- self.lose_expect('ALIVE\r\n'+self.prompt(req_counter))
- for req_counter in range(6,11):
- self.lose_expect(self.__exec_echo_lol_output__+self.prompt(req_counter))
- self.test_exit()
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/worker_link b/tests/worker_link
deleted file mode 120000
index 20be81a3..00000000
--- a/tests/worker_link
+++ /dev/null
@@ -1 +0,0 @@
-worker.py \ No newline at end of file
diff --git a/tests/ziptest b/tests/ziptest
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/ziptest
diff --git a/tests/ziptest_link b/tests/ziptest_link
new file mode 120000
index 00000000..e99bb13c
--- /dev/null
+++ b/tests/ziptest_link
@@ -0,0 +1 @@
+ziptest \ No newline at end of file