From 05f1c4dbb5a12470882fe99b43cd5bf3a1087faa Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Sat, 19 Nov 2022 23:49:43 +0100 Subject: [PATCH] Add integration tests Tests if repository json files conform to the json schema. If all resources (images/icons/website URLs) they mention actually exists. And can also test writing images and the FAT modification code. --- doc/json-schema/os-list-schema.json | 2 - src/cli.cpp | 85 ++++++++++++++++++++++++++- src/imagewriter.cpp | 17 +++++- src/imagewriter.h | 4 ++ tests/README.md | 30 ++++++++++ tests/cache/.gitignore | 1 + tests/conftest.py | 90 +++++++++++++++++++++++++++++ tests/test_firstrun.txt | 5 ++ tests/test_schema.py | 28 +++++++++ tests/test_urls.py | 25 ++++++++ tests/test_write_images.py | 40 +++++++++++++ 11 files changed, 319 insertions(+), 8 deletions(-) create mode 100644 tests/README.md create mode 100644 tests/cache/.gitignore create mode 100644 tests/conftest.py create mode 100644 tests/test_firstrun.txt create mode 100644 tests/test_schema.py create mode 100644 tests/test_urls.py create mode 100644 tests/test_write_images.py diff --git a/doc/json-schema/os-list-schema.json b/doc/json-schema/os-list-schema.json index 6829918..4bd017a 100644 --- a/doc/json-schema/os-list-schema.json +++ b/doc/json-schema/os-list-schema.json @@ -329,7 +329,6 @@ "required": [ "name", "description", - "icon", "subitems_url" ], "properties": { @@ -415,7 +414,6 @@ "required": [ "name", "description", - "icon", "subitems" ], "properties": { diff --git a/src/cli.cpp b/src/cli.cpp index 7a26f83..97f00e8 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -57,6 +57,15 @@ int Cli::main() parser.addOption(writeSystemDrive); QCommandLineOption sha256Option("sha256", "Expected hash", "sha256", ""); parser.addOption(sha256Option); + QCommandLineOption cacheFileOption("cache-file", "Custom cache file (requires setting sha256 as well)", "cache-file", ""); + parser.addOption(cacheFileOption); + QCommandLineOption firstRunScriptOption("first-run-script", "Add firstrun.sh to image", "first-run-script", ""); + parser.addOption(firstRunScriptOption); + QCommandLineOption userdataOption("cloudinit-userdata", "Add cloud-init user-data file to image", "cloudinit-userdata", ""); + parser.addOption(userdataOption); + QCommandLineOption networkconfigOption("cloudinit-networkconfig", "Add cloud-init network-config file to image", "cloudinit-networkconfig", ""); + parser.addOption(networkconfigOption); + QCommandLineOption debugOption("debug", "Output debug messages to console"); parser.addOption(debugOption); QCommandLineOption quietOption("quiet", "Only write to console on error"); @@ -69,7 +78,7 @@ int Cli::main() const QStringList args = parser.positionalArguments(); if (args.count() != 2) { - std::cerr << "Usage: --cli [--disable-verify] [--sha256 ] [--debug] [--quiet] " << std::endl; + std::cerr << "Usage: --cli [--disable-verify] [--sha256 [--cache-file ]] [--first-run-script