Loading testing/asn_process.py +23 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ import logging import json from pathlib import Path from subprocess import run from re import sub from shutil import which from pycrate_asn1c.asnproc import * Loading @@ -16,6 +16,15 @@ filesWithBigInts = [ '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): """ Performs ASN syntax checking on a list of filenames (or pathlib Paths) Loading @@ -31,10 +40,10 @@ def syntaxCheckASN (fileList): try: if file.as_posix() in filesWithBigInts: newFile = reconstrainInteger(str(file)) p = run(['asn1c', '-E', newFile], capture_output=True) p = run([asn1c_path, '-E', fix_path(newFile)], capture_output=True) Path(newFile).unlink() else: p = run(['asn1c', '-E', str(file)], capture_output=True) 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'): Loading @@ -50,6 +59,7 @@ def syntaxCheckASN (fileList): 'ok' : True } except Exception as ex: raise ex results[str(file)] = { 'ok' : False, 'code' : -1, Loading Loading @@ -162,6 +172,16 @@ def processResults (results, stageName): if __name__ == '__main__': logging.info ('Searching for ASN1C') asn1c_path = which("asn1c") if asn1c_path is None: raise Exception ("No asn1c executable found. Please install asn1c") logging.info (f"asn1c found at {asn1c_path}") if asn1c_path.lower().endswith("bat"): logging.info (f"asn1c is a batch file, so assume path separators need to be changed") change_path_to_unix = True logging.info('Searching for ASN.1 files') fileList = list(Path(".").rglob("*.asn1")) + list(Path(".").rglob("*.asn")) logging.info(f'{len(fileList)} ASN.1 files found') Loading Loading
testing/asn_process.py +23 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ import logging import json from pathlib import Path from subprocess import run from re import sub from shutil import which from pycrate_asn1c.asnproc import * Loading @@ -16,6 +16,15 @@ filesWithBigInts = [ '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): """ Performs ASN syntax checking on a list of filenames (or pathlib Paths) Loading @@ -31,10 +40,10 @@ def syntaxCheckASN (fileList): try: if file.as_posix() in filesWithBigInts: newFile = reconstrainInteger(str(file)) p = run(['asn1c', '-E', newFile], capture_output=True) p = run([asn1c_path, '-E', fix_path(newFile)], capture_output=True) Path(newFile).unlink() else: p = run(['asn1c', '-E', str(file)], capture_output=True) 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'): Loading @@ -50,6 +59,7 @@ def syntaxCheckASN (fileList): 'ok' : True } except Exception as ex: raise ex results[str(file)] = { 'ok' : False, 'code' : -1, Loading Loading @@ -162,6 +172,16 @@ def processResults (results, stageName): if __name__ == '__main__': logging.info ('Searching for ASN1C') asn1c_path = which("asn1c") if asn1c_path is None: raise Exception ("No asn1c executable found. Please install asn1c") logging.info (f"asn1c found at {asn1c_path}") if asn1c_path.lower().endswith("bat"): logging.info (f"asn1c is a batch file, so assume path separators need to be changed") change_path_to_unix = True logging.info('Searching for ASN.1 files') fileList = list(Path(".").rglob("*.asn1")) + list(Path(".").rglob("*.asn")) logging.info(f'{len(fileList)} ASN.1 files found') Loading