1
2
3import os
4import tests
5from common import TestCommon
6from barrelfish import BootModules
7from results import PassFailResult
8
9@tests.add_test
10class 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("e1000n", ["auto"])
30        modules.add_module("net_sockets_server", ["auto"])
31        modules.add_module("tests/tftpclient",
32                ['--server=tftp://10.110.4.4:69',
33                 '--file=/%s/hello.txt' % tftpdir ])
34        return modules
35
36    def get_finish_string(self):
37        return 'TFTP TEST DONE.'
38
39    def process_data(self, testdir, rawiter):
40        passed = False
41        for line in rawiter:
42            if self._filecontents in line:
43                passed = True
44
45        return PassFailResult(passed)
46