f2123893b719e74033970407261f04c3edc081d0
[barrelfish] / tools / harness / tests / tftp.py
1
2
3 import os
4 import tests
5 from common import TestCommon
6 from barrelfish import BootModules
7 from results import PassFailResult
8
9 @tests.add_test
10 class TftpClientTest(TestCommon):
11     '''Barrelfish TFTP client test'''
12     name = "tftpclient"
13
14     _filename = "hello.txt"
15     _filecontents = "Hello world via TFTP!"
16
17     def setup_tftp_file(self, tftpdir):
18         with open(os.path.join(tftpdir, self._filename), 'w') as f:
19             f.write(self._filecontents)
20
21
22     def setup(self, build, machine, testdir):
23         super(TftpClientTest, self).setup(build, machine, testdir)
24         self.setup_tftp_file(machine.get_tftp_dir())
25
26     def get_modules(self, build, machine):
27         modules = super(TftpClientTest, self).get_modules(build, machine)
28         tftpdir = machine._operations.get_tftp_subdir()
29         modules.add_module("tests/tftpclient",
30                 ['--server=tftp://10.110.4.4:69',
31                  '--file=/%s/hello.txt' % tftpdir ])
32         modules.add_module("e1000_net_sockets_server", ["auto"])
33         return modules
34
35     def get_finish_string(self):
36         return 'TFTP TEST DONE.'
37
38     def process_data(self, testdir, rawiter):
39         passed = False
40         for line in rawiter:
41             if self._filecontents in line:
42                 passed = True
43
44         return PassFailResult(passed)