From d75003d24c6e33befe041dd0cad7be3df199636c Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 4 Nov 2016 11:31:29 -0700 Subject: Make make_parent() to take const argument Switch to use const std::string; and add corresponding tests. Bug: 32649858 Test: Component tests pass Change-Id: I640f3ec81f1481fa91aa310f8d4d96dac9649cb9 --- tests/component/updater_test.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp index f922933cd..acc2b4040 100644 --- a/tests/component/updater_test.cpp +++ b/tests/component/updater_test.cpp @@ -208,4 +208,26 @@ TEST_F(UpdaterTest, rename) { // Already renamed. expect(temp_file2.path, script2.c_str(), kNoCause); + + // Parents create successfully. + TemporaryFile temp_file3; + TemporaryDir td; + std::string temp_dir = std::string(td.path) + "/aaa/bbb/a.txt"; + std::string script3("rename(\"" + std::string(temp_file3.path) + "\", \"" + + temp_dir + "\")"); + expect(temp_dir.c_str(), script3.c_str(), kNoCause); +} + +TEST_F(UpdaterTest, symlink) { + // symlink expects 1+ argument. + expect(nullptr, "symlink()", kArgsParsingFailure); + + // symlink should fail if src is an empty string. + TemporaryFile temp_file1; + std::string script1("symlink(\"" + std::string(temp_file1.path) + "\", \"\")"); + expect(nullptr, script1.c_str(), kSymlinkFailure); + + // symlink failed to remove old src. + std::string script2("symlink(\"" + std::string(temp_file1.path) + "\", \"/proc\")"); + expect(nullptr, script2.c_str(), kSymlinkFailure); } -- cgit v1.2.3