forked from HUST-OS/xv6-k210
-
Notifications
You must be signed in to change notification settings - Fork 20
/
tester.py
35 lines (26 loc) · 849 Bytes
/
tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
import pexpect
import sys
class QemuTest(unittest.TestCase):
def setUp(self):
self.p = pexpect.spawn("make run platform=qemu")
self.p.delaybeforesend = None
#self.p.logfile = sys.stdout.buffer
self.p.ignorecase = True
def tearDown(self):
self.p.terminate()
class BehaviorTest(QemuTest):
def test_getpid(self):
self.p.expect('-> / \$ ', timeout=3)
self.p.sendline('getpid')
self.p.expect('getpid success.')
self.p.expect(r'pid = (\d+)')
pid = int(self.p.match.group(1))
self.assertTrue(pid > 2)
class StringTest(unittest.TestCase):
def test_upper(self):
self.assertEqual("foo".upper(), "FOO")
def test_lower(self):
self.assertEqual("foo".upper(), "FOO")
if __name__ == "__main__":
unittest.main()