return WEXITSTATUS(status);
}
-} // namespace common_fota
\ No newline at end of file
+} // namespace common_fota
* limitations under the License.
*/
+#include "pkg_finder.hh"
+
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
-#include <cstring>
+#include <tzplatform_config.h>
+#include <cstring>
#include <algorithm>
#include <cctype>
-#include <tzplatform_config.h>
-
#include "logging.hh"
-#include "pkg_finder.hh"
#include "backend_invoker.hh"
#define ASCII(s) reinterpret_cast<const char*>(s)
#define XMLCHAR(s) reinterpret_cast<const xmlChar*>(s)
-#define USR_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RO_PACKAGES)
+#define USR_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RO_PACKAGES)
#define PRELOAD_RW_LIST_FILE \
tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, \
"pkgmgr/fota/.all_preload_rw_list")
xmlCleanupParser();
}
-int PkgFinder::UnzipFileOnlyToPath(const char* dest_path, const char* unzip_to) {
+int PkgFinder::UnzipFileOnlyToPath(const char* dest_path,
+ const char* unzip_to) {
const char* unzip_argv[] = { "/usr/bin/unzip", "-joXqq",
kOptZipFile, dest_path, "-d", unzip_to, nullptr };
return BackendInvoker::XSystem(unzip_argv);
return;
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
PkgOperation::UNINSTALL_KEEP_RW_DATA)),
unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::INSTALL))
- ));
+ PkgOperation::INSTALL))));
} else if (old_pkg->IsReadOnly() && !new_pkg.IsReadOnly()) {
// RO to RW
pkgs.emplace_back(new Ro2RwUpgrader(
unique_ptr<PkgUpgrader>(new SimpleUpgrader(*old_pkg,
PkgOperation::UNINSTALL_KEEP_RW_DATA)),
unique_ptr<PkgUpgrader>(new SimpleUpgrader(new_pkg,
- PkgOperation::INSTALL))
- ));
+ PkgOperation::INSTALL))));
}
} else {
// INSTALL
return nullptr;
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
return ret;
}
-int Ro2RwUpgrader::UnzipData(const std::string& pkgid, const std::string& dest) {
+int Ro2RwUpgrader::UnzipData(const std::string& pkgid,
+ const std::string& dest) {
std::string path = dest + pkgid + "/*";
int ret = UnzipFiles(path.c_str());
if (ret != 0)
return 0;
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
return true;
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
return false;
}
-} // common_fota
\ No newline at end of file
+} // namespace common_fota
int fd_ = -1;
};
-}
+} // namespace
namespace common_fota {
PkgUpgraderFactory factory;
auto list = factory.MakeList(finder);
- for(auto& pkg : list) {
- if(pkg->Upgrade()) {
+ for (auto& pkg : list) {
+ if (pkg->Upgrade()) {
LOG(DEBUG) << "upgrade success (" << pkg->GetId() << ")";
success_list_.push_back(move(pkg));
} else {
string cert_db_bck = cert_db_ + ".bck";
string cert_db_journal_bck = cert_db_journal_ + ".bck";
- if (BackupDb(parser_db_, parser_db_bck) == -1 ) {
- LOG(ERROR) << "Fail to backup [" << parser_db_ << "] to [" << parser_db_bck <<
- "]";
+ if (BackupDb(parser_db_, parser_db_bck) == -1) {
+ LOG(ERROR) << "Fail to backup [" << parser_db_ <<
+ "] to [" << parser_db_bck << "]";
goto CATCH;
}
RemoveBackupPath(cert_db_journal_);
}
-} // common_fota
+} // namespace common_fota
* limitations under the License.
*/
-#ifndef MOCK_MOCK_HOOK_H_
-#define MOCK_MOCK_HOOK_H_
+#ifndef TESTS_MOCK_MOCK_HOOK_H_
+#define TESTS_MOCK_MOCK_HOOK_H_
#define MOCK_HOOK_P0(MOCK_CLASS, f) \
TestFixture::GetMock<MOCK_CLASS>().f()
TestFixture::GetMock<MOCK_CLASS>().f( \
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
-#endif // MOCK_MOCK_HOOK_H_
+#endif // TESTS_MOCK_MOCK_HOOK_H_
* limitations under the License.
*/
-#ifndef MOCK_MODULE_MOCK_H_
-#define MOCK_MODULE_MOCK_H_
+#ifndef TESTS_MOCK_MODULE_MOCK_H_
+#define TESTS_MOCK_MODULE_MOCK_H_
class ModuleMock {
public:
virtual ~ModuleMock() {}
};
-#endif // MOCK_MODULE_MOCK_H_
+#endif // TESTS_MOCK_MODULE_MOCK_H_
extern "C" int smack_setlabel(const char *path, const char* label,
enum smack_label_type type) {
return MOCK_HOOK_P3(OsMock, smack_setlabel, path, label, type);
-}
\ No newline at end of file
+}
* limitations under the License.
*/
-#ifndef MOCK_OS_MOCK_H_
-#define MOCK_OS_MOCK_H_
+#ifndef TESTS_MOCK_OS_MOCK_H_
+#define TESTS_MOCK_OS_MOCK_H_
#include <gmock/gmock.h>
#include <sys/types.h>
MOCK_METHOD3(smack_setlabel, int(const char*, const char*, smack_label_type));
};
-#endif // MOCK_OS_MOCK_H_
+#endif // TESTS_MOCK_OS_MOCK_H_
char **version) {
return MOCK_HOOK_P2(PkgMgrInfoMock, pkgmgrinfo_pkginfo_get_version,
handle, version);
-}
\ No newline at end of file
+}
* limitations under the License.
*/
-#ifndef MOCK_PKGMGR_INFO_MOCK_H_
-#define MOCK_PKGMGR_INFO_MOCK_H_
+#ifndef TESTS_MOCK_PKGMGR_INFO_MOCK_H_
+#define TESTS_MOCK_PKGMGR_INFO_MOCK_H_
#include <tizen.h>
#include <gmock/gmock.h>
int(pkgmgrinfo_pkginfo_filter_h, const char*, const bool));
MOCK_METHOD3(pkgmgrinfo_pkginfo_filter_foreach_pkginfo,
int(pkgmgrinfo_pkginfo_filter_h, pkgmgrinfo_pkg_list_cb, void*));
- MOCK_METHOD2(pkgmgrinfo_pkginfo_get_pkgid, int(pkgmgrinfo_pkginfo_h, char**));
+ MOCK_METHOD2(pkgmgrinfo_pkginfo_get_pkgid,
+ int(pkgmgrinfo_pkginfo_h, char**));
MOCK_METHOD2(pkgmgrinfo_pkginfo_get_type, int(pkgmgrinfo_pkginfo_h, char**));
- MOCK_METHOD2(pkgmgrinfo_pkginfo_get_version, int(pkgmgrinfo_pkginfo_h, char**));
+ MOCK_METHOD2(pkgmgrinfo_pkginfo_get_version,
+ int(pkgmgrinfo_pkginfo_h, char**));
};
-#endif // MOCK_PKGMGR_INFO_MOCK_H_
+#endif // TESTS_MOCK_PKGMGR_INFO_MOCK_H_
* limitations under the License.
*/
-#ifndef MOCK_TEST_FIXTURE_H_
-#define MOCK_TEST_FIXTURE_H_
+#ifndef TESTS_MOCK_TEST_FIXTURE_H_
+#define TESTS_MOCK_TEST_FIXTURE_H_
#include <gtest/gtest.h>
static std::unique_ptr<ModuleMock> mock_;
};
-#endif // MOCK_TEST_FIXTURE_H_
+#endif // TESTS_MOCK_TEST_FIXTURE_H_
ret = RUN_ALL_TESTS();
} catch (const ::testing::internal::GoogleTestFailureException& e) {
ret = -1;
- std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+ std::cout << "GoogleTestFailureException was thrown:"
+ << e.what() << std::endl;
}
return ret;
};
EXPECT_CALL(GetMock<PkgMgrInfoMock>(),
- pkgmgrinfo_pkginfo_get_pkgid(_,_))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkgid[0])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkgid[1])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkgid[2])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_rw_pkgid[0])), Return(0)));
+ pkgmgrinfo_pkginfo_get_pkgid(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkgid[0])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkgid[1])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkgid[2])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_rw_pkgid[0])), Return(0)));
EXPECT_CALL(GetMock<PkgMgrInfoMock>(),
- pkgmgrinfo_pkginfo_get_type(_,_))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_type[0])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_type[1])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_type[2])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_rw_pkg_type[0])), Return(0)));
+ pkgmgrinfo_pkginfo_get_type(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_type[0])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_type[1])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_type[2])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_rw_pkg_type[0])), Return(0)));
EXPECT_CALL(GetMock<PkgMgrInfoMock>(),
- pkgmgrinfo_pkginfo_get_version(_,_))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_version[0])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_version[1])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_ro_pkg_version[2])), Return(0)))
- .WillOnce(DoAll(SetArgPointee<1>(const_cast<char*>(old_rw_pkg_version[0])), Return(0)));
+ pkgmgrinfo_pkginfo_get_version(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_version[0])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_version[1])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_ro_pkg_version[2])), Return(0)))
+ .WillOnce(DoAll(SetArgPointee<1>(
+ const_cast<char*>(old_rw_pkg_version[0])), Return(0)));
EXPECT_CALL(GetMock<PkgMgrInfoMock>(), pkgmgrinfo_pkginfo_filter_destroy(_))
.WillRepeatedly(Return(0));