Merge pull request #133675 from Ma27/test-driver-compat

nixos/test-driver: minor fixes for `nixos-build-vms(8)`
This commit is contained in:
Maximilian Bosch 2021-08-16 14:07:01 +02:00 committed by GitHub
commit 0362d572b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -1029,10 +1029,11 @@ if __name__ == "__main__":
args = arg_parser.parse_args()
global test_script
testscript = pathlib.Path(args.testscript).read_text()
def test_script() -> None:
with log.nested("running the VM test script"):
exec(pathlib.Path(args.testscript).read_text(), globals())
exec(testscript, globals())
log = Logger()
@ -1061,7 +1062,8 @@ if __name__ == "__main__":
process.terminate()
log.close()
interactive = args.interactive or (not bool(testscript))
tic = time.time()
run_tests(args.interactive)
run_tests(interactive)
toc = time.time()
print("test script finished in {:.2f}s".format(toc - tic))

View file

@ -186,6 +186,14 @@ rec {
--set startScripts "''${vmStartScripts[*]}" \
--set testScript "$out/test-script" \
--set vlans '${toString vlans}'
${lib.optionalString (testScript == "") ''
ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-run-vms
wrapProgram $out/bin/nixos-run-vms \
--set startScripts "''${vmStartScripts[*]}" \
--set testScript "${pkgs.writeText "start-all" "start_all(); join_all();"}" \
--set vlans '${toString vlans}'
''}
'');
# Make a full-blown test