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

Commit 74601257 authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge "Skip pmsg related tests if /dev/pmsg0 is not found"

parents 6d4e47a1 986bd0c7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,10 @@
TEST(libc, __pstore_append) {
#ifdef __ANDROID__
#ifndef NO_PSTORE
  if (access("/dev/pmsg0", W_OK) != 0) {
    GTEST_SKIP() << "pmsg0 not found, skipping test";
  }

  FILE* fp;
  ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "ae")));
  static const char message[] = "libc.__pstore_append\n";
+14 −14
Original line number Diff line number Diff line
@@ -160,7 +160,6 @@ static std::string popenToString(const std::string& command) {
  return ret;
}

#ifndef NO_PSTORE
static bool isPmsgActive() {
  pid_t pid = getpid();

@@ -170,7 +169,6 @@ static bool isPmsgActive() {

  return std::string::npos != myPidFds.find(" -> /dev/pmsg0");
}
#endif /* NO_PSTORE */

static bool isLogdwActive() {
  std::string logdwSignature =
@@ -222,16 +220,18 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
  log_time ts(CLOCK_MONOTONIC);
  log_time ts1(ts);

  bool has_pstore = access("/dev/pmsg0", W_OK) == 0;

  auto write_function = [&] {
    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
    // Check that we can close and reopen the logger
    bool logdwActiveAfter__android_log_btwrite;
    if (getuid() == AID_ROOT) {
      tested__android_log_close = true;
#ifndef NO_PSTORE
      if (has_pstore) {
        bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
#endif /* NO_PSTORE */
      }
      logdwActiveAfter__android_log_btwrite = isLogdwActive();
      EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
    } else if (!tested__android_log_close) {
@@ -239,10 +239,10 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
    }
    __android_log_close();
    if (getuid() == AID_ROOT) {
#ifndef NO_PSTORE
      if (has_pstore) {
        bool pmsgActiveAfter__android_log_close = isPmsgActive();
        EXPECT_FALSE(pmsgActiveAfter__android_log_close);
#endif /* NO_PSTORE */
      }
      bool logdwActiveAfter__android_log_close = isLogdwActive();
      EXPECT_FALSE(logdwActiveAfter__android_log_close);
    }
@@ -250,10 +250,10 @@ TEST(liblog, __android_log_btwrite__android_logger_list_read) {
    ts1 = log_time(CLOCK_MONOTONIC);
    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
    if (getuid() == AID_ROOT) {
#ifndef NO_PSTORE
      if (has_pstore) {
        bool pmsgActiveAfter__android_log_btwrite = isPmsgActive();
        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
#endif /* NO_PSTORE */
      }
      logdwActiveAfter__android_log_btwrite = isLogdwActive();
      EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
    }