CKM: Add asserts for file copying 09/40809/4
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 9 Jun 2015 08:26:25 +0000 (10:26 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 11 Jun 2015 09:36:17 +0000 (02:36 -0700)
[Problem] If you manually remove contents of /opt/data/ckm/ initial-values
tests will fail because the target directory does not exist.
[Solution] Add asserts checking if input & output files are correct.

[Verification] Remove /otp/data/ckm/initial_values. Run:
ckm-tests --group=T60_INITIAL_VALUES. They should fail. Reinstall key-manager
run tests again. All should pass.

Change-Id: Ib6b7308747b74943ec9d7274284d1d56c9be1641

src/ckm/initial-values.cpp

index 197e439..a66ab6d 100644 (file)
@@ -92,7 +92,9 @@ std::string format_dest_path(const char *file)
 void copy_file(const std::string &from, const std::string &to)
 {
     std::ifstream infile(from, std::ios_base::binary);
+    RUNNER_ASSERT_MSG(infile, "Input file " << from << " does not exist.");
     std::ofstream outfile(to, std::ios_base::binary);
+    RUNNER_ASSERT_MSG(outfile, "Output file " << to << " does not exist. Reinstall key-manager.");
     outfile << infile.rdbuf();
 }