1##########################################################################
2# Copyright (c) 2009, 2010, 2011, ETH Zurich.
3# All rights reserved.
4#
5# This file is distributed under the terms in the attached LICENSE file.
6# If you do not find this file, copies can be found by writing to:
7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8##########################################################################
9
10import socket, datetime
11import tests, siteconfig
12from common import TestCommon
13from results import PassFailResult
14
15NFS_TIMEOUT = datetime.timedelta(minutes=5)
16
17@tests.add_test
18class NFSTest(TestCommon):
19    '''NFS benchmark'''
20    name = "nfscat"
21
22    def get_modules(self, build, machine):
23        cardName = "e1000"
24        modules = super(NFSTest, self).get_modules(build, machine)
25        modules.add_module("e1000n", ["auto"])
26        modules.add_module("net_sockets_server", ["nospawn"])
27        nfsip = socket.gethostbyname(siteconfig.get('WEBSERVER_NFS_HOST'))
28        nfspath = siteconfig.get('WEBSERVER_1G_PATH')
29        nfsfile = siteconfig.get('WEBSERVER_1G_FILE')
30
31        modules.add_module("netthroughput",
32                ["core=%d" % machine.get_coreids()[2], "nfs://" + nfsip +
33                          nfspath , "/nfs/" + nfsfile])
34        return modules
35
36    def get_finish_string(self):
37        return "## Data size ="
38
39    def boot(self, *args):
40        super(NFSTest, self).boot(*args)
41        self.set_timeout(NFS_TIMEOUT)
42
43    def process_data(self, testdir, rawiter):
44        # the test passed iff the last line is the finish string
45        lastline = ''
46        for line in rawiter:
47            lastline = line
48        passed = lastline.startswith(self.get_finish_string())
49        return PassFailResult(passed)
50
51@tests.add_test
52class NFSTestE10k(NFSTest):
53    '''NFS benchmark'''
54    name = "nfscat_e10k"
55
56    def get_modules(self, build, machine):
57        modules = super(NFSTest, self).get_modules(build, machine)
58        modules.add_module("e10k", ["auto"])
59        modules.add_module("net_sockets_server", ["nospawn"])
60        nfsip = socket.gethostbyname(siteconfig.get('WEBSERVER_NFS_HOST'))
61        nfspath = siteconfig.get('WEBSERVER_1G_PATH')
62        nfsfile = siteconfig.get('WEBSERVER_1G_FILE')
63
64        modules.add_module("netthroughput",
65                ["core=%d" % machine.get_coreids()[2], "nfs://" + nfsip +
66                          nfspath , "/nfs/" + nfsfile])
67        return modules
68
69@tests.add_test
70class NFSTestSf(NFSTest):
71    '''NFS benchmark'''
72    name = "nfscat_sf"
73
74    def get_modules(self, build, machine):
75        modules = super(NFSTest, self).get_modules(build, machine)
76        modules.add_module("sfn5122f", ["auto"])
77        modules.add_module("net_sockets_server", ["nospawn"])
78        nfsip = socket.gethostbyname(siteconfig.get('WEBSERVER_NFS_HOST'))
79        nfspath = siteconfig.get('WEBSERVER_1G_PATH')
80        nfsfile = siteconfig.get('WEBSERVER_1G_FILE')
81
82        modules.add_module("netthroughput",
83                ["core=%d" % machine.get_coreids()[2], "nfs://" + nfsip +
84                          nfspath , "/nfs/" + nfsfile])
85        return modules
86