diff --git a/services/pddb/src/backend/basis.rs b/services/pddb/src/backend/basis.rs index 743d5e15d..563836e48 100644 --- a/services/pddb/src/backend/basis.rs +++ b/services/pddb/src/backend/basis.rs @@ -828,10 +828,10 @@ impl BasisCache { /// similar to how you might use fdisk to create a partition, but you still must call mount to access it. pub(crate) fn basis_create(&mut self, hw: &mut PddbOs, name: &str, password: &str) -> Result<()> { if !hw.fast_space_ensure_next_log() { - return Err(Error::new(ErrorKind::OutOfMemory, "no free space to create basis")); + return Err(Error::new(ErrorKind::OutOfMemory, "No free space to create basis")); }; if !hw.ensure_fast_space_alloc(1, &self.cache) { - return Err(Error::new(ErrorKind::OutOfMemory, "no free space to create basis")); + return Err(Error::new(ErrorKind::OutOfMemory, "No free space to create basis")); }; let basis_key = hw.basis_derive_key(name, password); diff --git a/tools/pddbci.py b/tools/pddbci.py new file mode 100644 index 000000000..9608c8121 --- /dev/null +++ b/tools/pddbci.py @@ -0,0 +1,119 @@ +#! /usr/bin/env python3 +import argparse +import os +import logging +import subprocess +import time +import signal + +def main(): + parser = argparse.ArgumentParser(description="Regression tester for PDDB") + parser.add_argument( + "--name", required=True, help="pddb disk image root name", type=str, nargs='?', metavar=('name'), const='./pddb' + ) + parser.add_argument( + "--loglevel", required=False, help="set logging level (INFO/DEBUG/WARNING/ERROR)", type=str, default="INFO", + ) + args = parser.parse_args() + + numeric_level = getattr(logging, args.loglevel.upper(), None) + if not isinstance(numeric_level, int): + raise ValueError('Invalid log level: %s' % args.loglevel) + logging.basicConfig(level=numeric_level) + + pass_log = {} + err_log = [] + for seed in range(0, 51): + err_log.append("Starting seed {}".format(seed)) + seed_env = os.environ + seed_env["XOUS_SEED"] = str(seed) + # result = subprocess.run(['tools/pddbdbg.py', '--name', 'patterne'], env=seed_env, capture_output=True, text=True, universal_newlines=True) + #result = subprocess.run(['cargo', 'xtask', 'run'], env=seed_env, capture_output=True, text=True, universal_newlines=True) + #for line in result.stdout.split('\n'): + # if 'Seed' in line: + # logging.info(line) + + start_time = time.time() + passing = True + proc = subprocess.Popen( + ['cargo', 'xtask', 'run'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + #shell=True, + encoding='utf-8', + errors='replace' + ) + while True: + realtime_output = proc.stdout.readline() + if (realtime_output == '' and proc.poll() is not None) or (time.time() - start_time > 20): + proc.kill() + if time.time() - start_time > 20: + logging.debug("timeout on generation") + passing = False + break + if realtime_output: + if 'Seed' in realtime_output: + logging.info(realtime_output.strip()) # flush=True for print version + if 'CI done' in realtime_output: + logging.info(realtime_output.strip()) + proc.kill() + if 'out of disk space' in realtime_output: + err_log.append(realtime_output) + logging.debug("ran out of space") + passing = False + proc.kill() + if 'No free space' in realtime_output: + err_log.append(realtime_output) + logging.debug("ran out of space") + passing = False + proc.kill() + if 'Decryption auth error' in realtime_output: + err_log.append(realtime_output) + logging.debug("decryption auth error") + passing = False + proc.kill() + + proc = subprocess.Popen( + ['python', './tools/pddbdbg.py', '--name', args.name], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding='utf-8', + errors='replace' + ) + while True: + realtime_output = proc.stdout.readline() + if (realtime_output == '' and proc.poll() is not None) or (time.time() - start_time > 45): + if time.time() - start_time > 45: + passing = False + logging.debug("analysis timed out") + proc.kill() + break + if realtime_output: + if 'ERROR' in realtime_output: + logging.info(realtime_output.strip()) + err_log.append(realtime_output) + logging.debug("output contained errors") + passing = False + if 'WARNING' in realtime_output: + logging.info(realtime_output.strip()) + err_log.append(realtime_output) + logging.debug("output contained warnings") + passing = False + + if passing: + logging.info("Seed {} PASS".format(seed)) + pass_log[seed] = 'PASS' + else: + logging.info("Seed {} FAIL".format(seed)) + pass_log[seed] = 'FAIL' + + for line in err_log: + logging.info(line) + + for items in pass_log.items(): + logging.info(items) + + +if __name__ == "__main__": + main() + exit(0) diff --git a/tools/pddbdbg.py b/tools/pddbdbg.py index f3881ef68..23fdaf623 100755 --- a/tools/pddbdbg.py +++ b/tools/pddbdbg.py @@ -106,7 +106,7 @@ def main(): "--name", required=False, help="pddb disk image root name", type=str, nargs='?', metavar=('name'), const='./pddb' ) parser.add_argument( - "--loglevel", required=False, help="set logging level", type=str, default="INFO", + "--loglevel", required=False, help="set logging level (INFO/DEBUG/WARNING/ERROR)", type=str, default="INFO", ) args = parser.parse_args()