def __test_variable_width(self): """ Test variable width. """ if self.verbose: print("Running __test_variable_width()...") models = CrcModels() m = models.getParams("crc-64-jones") for width in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 23, 24, 25, 31, 32, 33, 63, 64]: mask = (1 << width) - 1 mw = { 'width': width, 'poly': m['poly'] & mask, 'reflect_in': m['reflect_in'], 'xor_in': m['xor_in'] & mask, 'reflect_out': m['reflect_out'], 'xor_out': m['xor_out'] & mask, } args = "--width %(width)s --poly 0x%(poly)x --xor-in 0x%(xor_in)x --reflect-in %(reflect_in)s --xor-out 0x%(xor_out)x --reflect-out %(reflect_out)s" % mw check = self.__get_crc(mw) if check is None: return False if self.use_algo_bit_by_bit: if self.crc_bin_bbb_c99 is not None: if not self.__check_command(self.crc_bin_bbb_c99 + " " + args, check): return False if not self.__compile_and_check_res("--algorithm bit-by-bit" + " " + args, None, "crc_bbb_arg", check): return False if self.use_algo_bit_by_bit_fast: if self.crc_bin_bbf_c99 is not None: if not self.__check_command(self.crc_bin_bbf_c99 + " " + args, check): return False if not self.__compile_and_check_res("--algorithm bit-by-bit-fast" + " " + args, None, "crc_bbf_arg", check): return False if self.use_algo_bitwise_expression: if self.crc_bin_bwe_c99 is not None: if not self.__check_command(self.crc_bin_bwe_c99 + " " + args, check): return False if not self.__compile_and_check_res("--algorithm bitwise-expression" + " " + args, None, "crc_bwe_arg", check): return False if self.use_algo_table_driven: if self.crc_bin_tbl_c99 is not None: if not self.__check_command(self.crc_bin_tbl_c99 + " " + args, check): return False if not self.__compile_and_check_res("--algorithm table-driven" + " " + args, None, "crc_tbl_arg", check): return False return True
def model_cb(self, option, opt_str, value, parser): """ This function sets up the single parameters if the 'model' option has been selected by the user. """ model_name = value.lower() models = CrcModels() model = models.getParams(model_name) if model != None: setattr(parser.values, 'width', model['width']) setattr(parser.values, 'poly', model['poly']) setattr(parser.values, 'reflect_in', model['reflect_in']) setattr(parser.values, 'xor_in', model['xor_in']) setattr(parser.values, 'reflect_out', model['reflect_out']) setattr(parser.values, 'xor_out', model['xor_out']) else: raise OptionValueError("Error: unsupported model %s" % (value))
def model_cb(self, option, opt_str, value, parser): """ This function sets up the single parameters if the 'model' option has been selected by the user. """ model_name = value.lower() models = CrcModels() model = models.getParams(model_name) if model != None: setattr(parser.values, "width", model["width"]) setattr(parser.values, "poly", model["poly"]) setattr(parser.values, "reflect_in", model["reflect_in"]) setattr(parser.values, "xor_in", model["xor_in"]) setattr(parser.values, "reflect_out", model["reflect_out"]) setattr(parser.values, "xor_out", model["xor_out"]) else: models = CrcModels() model_list = ", ".join(models.getList()) raise OptionValueError("unsupported model %s. Supported models are: %s." % (value, model_list))
def __test_variable_width(self): """ Test variable width. """ if self.verbose: print("Running __test_variable_width()...") models = CrcModels() m = models.getParams("crc-64-jones") for width in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 23, 24, 25, 31, 32, 33, 63, 64 ]: mask = (1 << width) - 1 mw = { 'width': width, 'poly': m['poly'] & mask, 'reflect_in': m['reflect_in'], 'xor_in': m['xor_in'] & mask, 'reflect_out': m['reflect_out'], 'xor_out': m['xor_out'] & mask, } args = "--width %(width)s --poly 0x%(poly)x --xor-in 0x%(xor_in)x --reflect-in %(reflect_in)s --xor-out 0x%(xor_out)x --reflect-out %(reflect_out)s" % mw check = self.__get_crc(mw) if check == None: return False if self.use_algo_bit_by_bit: if self.crc_bin_bbb_c99 != None: if not self.__check_command( self.crc_bin_bbb_c99 + " " + args, check): return False filename = self.__make_bin( "--algorithm bit-by-bit" + " " + args, "crc_bbb_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename + ".h", filename + ".c"]) if not ret: return False if self.use_algo_bit_by_bit_fast: if self.crc_bin_bbf_c99 != None: if not self.__check_command( self.crc_bin_bbf_c99 + " " + args, check): return False filename = self.__make_bin( "--algorithm bit-by-bit-fast" + " " + args, "crc_bbf_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename + ".h", filename + ".c"]) if not ret: return False if self.use_algo_bitwise_expression: if self.crc_bin_bwe_c99 != None: if not self.__check_command( self.crc_bin_bwe_c99 + " " + args, check): return False filename = self.__make_bin( "--algorithm bitwise-expression" + " " + args, "crc_bwe_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename + ".h", filename + ".c"]) if not ret: return False if self.use_algo_table_driven: if self.crc_bin_tbl_c99 != None: if not self.__check_command( self.crc_bin_tbl_c99 + " " + args, check): return False filename = self.__make_bin( "--algorithm table-driven" + " " + args, "crc_tbl_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename + ".h", filename + ".c"]) if not ret: return False return True
def __test_variable_width(self): """ Test variable width. """ if self.verbose: print("Running __test_variable_width()...") models = CrcModels() m = models.getParams("crc-64-jones") for width in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 23, 24, 25, 31, 32, 33, 63, 64]: mask = (1 << width) - 1 mw = { 'width': width, 'poly': m['poly'] & mask, 'reflect_in': m['reflect_in'], 'xor_in': m['xor_in'] & mask, 'reflect_out': m['reflect_out'], 'xor_out': m['xor_out'] & mask, } args = "--width %(width)s --poly 0x%(poly)x --xor-in 0x%(xor_in)x --reflect-in %(reflect_in)s --xor-out 0x%(xor_out)x --reflect-out %(reflect_out)s" % mw check = self.__get_crc(mw) if check == None: return False if self.use_algo_bit_by_bit: if self.crc_bin_bbb_c99 != None: if not self.__check_command(self.crc_bin_bbb_c99 + " " + args, check): return False filename = self.__make_bin("--algorithm table-driven" + " " + args, "crc_bbb_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename+".h", filename+".c"]) if not ret: return False if self.use_algo_bit_by_bit_fast: if self.crc_bin_bbf_c99 != None: if not self.__check_command(self.crc_bin_bbf_c99 + " " + args, check): return False filename = self.__make_bin("--algorithm table-driven" + " " + args, "crc_bbf_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename+".h", filename+".c"]) if not ret: return False if self.use_algo_table_driven: if self.crc_bin_tbl_c99 != None: if not self.__check_command(self.crc_bin_tbl_c99 + " " + args, check): return False filename = self.__make_bin("--algorithm table-driven" + " " + args, "crc_tbl_arg") if filename == None: return False ret = self.__check_command(filename, check) self.__del_files([filename, filename+".h", filename+".c"]) if not ret: return False return True