# GTEST_MAIN_LIBRARIES is needed.
target_link_libraries(signature_unittest PUBLIC ${TARGET_LIBNAME_COMMON} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(xml_parser_unittest PUBLIC ${TARGET_LIBNAME_PARSER} ${GTEST_MAIN_LIBRARIES})
-target_link_libraries(smoke_test PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES})
+target_link_libraries(smoke_test PRIVATE ${TARGET_LIBNAME_WGT})
FOREACH(test ${TESTS})
INSTALL(TARGETS ${test} DESTINATION ${BINDIR}/${DESTINATION_DIR})
#include <array>
#include <cstdio>
+#include <cstdlib>
#include "common/backup_paths.h"
#include "common/pkgmgr_interface.h"
namespace {
+const char kApplicationDir[] = ".applications";
+const char kApplicationDirBackup[] = ".applications.bck";
+const char KUserAppsDir[] = "apps_rw";
+const char KUserAppsDirBackup[] = "apps_rw.bck";
+
enum class RequestResult {
NORMAL,
FAIL,
namespace wgt {
-// TODO(t.iwanek): before tests cleanup...
+class SmokeEnvironment : public testing::Environment {
+ public:
+ explicit SmokeEnvironment(const bf::path& home) : home_(home) {
+ }
+ void SetUp() override {
+ bs::error_code error;
+ bf::remove_all(home_ / kApplicationDirBackup, error);
+ bf::remove_all(home_ / KUserAppsDirBackup, error);
+ if (bf::exists(home_ / KUserAppsDir)) {
+ bf::rename(home_ / KUserAppsDir, home_ / KUserAppsDirBackup, error);
+ assert(!error);
+ }
+ if (bf::exists(home_ / kApplicationDir)) {
+ bf::rename(home_ / kApplicationDir, home_ / kApplicationDirBackup, error);
+ assert(!error);
+ }
+ }
+ void TearDown() override {
+ bs::error_code error;
+ bf::remove_all(home_ / kApplicationDir, error);
+ bf::remove_all(home_ / KUserAppsDir, error);
+ if (bf::exists(home_ / KUserAppsDirBackup))
+ bf::rename(home_ / KUserAppsDirBackup, home_ / KUserAppsDir, error);
+ if (bf::exists(home_ / kApplicationDirBackup))
+ bf::rename(home_ / kApplicationDirBackup, home_ / kApplicationDir, error);
+ }
+
+ private:
+ bf::path home_;
+};
+
class SmokeTest : public testing::Test {
};
}
} // namespace wgt
+
+int main(int argc, char** argv) {
+ testing::InitGoogleTest(&argc, argv);
+ const char* directory = getenv("HOME");
+ if (!directory) {
+ LOG(ERROR) << "Cannot get $HOME value";
+ return 1;
+ }
+ testing::AddGlobalTestEnvironment(new wgt::SmokeEnvironment(directory));
+ return RUN_ALL_TESTS();
+}