add a multi-iteration CI loop around the pddb test

this allows us to capture seeds and corners of interest
This commit is contained in:
bunnie 2021-12-27 16:15:51 +08:00
parent 4f7372bbd4
commit 713c0d6e73
3 changed files with 122 additions and 3 deletions

View file

@ -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);

119
tools/pddbci.py Normal file
View file

@ -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)

View file

@ -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()