Example #1
0
    def init_memory(self, path, arch, src_arch, config_file="", callback=None):
        """ If config_file == "", load default config
        Return -1 if configuration file does not exist or is not correct
        (argument or default)
        """
        if config_file != "":
            if not self.is_config_file_correct(config_file):
                return -1
        self.path = path
        self.arch = arch
        self.src_arch = src_arch

        self.config_file = config_file
        if config_file == "":
            self.config_file = self._get_default_config()
        if not os.path.isfile(self.config_file):
            # Config_file does not exist
            return -1

        utility.init_environ(self.path,
                             self.arch,
                             self.src_arch)

        if path[-1] != "/":
            path += "/"

        self.kconfig_infos = kconfiglib.Config(filename=path+"Kconfig",
                                               base_dir=path,
                                               print_warnings=False,
                                               callback=callback)

        self.kconfig_infos.load_config(self.config_file)

        self.top_level_items = self.kconfig_infos.get_top_level_items()
        self.menus = self.kconfig_infos.get_menus()
        self.top_menus = utility.get_top_menus(self.menus)
        self.sections = utility.get_top_menus(self.menus)
        self.items = []
        utility.get_all_items(self.top_level_items, self.items)
Example #2
0
"""

""" 
    Initialization of options to be tested 
    For instance, you can exec this script like this :
    python unit_tests.py /net/travail/jaupetit/linux-3.13.5
"""

if len(sys.argv) > 1:
    path = sys.argv[1]

    arch = "x86_64"
    srcarch = "x86"

    try:
        utility.init_environ(path, arch, srcarch)
        kconfig_infos = kconfiglib.Config(filename=path+"/Kconfig",
            base_dir=path, print_warnings=False)
    except Exception as e:
        sys.exit("Error -- Kernel's path : < " + path + " > is not correct")

    top_level_items = kconfig_infos.get_top_level_items()
    menus = kconfig_infos.get_menus()
    top_menus = utility.get_top_menus(menus)
    items = []
    utility.get_all_items(top_level_items, items)

else:
    sys.exit("Error -- Please give a kernel path in parameter")