diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-18 17:24:11 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-18 17:24:11 -0500 |
commit | e4cd6fffb79807fa1d184bc8d108a91aea8af649 (patch) | |
tree | 7036c49774f60c0e39c2458b389dada5a59b0092 | |
parent | 5c9056e171f919b6d662011eb594d840636f3ea4 (diff) | |
download | horizon-e4cd6fffb79807fa1d184bc8d108a91aea8af649.tar.gz horizon-e4cd6fffb79807fa1d184bc8d108a91aea8af649.tar.bz2 horizon-e4cd6fffb79807fa1d184bc8d108a91aea8af649.tar.xz horizon-e4cd6fffb79807fa1d184bc8d108a91aea8af649.zip |
hscript: Mark install-only sections as untestable
-rw-r--r-- | hscript/disk.cc | 14 | ||||
-rw-r--r-- | hscript/meta.cc | 57 | ||||
-rw-r--r-- | hscript/user.cc | 3 |
3 files changed, 42 insertions, 32 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index cbd9517..713a31d 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -63,7 +63,7 @@ bool DiskId::validate(ScriptOptions options) const { return true; } -bool DiskId::execute(ScriptOptions options) const { +bool DiskId::execute(ScriptOptions) const { return false; } @@ -131,7 +131,7 @@ bool Mount::execute(ScriptOptions options) const { /* We have to get the filesystem for the node. */ if(options.test(Simulate)) { fstype = "auto"; - } else { + } else { /* LCOV_EXCL_START */ fstype = blkid_get_tag_value(nullptr, "TYPE", this->device().c_str()); if(fstype == nullptr) { output_error("installfile:" + std::to_string(this->lineno()), @@ -139,7 +139,7 @@ bool Mount::execute(ScriptOptions options) const { this->device()); return false; } - } + } /* LCOV_EXCL_STOP */ output_info("installfile:" + std::to_string(this->lineno()), "mount: mounting " + this->device() + " on " + @@ -150,7 +150,7 @@ bool Mount::execute(ScriptOptions options) const { std::cout << "-o " << this->options() << " "; } std::cout << this->device() << " " << actual_mount << std::endl; - } else { + } else { /* LCOV_EXCL_START */ /* mount */ if(mount(this->device().c_str(), actual_mount.c_str(), fstype, 0, this->options().c_str()) != 0) { @@ -165,7 +165,7 @@ bool Mount::execute(ScriptOptions options) const { return false; } } - } + } /* LCOV_EXCL_STOP */ /* Handle fstab. We're guaranteed to have a /target since mount has * already ran and /target is the first mount done. @@ -183,7 +183,7 @@ bool Mount::execute(ScriptOptions options) const { << "n' " << this->device() << " " << this->mountpoint() << " " << fstype << " " << fstab_opts << " >> /target/etc/fstab" << std::endl; - } else { + } else { /* LCOV_EXCL_START */ if(this->mountpoint() == "/") { /* failure of mkdir will be handled in the !fstab_f case */ mkdir("/target/etc", @@ -198,7 +198,7 @@ bool Mount::execute(ScriptOptions options) const { fstab_f << this->device() << "\t" << this->mountpoint() << "\t" << fstype << "\t" << fstab_opts << "\t0\t" << pass << std::endl; - } + } /* LCOV_EXCL_STOP */ return true; } diff --git a/hscript/meta.cc b/hscript/meta.cc index 299c1f0..b2d7010 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -83,26 +83,26 @@ bool Hostname::execute(ScriptOptions opts) const { } /* Runner.Execute.hostname. */ + output_info("installfile:" + std::to_string(this->lineno()), + "hostname: set hostname to '" + actual + "'"); if(opts.test(Simulate)) { - output_info("installfile:" + std::to_string(this->lineno()), - "hostname: set hostname to '" + actual + "'"); std::cout << "hostname " << actual << std::endl; - } else { + } else { /* LCOV_EXCL_START */ if(sethostname(actual.c_str(), actual.size()) == -1) { output_error("installfile:" + std::to_string(this->lineno()), "hostname: failed to set host name", std::string(strerror(errno))); return false; } - } + } /* LCOV_EXCL_STOP */ /* Runner.Execute.hostname.Write. */ + output_info("installfile:" + std::to_string(this->lineno()), + "hostname: write '" + actual + "' to /etc/hostname"); if(opts.test(Simulate)) { - output_info("installfile:" + std::to_string(this->lineno()), - "hostname: write '" + actual + "' to /etc/hostname"); std::cout << "printf '%s' " << actual << " > /target/etc/hostname" << std::endl; - } else { + } else { /* LCOV_EXCL_START */ std::ofstream hostname_f("/target/etc/hostname"); if(!hostname_f) { output_error("installfile:" + std::to_string(this->lineno()), @@ -110,15 +110,15 @@ bool Hostname::execute(ScriptOptions opts) const { return false; } hostname_f << actual; - } + } /* LCOV_EXCL_STOP */ /* The second condition ensures that it isn't a single dot that simply * terminates the nodename. */ if(dot != std::string::npos && this->_value.length() > dot + 1) { const std::string domain(this->_value.substr(dot + 1)); + output_info("installfile:" + std::to_string(this->lineno()), + "hostname: set domain name '" + domain + "'"); if(opts.test(Simulate)) { - output_info("installfile:" + std::to_string(this->lineno()), - "hostname: set domain name '" + domain + "'"); std::cout << "printf 'dns_domain_lo=\"" << domain << "\"\\" << "n' >> /target/etc/conf.d/net" << std::endl; } else { @@ -167,16 +167,18 @@ Key *PkgInstall::parseFromData(const std::string &data, int lineno, int *errors, } +/* LCOV_EXCL_START */ bool PkgInstall::validate(ScriptOptions) const { /* Any validation errors would have occurred above. */ - return true; /* LCOV_EXCL_LINE */ + return true; } bool PkgInstall::execute(ScriptOptions) const { /* Package installation is handled in Script::execute. */ - return true; /* LCOV_EXCL_LINE */ + return true; } +/* LCOV_EXCL_STOP */ Key *Repository::parseFromData(const std::string &data, int lineno, int *errors, @@ -197,22 +199,27 @@ bool Repository::validate(ScriptOptions) const { bool Repository::execute(ScriptOptions opts) const { /* Runner.Execute.repository. */ + output_info("installfile:" + std::to_string(this->lineno()), + "repository: write '" + this->value() + + "' to /etc/apk/repositories"); if(opts.test(Simulate)) { - output_info("installfile:" + std::to_string(this->lineno()), - "repository: write '" + this->value() + - "' to /etc/apk/repositories"); std::cout << "echo '" << this->value() << "' >> /target/etc/apk/repositories" << std::endl; - } else { - std::ofstream repo_f("/target/etc/apk/repositories", - std::ios_base::ate); - if(!repo_f) { - output_error("installfile:" + std::to_string(this->lineno()), - "repository: could not open /etc/apk/repositories " - "for writing"); - return false; - } - repo_f << this->value() << std::endl; + return true; } + + /* LCOV_EXCL_START */ + std::ofstream repo_f("/target/etc/apk/repositories", + std::ios_base::ate); + if(!repo_f) { + output_error("installfile:" + std::to_string(this->lineno()), + "repository: could not open /etc/apk/repositories " + "for writing"); + return false; + } + + repo_f << this->value() << std::endl; + return true; + /* LCOV_EXCL_STOP */ } diff --git a/hscript/user.cc b/hscript/user.cc index 0513d21..4d00cb2 100644 --- a/hscript/user.cc +++ b/hscript/user.cc @@ -58,6 +58,8 @@ bool RootPassphrase::execute(ScriptOptions options) const { return false; } + /* LCOV_EXCL_START */ + /* This was tested on gwyn during development. */ std::stringstream shadow_stream; char shadow_line[200]; /* Discard root. */ @@ -81,4 +83,5 @@ bool RootPassphrase::execute(ScriptOptions options) const { } new_shadow << shadow_stream.str(); return true; + /* LCOV_EXCL_STOP */ } |