Loading testing/asn_process.py +42 −7 Original line number Diff line number Diff line Loading @@ -10,6 +10,24 @@ from pycrate_asn1c.asnproc import * import lint_asn1 def reconstrainInteger (filename): Path('temp.asn').write_text(Path(filename).read_text().replace("18446744073709551615", "65536")) return 'temp.asn' filesWithBigInts = [ '102232-1/LI-PS-PDU.asn', '102232-3/IPAccessPDU.asn', '102232-4/L2AccessPDU.asn' ] asn1c_path = "" change_path_to_unix = False def fix_path(path): if change_path_to_unix: return "./" + path.replace("\\","/") else: return path def syntaxCheckASN(fileList): """ Loading @@ -24,20 +42,37 @@ def syntaxCheckASN(fileList): results = {} for file in fileList: try: p = run(["asn1c", "-E", str(file)], capture_output=True) if p.returncode != 0: if file.as_posix() in filesWithBigInts: newFile = reconstrainInteger(str(file)) p = run([asn1c_path, '-E', fix_path(newFile)], capture_output=True) Path(newFile).unlink() else: p = run([asn1c_path, '-E', fix_path(str(file))], capture_output=True) if (p.returncode != 0): errorMessage = p.stderr.decode().splitlines()[0] if errorMessage.startswith(' Value "18446744073709551615" at line'): results[str(file)] = { 'ok' : True} continue results[str(file)] = { "ok": False, "code": p.returncode, "message": p.stderr.decode().splitlines()[0], 'ok' : False, 'code' : p.returncode, 'message' : p.stderr.decode().splitlines()[0] } else: results[str(file)] = {"ok": True} results[str(file)] = { 'ok' : True } except Exception as ex: results[str(file)] = {"ok": False, "code": -1, "message": f"{ex.__class__.__qualname__}: {ex}"} raise ex results[str(file)] = { 'ok' : False, 'code' : -1, 'message' : f"{ex!r}" } return results def compileAllTargets(compileTargets): """ Attempts to compile a set of compile targets using the pycrate ASN1 tools Loading Loading
testing/asn_process.py +42 −7 Original line number Diff line number Diff line Loading @@ -10,6 +10,24 @@ from pycrate_asn1c.asnproc import * import lint_asn1 def reconstrainInteger (filename): Path('temp.asn').write_text(Path(filename).read_text().replace("18446744073709551615", "65536")) return 'temp.asn' filesWithBigInts = [ '102232-1/LI-PS-PDU.asn', '102232-3/IPAccessPDU.asn', '102232-4/L2AccessPDU.asn' ] asn1c_path = "" change_path_to_unix = False def fix_path(path): if change_path_to_unix: return "./" + path.replace("\\","/") else: return path def syntaxCheckASN(fileList): """ Loading @@ -24,20 +42,37 @@ def syntaxCheckASN(fileList): results = {} for file in fileList: try: p = run(["asn1c", "-E", str(file)], capture_output=True) if p.returncode != 0: if file.as_posix() in filesWithBigInts: newFile = reconstrainInteger(str(file)) p = run([asn1c_path, '-E', fix_path(newFile)], capture_output=True) Path(newFile).unlink() else: p = run([asn1c_path, '-E', fix_path(str(file))], capture_output=True) if (p.returncode != 0): errorMessage = p.stderr.decode().splitlines()[0] if errorMessage.startswith(' Value "18446744073709551615" at line'): results[str(file)] = { 'ok' : True} continue results[str(file)] = { "ok": False, "code": p.returncode, "message": p.stderr.decode().splitlines()[0], 'ok' : False, 'code' : p.returncode, 'message' : p.stderr.decode().splitlines()[0] } else: results[str(file)] = {"ok": True} results[str(file)] = { 'ok' : True } except Exception as ex: results[str(file)] = {"ok": False, "code": -1, "message": f"{ex.__class__.__qualname__}: {ex}"} raise ex results[str(file)] = { 'ok' : False, 'code' : -1, 'message' : f"{ex!r}" } return results def compileAllTargets(compileTargets): """ Attempts to compile a set of compile targets using the pycrate ASN1 tools Loading