- TestPkgmgrInstaller pkgmgr_installer;
- std::shared_ptr<ci::AppQueryInterface> query_interface =
- CreateQueryInterface();
- auto pkgmgr =
- ci::PkgMgrInterface::Create(argc, const_cast<char**>(argv),
- &pkgmgr_installer,
- query_interface);
- if (!pkgmgr) {
- LOG(ERROR) << "Failed to initialize pkgmgr interface";
- return;
- }
- AppInstallerPtr backend;
- unsigned int insert_idx = 0;
- do {
- backend = CreateFailExpectedInstaller(pkgmgr, insert_idx);
- LOG(DEBUG) << "StepFail is inserted at: " << insert_idx;
- ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend->Run());
- if (!validator())
- break;
- insert_idx++;
- } while (insert_idx < backend->StepCount());
- ASSERT_EQ(insert_idx, backend->StepCount());
+ ci::Subprocess backend_helper = CreateSubprocess();
+ ASSERT_EQ(backend_helper.RunFunc({[&]() -> int {
+ TestPkgmgrInstaller pkgmgr_installer;
+ std::shared_ptr<ci::AppQueryInterface> query_interface =
+ CreateQueryInterface();
+ auto pkgmgr =
+ ci::PkgMgrInterface::Create(argc, const_cast<char**>(argv),
+ &pkgmgr_installer,
+ query_interface);
+ if (!pkgmgr) {
+ LOG(ERROR) << "Failed to initialize pkgmgr interface";
+ return 1;
+ }
+ AppInstallerPtr backend;
+ unsigned int insert_idx = 0;
+ do {
+ backend = CreateFailExpectedInstaller(pkgmgr, insert_idx);
+ LOG(DEBUG) << "StepFail is inserted at: " << insert_idx;
+ ci::AppInstaller::Result ret = backend->Run();
+ if (ret != ci::AppInstaller::Result::ERROR) {
+ LOG(ERROR) << "StepFail not executed";
+ return 1;
+ }
+ if (!validator())
+ break;
+ insert_idx++;
+ } while (insert_idx < backend->StepCount());
+ if (insert_idx != backend->StepCount()) {
+ LOG(ERROR) << "Fail to validate";
+ return 1;
+ }
+
+ return 0;
+ }}), true);
+ int status = backend_helper.Wait();
+ ASSERT_NE(WIFEXITED(status), 0);
+ ASSERT_EQ(WEXITSTATUS(status), 0);