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

Commit 3c9d4e75 authored by Steve Gu's avatar Steve Gu Committed by Andre Eisenbach
Browse files

Sometimes I forget stopping shell before running bdtest.

Make this check automatic and print out a friendly message for reminder.
parent 7b92d70f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ LOCAL_SRC_FILES := \
LOCAL_SHARED_LIBRARIES += \
    liblog \
    libhardware \
    libhardware_legacy
    libhardware_legacy \
    libcutils

LOCAL_STATIC_LIBRARIES += \
  libbtcore \
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
 *
 ******************************************************************************/

#include <cutils/properties.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
@@ -63,6 +64,16 @@ static void *watchdog_fn(void *arg) {
  return NULL;
}

// Is shell still running? bdtest must run with shell stopped.
static bool is_shell_running() {
  char property_str[100];
  property_get("init.svc.zygote", property_str, NULL);
  if (!strcmp("running", property_str)) {
    return true;
  }
  return false;
}

static void print_usage(const char *program_name) {
  printf("Usage: %s [options] [test name]\n", program_name);
  printf("\n");
@@ -123,6 +134,11 @@ int main(int argc, char **argv) {
    test_name = argv[i];
  }

  if (is_shell_running()) {
    printf("Run 'adb shell stop' before running %s.\n", argv[0]);
    return -1;
  }

  config_t *config = config_new(CONFIG_FILE_PATH);
  if (!config) {
    printf("Error: unable to open stack config file.\n");