1##########################################################################
2# Copyright (c) 2009, 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, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8##########################################################################
9
10# MAKEOPTS=-j12 ./scalebench.py -m xeon_phi_1 -B /mnt/local/" + machine.get_tftp_subdir() + "/barrelfish/build -t xeon_phi_spawn /mnt/local/" + machine.get_tftp_subdir() + "/barrelfish/ /mnt/local/" + machine.get_tftp_subdir() + "/harness-results/ -v
11
12
13import re, os, sys, debug, shutil, datetime
14
15import tests
16from common import TestCommon
17from barrelfish import BootModules
18from results import PassFailResult
19
20#module /" + machine.get_tftp_subdir() + "/x86_64/sbin/xeon_phi_mgr
21
22@tests.add_test
23class XeonPhi_Boot_Test(TestCommon):
24    '''Xeon Phi Spawn test'''
25    name = "xeon_phi_boot"
26    nphi = 2;
27
28    def set_xeon_phi_bootmodules(self, build_dir, machine):
29        fullpath = os.path.join(machine.get_tftp_dir(), 'menu.lst.k1om')
30        f = open(fullpath, 'w')
31
32        tftpdir = machine._operations.get_tftp_subdir()
33
34        f.write("title   Barrelfish \n")
35        f.write("root    (nd) \n")
36        f.write("kernel  /" + tftpdir + "/k1om/sbin/weever\n")
37        f.write("module  /" + tftpdir + "/k1om/sbin/cpu loglevel=3 \n")
38        f.write("module  /" + tftpdir + "/k1om/sbin/init\n")
39
40        # Domains spawned by init
41        f.write("module  /" + tftpdir + "/k1om/sbin/mem_serv\n")
42        f.write("module  /" + tftpdir + "/k1om/sbin/monitor\n")
43
44        # Special boot time domains spawned by monitor
45        f.write("module  /" + tftpdir + "/k1om/sbin/ramfsd boot \n")
46        f.write("module  /" + tftpdir + "/k1om/sbin/skb boot \n")
47        f.write("module  /" + tftpdir + "/k1om/sbin/xeon_phi boot \n")
48        f.write("module  /" + tftpdir + "/k1om/sbin/spawnd boot \n")
49        f.write("module  /" + tftpdir + "/k1om/sbin/startd boot \n")
50        f.write("module  /" + tftpdir + "/k1om/sbin/proc_mgmt boot \n")
51        # drivers
52        f.write("module  /" + tftpdir + "/k1om/sbin/corectrl auto \n")
53
54        # GDDR Memory we have 6GB on our Xeon PHi
55        f.write("mmap map 0x0000000000 0x00FEE00000 1 \n")
56        # memory hole for the APIC and the flash rom
57        f.write("mmap map 0x00FEE00000 0x120000 3 \n")
58        f.write("mmap map 0x0100000000 0x80000000 1 \n")
59        # put additional modules herei
60        f.write("\n")
61        f.close()
62
63
64    def setup(self, build, machine, testdir) :
65        super(XeonPhi_Boot_Test, self).setup(build, machine, testdir)
66
67        # setup menu.lst.k1om
68        menulst = os.path.join(machine.get_tftp_dir(), "menu.lst.k1om")
69        if (os.path.isfile(menulst)) :
70            os.remove(menulst)
71        self.set_xeon_phi_bootmodules(build.build_dir, machine)
72#        self.nphi = machine.get_xphi_ncards()
73
74
75    def get_build_targets(self, build, machine):
76        targets = super(XeonPhi_Boot_Test, self).get_build_targets(build, machine)
77        targets.append('k1om/sbin/weever')
78        targets.append('k1om/sbin/cpu')
79        targets.append('k1om/sbin/init')
80        targets.append('k1om/sbin/mem_serv')
81        targets.append('k1om/sbin/monitor')
82        targets.append('k1om/sbin/ramfsd')
83        targets.append('k1om/sbin/xeon_phi')
84        targets.append('k1om/sbin/spawnd')
85        targets.append("k1om/sbin/skb")
86        targets.append('k1om/sbin/startd')
87        targets.append('k1om/sbin/proc_mgmt')
88        targets.append('k1om/sbin/corectrl')
89        return targets
90
91
92
93
94    def cleanup(self, machine):
95        # remove the xeon phi image directory
96        menulst = os.path.join(machine.get_tftp_dir(), "menu.lst.k1om")
97        if (os.path.isfile(menulst)) :
98            os.remove(menulst)
99        super(XeonPhi_Boot_Test, self).cleanup(machine)
100
101    def get_modules(self, build, machine):
102        modules = super(XeonPhi_Boot_Test, self).get_modules(build, machine)
103        tftpdir = machine._operations.get_tftp_subdir()
104        modules.add_module("xeon_phi_mgr", [""])
105        modules.add_module("xeon_phi", ["auto",
106                                        "--tftp=tftp://10.110.4.4:69",
107                                        "--modlist=/" + tftpdir + "/menu.lst.k1om"])
108        modules.add_module("e1000n", ["auto"])
109        modules.add_module("net_sockets_server", ["nospawn"])
110        modules.add_module("dma_mgr", [""])
111
112        return modules
113
114    def get_finish_string(self):
115        return "Xeon Phi operational: xeon_phi." + str(self.nphi - 1) + ".ready"
116
117    def boot(self, *args):
118        super(XeonPhi_Boot_Test, self).boot(*args)
119#        self.set_timeout(NFS_TIMEOUT)
120
121    def process_data(self, testdir, rawiter):
122        # the test passed iff the last line is the finish string
123        print "PROCESS DATA"
124        passed=False
125        for line in rawiter:
126            m = re.search("Xeon Phi operational: xeon_phi." + str(self.nphi - 1) + ".ready", line)
127            if m:
128                passed=True
129
130        return PassFailResult(passed)
131