Beispiel #1
0
    def setup(self, **kwargs):
        # DevDax tests always require ndctl
        req.Requirements().check_ndctl_enable()
        req.Requirements().check_ndctl()

        tools = kwargs['tools']
        for dd in self.dax_devices:
            proc = tools.pmemdetect('-d', dd.path)
            if proc.returncode != 0:
                raise futils.Fail(
                    'checking {} with pmemdetect failed:{}{}'.format(
                        dd.path, os.linesep, proc.stdout))
Beispiel #2
0
    def get_contexts(self):
        """
        Generate a list of contexts based on configuration and
        test requirements
        """
        reqs = req.Requirements()
        if not reqs.check_if_all_requirements_are_met(self.tc):
            return []
        conf_params = self._get_configured_params()
        common_params = self._get_common_params()
        ctx_elem_names = list(conf_params.keys()) + list(common_params.keys())

        builds = self._get_builds()

        # Generate cartesian product of builds and context elements.
        # Each element of the product serves as a base for the separate
        # context in which the test is run
        ctx_params = itertools.product(builds, *conf_params.values(),
                                       *common_params.values())
        ctxs = []
        for cp in ctx_params:
            build = cp[0]

            ctx_elems = dict(zip(ctx_elem_names, cp[1:]))
            c = ctx.Context(build, **ctx_elems)
            c.cwd = self.tc.cwd
            ctxs.append(c)

        return ctxs
Beispiel #3
0
    def get_contexts(self):
        """
        Generate a list of context based on configuration and
        test requirements
        """
        reqs = req.Requirements()
        if not reqs.check_if_all_requirements_are_met(self.tc):
            return []
        conf_params = self._get_configured_params()
        common_params = self._get_common_params()
        ctx_arg_keys = list(conf_params.keys()) + list(common_params.keys())

        builds = self._get_builds()

        ctx_params = itertools.product(builds, *conf_params.values(),
                                       *common_params.values())
        ctxs = []
        for cp in ctx_params:
            build = cp[0]

            kwargs = dict(zip(ctx_arg_keys, cp[1:]))
            c = ctx.Context(build, **kwargs)
            c.cwd = self.tc.cwd
            ctxs.append(c)
        return ctxs
Beispiel #4
0
    def setup(self, **kwargs):
        # DevDax tests always require ndctl
        req.Requirements().check_ndctl_enable()
        req.Requirements().check_ndctl()

        tools = kwargs['tools']
        for dd in self.dax_devices:
            proc = tools.pmemdetect('-d', dd.path)
            if proc.returncode != 0:
                raise futils.Fail('checking {} with pmemdetect failed:{}{}'
                                  .format(dd.path, os.linesep, proc.stdout))

            if self.check_fs_exec:
                exec_allowed = tools.mapexec(dd.path)
                if exec_allowed.returncode != 1:
                    raise futils.Skip('dax device {} has no exec rights for'
                                      ' mmap'.format(dd.path))
Beispiel #5
0
    def setup(self):
        self.req = requirements.Requirements()

        # load starting JSON file that declares which rooms the game will use
        file_setup = open(os.path.join(self.JSON, "setup.json"), "r")
        if self.DEBUG:
            print("* setup.json opened")
        data_setup = json.load(file_setup)
        file_setup.close()
        if self.DEBUG:
            print("* setup.json closed")

        data_rooms = {}

        # create all of the rooms
        for room_name in data_setup["rooms"]:
            # open file for each room and get the data from it
            file_room = open(os.path.join(self.JSON, (room_name + ".json")),
                             "r")
            if self.DEBUG:
                print("* {}.json opened".format(room_name))
            data_rooms[room_name] = json.load(file_room)
            file_room.close()
            if self.DEBUG:
                print("* {}.json closed".format(room_name))

            if self.DEBUG:
                print("-creating room " + room_name)
            # create a room, ready to have views added to it
            self.rooms[room_name] = {}

            for view_name in data_rooms[room_name]:
                # create a room, ready to have rooms added to it
                if self.DEBUG:
                    print("    -creating view {}".format(view_name))
                view_path = os.path.join(self.GRAPHICS, room_name, view_name)
                self.rooms[room_name][view_name] = {
                    'id': data_rooms[room_name][view_name]['id'],
                    'view': view.View(view_path, 'bg.png')
                }

                # get data for the view
                data_view = data_rooms[room_name][view_name]
                objects = {}
                editor_queue = [
                ]  # get all currently set up objects before editing new objects
                for obj_name in data_view["objects"].keys():
                    # declare objects
                    obj = data_view["objects"][obj_name]
                    obj_name = room_name + "_" + view_name + "_" + obj_name
                    obj_path = os.path.join(self.GRAPHICS, room_name,
                                            view_name)
                    try:
                        # object is already set up in json file
                        self.create_object(objects, room_name, view_name,
                                           obj_name, obj_path, obj)
                        self.setup_object(objects, room_name, view_name,
                                          obj_name, obj_path, obj)
                    except KeyError:  # something in the object is not set up
                        # launch the editor
                        if self.DEBUG:
                            print('        # {} added to editor queue'.format(
                                obj_name))
                            editor_queue.append(obj_name)
                        else:
                            print("Error: {} has not been set up.".format(
                                obj_name))
                            print("Remove the objects from {}.json or set it".
                                  format(room_name))
                            print("up by setting self.DEBUG = True")
                            sys.exit()
                            pygame.quit()
                if self.DEBUG:
                    print("    ! done creating objects in view {}".format(
                        view_name))
                # open editor to create objects that need to be created
                for obj_name in editor_queue:
                    self.editor(data_rooms, room_name, view_name, obj_name,
                                objects)
                    #sys.exit()
                    #pygame.quit()
                    if self.DEBUG:
                        print("        -creating object {}".format(obj_name))
                    obj_path = os.path.join(self.GRAPHICS, room_name,
                                            view_name)
                    # reload the file and grab the object just edited
                    file_room = open(
                        os.path.join(self.JSON, (room_name + ".json")), "r")
                    if self.DEBUG:
                        print("* {}.json opened".format(room_name))
                    data_rooms[room_name] = json.load(file_room)
                    file_room.close()
                    if self.DEBUG:
                        print("* {}.json closed".format(room_name))
                    # create the object
                    obj = data_rooms[room_name][view_name]["objects"][obj_name]
                    self.create_object(objects, room_name, view_name, obj_name,
                                       obj_path, obj)
                    self.setup_object(objects, room_name, view_name, obj_name,
                                      obj_path, obj)
                self.rooms[room_name][view_name]['view'].objects = objects

        # construct rooms and set starting room
        self.cur_room = data_setup['start_room']
        self.cur_view = data_setup['start_view']