diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-10-15 13:25:38 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-10-15 13:25:38 -0500 |
commit | e9870d0b830deb0b253e5e514fc90ceee201a778 (patch) | |
tree | 244344085bdcd5ada2f187fc4579005caa51e409 /hscript | |
parent | f9850e766787d46bcae874fd4302cab0f0244e03 (diff) | |
download | horizon-e9870d0b830deb0b253e5e514fc90ceee201a778.tar.gz horizon-e9870d0b830deb0b253e5e514fc90ceee201a778.tar.bz2 horizon-e9870d0b830deb0b253e5e514fc90ceee201a778.tar.xz horizon-e9870d0b830deb0b253e5e514fc90ceee201a778.zip |
Add many more various test cases
Diffstat (limited to 'hscript')
-rw-r--r-- | hscript/disk.cc | 2 | ||||
-rw-r--r-- | hscript/meta.cc | 12 | ||||
-rw-r--r-- | hscript/network.cc | 2 | ||||
-rw-r--r-- | hscript/script_v.cc | 28 | ||||
-rw-r--r-- | hscript/user.cc | 2 |
5 files changed, 36 insertions, 10 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 0cc4c8f..446714e 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -272,9 +272,11 @@ bool Encrypt::validate() const { return true; } +/* LCOV_EXCL_START */ bool Encrypt::execute() const { return false; } +/* LCOV_EXCL_STOP */ /*! Parse a size string into a size and type. diff --git a/hscript/meta.cc b/hscript/meta.cc index 84e851a..12ed196 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -451,9 +451,11 @@ Key *Timezone::parseFromData(const std::string &data, const ScriptLocation &pos, } if(access("/usr/share/zoneinfo", X_OK) != 0) { + /* LCOV_EXCL_START */ if(warnings) *warnings += 1; output_warning(pos, "timezone: can't determine validity of timezone", "zoneinfo data is missing or inaccessible"); + /* LCOV_EXCL_STOP */ } else { std::string zi_path = "/usr/share/zoneinfo/" + data; if(access(zi_path.c_str(), F_OK) != 0) { @@ -642,9 +644,11 @@ Key *SvcEnable::parseFromData(const std::string &data, return new SvcEnable(script, pos, svc, runlevel); } +/* LCOV_EXCL_START */ bool SvcEnable::validate() const { return true; /* validation occurs during parsing */ } +/* LCOV_EXCL_STOP */ bool SvcEnable::execute() const { const std::string target = script->targetDirectory() + @@ -687,9 +691,11 @@ Key *Version::parseFromData(const std::string &data, return new Version(script, pos, data); } +/* LCOV_EXCL_START */ bool Version::execute() const { return true; } +/* LCOV_EXCL_STOP */ const std::string my_arch(const Horizon::Script *script) { @@ -785,8 +791,10 @@ bool Bootloader::validate() const { const static std::set<std::string> valid_arm64 = {"grub-efi"}; valid_selection = valid_arm64.find(candidate) != valid_arm64.end(); } else if(arch == "armv7") { + /* LCOV_EXCL_START - unreachable atm */ const static std::set<std::string> valid_arm = {}; valid_selection = valid_arm.find(candidate) != valid_arm.end(); + /* LCOV_EXCL_STOP */ } else if(arch == "pmmx") { const static std::set<std::string> valid_pmmx = {"grub-bios", "grub-efi"}; @@ -797,8 +805,10 @@ bool Bootloader::validate() const { valid_selection = valid_x86.find(candidate) != valid_x86.end(); } else if(arch == "mips64" || arch == "mips" || arch == "mips64el" || arch == "mipsel") { + /* LCOV_EXCL_START - unreachable atm */ const static std::set<std::string> valid_mips = {}; valid_selection = valid_mips.find(candidate) != valid_mips.end(); + /* LCOV_EXCL_STOP */ } else { output_error(pos, "bootloader: unknown architecture", arch); return false; @@ -879,10 +889,12 @@ bool Bootloader::execute() const { goto updateboot; #endif /* HAS_INSTALL_ENV */ } + /* LCOV_EXCL_START */ else if(method == "iquik") { output_error(pos, "bootloader: iQUIK is not yet supported"); return false; } + /* LCOV_EXCL_STOP */ else if(method == "grub-ieee1275") { if(script->options().test(Simulate)) { std::cout << "apk --root " << script->targetDirectory() diff --git a/hscript/network.cc b/hscript/network.cc index 17fd0ea..e530da7 100644 --- a/hscript/network.cc +++ b/hscript/network.cc @@ -70,6 +70,7 @@ Key *NetConfigType::parseFromData(const std::string &data, return new NetConfigType(script, pos, system); } +/* LCOV_EXCL_START */ bool NetConfigType::validate() const { /* Validation takes place during parsing. */ return true; @@ -79,6 +80,7 @@ bool NetConfigType::execute() const { /* This key doesn't perform any action by itself. */ return true; } +/* LCOV_EXCL_STOP */ Key *NetAddress::parseFromData(const std::string &data, diff --git a/hscript/script_v.cc b/hscript/script_v.cc index 41f1756..2cd3ab9 100644 --- a/hscript/script_v.cc +++ b/hscript/script_v.cc @@ -115,21 +115,25 @@ bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos, } else { base_url += "stable/"; } - Repository *sys_key = dynamic_cast<Repository *>( + Repository *sys_key = static_cast<Repository *>( Repository::parseFromData(base_url + "system", p, nullptr, nullptr, s) ); if(!sys_key) { + /* LCOV_EXCL_START - only relevant in OOM conditions */ output_error("internal", "failed to create default system repository"); return false; + /* LCOV_EXCL_STOP */ } std::unique_ptr<Repository> sys_repo(sys_key); repos.push_back(std::move(sys_repo)); - Repository *user_key = dynamic_cast<Repository *>( + Repository *user_key = static_cast<Repository *>( Repository::parseFromData(base_url + "user", p, nullptr, nullptr, s) ); if(!user_key) { + /* LCOV_EXCL_START - only relevant in OOM conditions */ output_error("internal", "failed to create default user repository"); return false; + /* LCOV_EXCL_STOP */ } std::unique_ptr<Repository> user_repo(user_key); repos.push_back(std::move(user_repo)); @@ -137,10 +141,10 @@ bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos, #ifdef NON_LIBRE_FIRMWARE /* REQ: Runner.Execute.firmware.Repository */ if(firmware) { - Repository *fw_key = dynamic_cast<Repository *>( + Repository *fw_key = static_cast<Repository *>( Repository::parseFromData( "https://distfiles.apkfission.net/adelie/1.0/nonfree", - {"internal", 0}, nullptr, nullptr, s + p, nullptr, nullptr, s ) ); if(!fw_key) { @@ -163,14 +167,16 @@ bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos, */ bool add_default_repo_keys(std::vector<std::unique_ptr<SigningKey>> &keys, const Script *s, bool firmware = false) { - SigningKey *key = dynamic_cast<SigningKey *>( + SigningKey *key = static_cast<SigningKey *>( SigningKey::parseFromData( "/etc/apk/keys/packages@adelielinux.org.pub", {"internal", 0}, nullptr, nullptr, s) ); if(!key) { + /* LCOV_EXCL_START - only relevant in OOM conditions */ output_error("internal", "failed to create default repository signing key"); return false; + /* LCOV_EXCL_STOP */ } std::unique_ptr<SigningKey> repo_key(key); keys.push_back(std::move(repo_key)); @@ -278,11 +284,15 @@ bool Horizon::Script::validate() const { /* REQ: Runner.Execute.timezone */ if(!internal->tzone) { - Timezone *utc = dynamic_cast<Timezone *> - (Timezone::parseFromData("UTC", {"", 0}, &failures, nullptr, this)); + Timezone *utc = static_cast<Timezone *>( + Timezone::parseFromData("UTC", {"internal", 0}, &failures, + nullptr, this) + ); if(!utc) { + /* LCOV_EXCL_START - only relevant in OOM conditions */ output_error("internal", "failed to create default timezone"); return false; + /* LCOV_EXCL_STOP */ } std::unique_ptr<Timezone> zone(utc); internal->tzone = std::move(zone); @@ -298,7 +308,7 @@ bool Horizon::Script::validate() const { , internal->firmware && internal->firmware->test() #endif )) { - return false; + return false; /* LCOV_EXCL_LINE - only OOM */ } } @@ -320,7 +330,7 @@ bool Horizon::Script::validate() const { , internal->firmware && internal->firmware->test() #endif )) { - return false; + return false; /* LCOV_EXCL_LINE - only OOM */ } } diff --git a/hscript/user.cc b/hscript/user.cc index 571ebc4..5a1d6cf 100644 --- a/hscript/user.cc +++ b/hscript/user.cc @@ -318,7 +318,7 @@ bool UserPassphrase::execute() const { return false; } #endif /* HAS_INSTALL_ENV */ - return true; + return true; /* LCOV_EXCL_LINE */ } |