Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47282420 authored by Tianjie Xu's avatar Tianjie Xu
Browse files

Do not inject I/O fault on a retry

We could inject I/O faults during an OTA update for test purpose. But we
should skip the injection if the update is an retry. Otherwise the
update test will simply keeps failing.

Bug: 34159970
Test: Apply the same package on angler and the update succeeds on the 2nd try.
Change-Id: Id274e5475e3bc8d25d50a8cf61a77d2e32c569d6
parent 095675a3
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -29,21 +29,23 @@
#define OTAIO_MAX_FNAME_SIZE 128
#define OTAIO_MAX_FNAME_SIZE 128


static ZipArchiveHandle archive;
static ZipArchiveHandle archive;
static bool is_retry = false;
static std::map<std::string, bool> should_inject_cache;
static std::map<std::string, bool> should_inject_cache;


static std::string get_type_path(const char* io_type) {
static std::string get_type_path(const char* io_type) {
    return android::base::StringPrintf("%s/%s", OTAIO_BASE_DIR, io_type);
    return android::base::StringPrintf("%s/%s", OTAIO_BASE_DIR, io_type);
}
}


void ota_io_init(ZipArchiveHandle za) {
void ota_io_init(ZipArchiveHandle za, bool retry) {
    archive = za;
    archive = za;
    is_retry = retry;
    ota_set_fault_files();
    ota_set_fault_files();
}
}


bool should_fault_inject(const char* io_type) {
bool should_fault_inject(const char* io_type) {
    // archive will be NULL if we used an entry point other
    // archive will be NULL if we used an entry point other
    // than updater/updater.cpp:main
    // than updater/updater.cpp:main
    if (archive == NULL) {
    if (archive == nullptr || is_retry) {
        return false;
        return false;
    }
    }
    const std::string type_path = get_type_path(io_type);
    const std::string type_path = get_type_path(io_type);
+1 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@
/*
/*
 * Initialize libotafault by providing a reference to the OTA package.
 * Initialize libotafault by providing a reference to the OTA package.
 */
 */
void ota_io_init(ZipArchiveHandle zip);
void ota_io_init(ZipArchiveHandle zip, bool retry);


/*
/*
 * Return true if a config file is present for the given IO type.
 * Return true if a config file is present for the given IO type.
+1 −1
Original line number Original line Diff line number Diff line
@@ -100,7 +100,6 @@ int main(int argc, char** argv) {
    CloseArchive(za);
    CloseArchive(za);
    return 3;
    return 3;
  }
  }
  ota_io_init(za);


  ZipString script_name(SCRIPT_NAME);
  ZipString script_name(SCRIPT_NAME);
  ZipEntry script_entry;
  ZipEntry script_entry;
@@ -166,6 +165,7 @@ int main(int argc, char** argv) {
      printf("unexpected argument: %s", argv[4]);
      printf("unexpected argument: %s", argv[4]);
    }
    }
  }
  }
  ota_io_init(za, state.is_retry);


  std::string result;
  std::string result;
  bool status = Evaluate(&state, root, &result);
  bool status = Evaluate(&state, root, &result);