diff options
-rw-r--r-- | Makefile.rules | 9 | ||||
-rw-r--r-- | chip/lm4/mock_gpio.c | 116 | ||||
-rw-r--r-- | chip/lm4/mock_keyboard_scan_stub.c | 85 | ||||
-rw-r--r-- | chip/lm4/mock_lpc.c | 79 | ||||
-rw-r--r-- | chip/lm4/mock_pwm.c | 69 | ||||
-rw-r--r-- | test/build.mk | 3 | ||||
-rw-r--r-- | test/charging.py | 81 | ||||
-rw-r--r-- | test/charging.tasklist | 17 | ||||
-rw-r--r-- | test/mutex.py | 25 | ||||
-rw-r--r-- | test/pingpong.py | 27 | ||||
-rw-r--r-- | test/scancode.py | 29 | ||||
-rw-r--r-- | test/scancode.tasklist | 17 | ||||
-rw-r--r-- | test/thermal_old.c | 426 | ||||
-rw-r--r-- | test/thermal_old.py | 104 | ||||
-rw-r--r-- | test/typematic.py | 63 | ||||
-rw-r--r-- | test/typematic.tasklist | 17 | ||||
-rwxr-xr-x | util/qemu-system-arm | bin | 3509800 -> 0 bytes | |||
-rwxr-xr-x | util/run_qemu_test | 265 |
18 files changed, 1 insertions, 1431 deletions
diff --git a/Makefile.rules b/Makefile.rules index 527e0934ef..c72a229f3f 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -39,8 +39,6 @@ cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@ cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) \ -MMD -MF $@.d $< -o $@ cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d $(filter %.c, $^) -o $@ -cmd_qemu = ./util/run_qemu_test --image=build/$(BOARD)/$*/$*.bin test/$*.py \ - $(silent) cmd_host_test = ./util/run_host_test $* $(silent) cmd_version = ./util/getversion.sh > $@ cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin @@ -59,8 +57,7 @@ utils: $(build-utils) $(host-utils) # On board test binaries test-targets=$(foreach t,$(test-list-y),test-$(t)) -qemu-test-targets=$(foreach t,$(test-list-y),qemu-$(t)) -.PHONY: $(qemu-test-targets) $(test-targets) +.PHONY: $(test-targets) $(test-targets): test-%: @set -e ; \ @@ -69,11 +66,7 @@ $(test-targets): test-%: V=$(V) out=$(out)/$* TEST_BUILD=y; \ cp $(out)/$*/$*.bin $(out)/test-$*.bin -$(qemu-test-targets): qemu-%: test-% - $(call quiet,qemu,TEST ) - tests: $(test-targets) -qemu-tests: $(qemu-test-targets) # Emulator test executables host-test-targets=$(foreach t,$(test-list-host),host-$(t)) diff --git a/chip/lm4/mock_gpio.c b/chip/lm4/mock_gpio.c deleted file mode 100644 index 59c32dc7ce..0000000000 --- a/chip/lm4/mock_gpio.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Mock GPIO module for Chrome EC */ - -#include "console.h" -#include "gpio.h" -#include "util.h" - - -static int8_t mock_value[GPIO_COUNT] = {0}; -static int8_t mock_gpio_im[GPIO_COUNT] = {0}; - - -int gpio_pre_init(void) -{ - /* Nothing to do */ - return EC_SUCCESS; -} - - -void gpio_set_alternate_function(int port, int mask, int func) -{ - /* Not implemented */ - return; -} - - -const char *gpio_get_name(enum gpio_signal signal) -{ - return gpio_list[signal].name; -} - - -int gpio_get_level(enum gpio_signal signal) -{ - return mock_value[signal] ? 1 : 0; -} - - -int gpio_set_level(enum gpio_signal signal, int value) -{ - mock_value[signal] = value; - return EC_SUCCESS; -} - - -int gpio_set_flags(enum gpio_signal signal, int flags) -{ - /* Not implemented */ - return EC_SUCCESS; -} - - -int gpio_enable_interrupt(enum gpio_signal signal) -{ - const struct gpio_info *g = gpio_list + signal; - - /* Fail if no interrupt handler */ - if (!g->irq_handler) - return EC_ERROR_UNKNOWN; - - mock_gpio_im[signal] = 1; - return EC_SUCCESS; -} - - -/* Find a GPIO signal by name. Returns the signal index, or GPIO_COUNT if - * no match. */ -static enum gpio_signal find_signal_by_name(const char *name) -{ - const struct gpio_info *g = gpio_list; - int i; - - if (!name || !*name) - return GPIO_COUNT; - - for (i = 0; i < GPIO_COUNT; i++, g++) { - if (!strcasecmp(name, g->name)) - return i; - } - - return GPIO_COUNT; -} - - -static int command_gpio_mock(int argc, char **argv) -{ - char *e; - int v, i; - const struct gpio_info *g; - - if (argc < 3) - return EC_ERROR_PARAM_COUNT; - - i = find_signal_by_name(argv[1]); - if (i == GPIO_COUNT) - return EC_ERROR_PARAM1; - g = gpio_list + i; - - v = strtoi(argv[2], &e, 0); - if (*e) - return EC_ERROR_PARAM2; - - gpio_set_level(i, v); - - if (g->irq_handler && mock_gpio_im[i]) - g->irq_handler(i); - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(gpiomock, command_gpio_mock, - "name <0 | 1>", - "Mock a GPIO input", - NULL); diff --git a/chip/lm4/mock_keyboard_scan_stub.c b/chip/lm4/mock_keyboard_scan_stub.c deleted file mode 100644 index 6334475dfa..0000000000 --- a/chip/lm4/mock_keyboard_scan_stub.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Mock functions for keyboard scanner module for Chrome EC */ - -#include "common.h" -#include "console.h" -#include "keyboard_config.h" -#include "keyboard_raw.h" -#include "keyboard_scan.h" -#include "task.h" -#include "uart.h" -#include "util.h" - -static int enable_scanning = 1; -static int selected_column = -1; -static int interrupt_enabled = 0; -static uint8_t matrix_status[KEYBOARD_COLS]; - -void keyboard_raw_init(void) -{ - /* Init matrix status to release all */ - int i; - for (i = 0; i < KEYBOARD_COLS; ++i) - matrix_status[i] = 0xff; -} - -void keyboard_raw_task_start(void) -{ -} - -void keyboard_raw_drive_column(int col) -{ - selected_column = col; -} - -int keyboard_raw_read_rows(void) -{ - if (selected_column >= 0) - return matrix_status[selected_column] ^ 0xff; - else - return 0; -} - -void keyboard_raw_enable_interrupt(int enable) -{ - interrupt_enabled = enable; -} - -static int command_mock_matrix(int argc, char **argv) -{ - int r, c, p; - char *e; - - if (argc < 4) - return EC_ERROR_PARAM_COUNT; - - c = strtoi(argv[1], &e, 0); - if (*e || c < 0 || c >= KEYBOARD_COLS) - return EC_ERROR_PARAM1; - - r = strtoi(argv[2], &e, 0); - if (*e || r < 0 || r >= KEYBOARD_ROWS) - return EC_ERROR_PARAM2; - - p = strtoi(argv[3], &e, 0); - if (*e) - return EC_ERROR_PARAM3; - - if (p) - matrix_status[c] &= ~(1 << r); - else - matrix_status[c] |= (1 << r); - - if (interrupt_enabled) - task_wake(TASK_ID_KEYSCAN); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(mockmatrix, command_mock_matrix, - "<Col> <Row> <0 | 1>", - "Mock keyboard matrix", - NULL); diff --git a/chip/lm4/mock_lpc.c b/chip/lm4/mock_lpc.c deleted file mode 100644 index b4b7164352..0000000000 --- a/chip/lm4/mock_lpc.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Mock LPC module for Chrome EC */ - -#include "common.h" -#include "ec_commands.h" -#include "lpc.h" -#include "registers.h" -#include "uart.h" - - -void lpc_set_host_event_state(uint32_t mask) -{ - uart_printf("Host event: %x\n", mask); -} - - -uint32_t lpc_get_host_event_state(void) -{ - /* Not implemented */ - return 0; -} - - -void lpc_clear_host_event_state(uint32_t mask) -{ - uart_printf("Clear host event: %x\n", mask); -} - - -void lpc_set_host_event_mask(enum lpc_host_event_type type, uint32_t mask) -{ - uart_printf("Set host event mask: type %d = %x\n", type, mask); -} - - -uint32_t lpc_get_host_event_mask(enum lpc_host_event_type type) -{ - /* Not implemented */ - return 0; -} - - -int lpc_comx_has_char(void) -{ - /* Not implemented */ - return 0; -} - - -int lpc_comx_get_char(void) -{ - /* Not implemented */ - return 0; -} - - -void lpc_comx_put_char(int c) -{ - /* Not implemented */ - return; -} - -#define LPC_POOL_OFFS_CMD_DATA 512 /* Data range for host commands - 512-767 */ -#define LPC_POOL_CMD_DATA (LM4_LPC_LPCPOOL + LPC_POOL_OFFS_CMD_DATA) - -uint8_t *lpc_get_memmap_range(void) -{ - return (uint8_t *)LPC_POOL_CMD_DATA + EC_HOST_PARAM_SIZE * 2; -} - - -uint8_t *host_get_buffer(void) -{ - return (uint8_t *)LPC_POOL_CMD_DATA; -} diff --git a/chip/lm4/mock_pwm.c b/chip/lm4/mock_pwm.c deleted file mode 100644 index b269b8f116..0000000000 --- a/chip/lm4/mock_pwm.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Mock PWM control module for Chrome EC */ - -#include "pwm.h" -#include "timer.h" -#include "uart.h" - -static int fan_target_rpm; -static int kblight; - -int pwm_set_fan_target_rpm(int rpm) -{ - uart_printf("Fan RPM: %d\n", rpm); - fan_target_rpm = rpm; - return EC_SUCCESS; -} - - -int pwm_get_fan_target_rpm(void) -{ - return fan_target_rpm; -} - - -int pwm_set_keyboard_backlight(int percent) -{ - uart_printf("KBLight: %d\n", percent); - kblight = percent; - return EC_SUCCESS; -} - - -int pwm_get_keyboard_backlight(void) -{ - return kblight; -} - - -int pwm_get_keyboard_backlight_enabled(void) -{ - /* Always enabled */ - return 1; -} - - -int pwm_enable_keyboard_backlight(int enable) -{ - /* Not implemented */ - return EC_SUCCESS; -} - - -int pwm_set_fan_duty(int percent) -{ - /* Not implemented */ - return EC_SUCCESS; -} - - -void pwm_task(void) -{ - /* Do nothing */ - while (1) - sleep(5); -} diff --git a/test/build.mk b/test/build.mk index 27a5447060..1c98d63bdd 100644 --- a/test/build.mk +++ b/test/build.mk @@ -9,9 +9,6 @@ test-list-y=pingpong timer_calib timer_dos timer_jump mutex utils #disable: powerdemo -# TODO(victoryang): Fix these tests: -# scancode typematic charging - test-list-$(BOARD_bds)+= test-list-$(BOARD_daisy)+=kb_scan stress test-list-$(BOARD_pit)+=kb_scan stress diff --git a/test/charging.py b/test/charging.py deleted file mode 100644 index 366d3faa3c..0000000000 --- a/test/charging.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Charging state machine unit test -# - -import time - -def consume_charge_state(helper): - try: - while True: - helper.wait_output("Charge state \S+ -> \S+", - use_re=True, - timeout=1) - except: - pass - -def wait_charge_state(helper, state): - helper.wait_output("Charge state \S+ -> %s" % state, use_re=True) - -def test(helper): - helper.wait_output("--- UART initialized") - - # Check charge when AC present - consume_charge_state(helper) - helper.ec_command("gpiomock AC_PRESENT 1") - wait_charge_state(helper, "charge") - - # Check discharge when AC not present - helper.ec_command("gpiomock AC_PRESENT 0") - wait_charge_state(helper, "discharge") - - # Check charge current - helper.ec_command("sbmock desire_current 2800") - helper.ec_command("gpiomock AC_PRESENT 1") - helper.wait_output("Charger set current: 2800") - - # Check charger voltage - helper.ec_command("gpiomock AC_PRESENT 0") - wait_charge_state(helper, "discharge") - helper.ec_command("sbmock desire_voltage 7500") - helper.ec_command("gpiomock AC_PRESENT 1") - helper.wait_output("Charger set voltage: 7500") - - # While powered on and discharging, over-temperature should trigger - # system shutdown - helper.ec_command("gpiomock AC_PRESENT 0") - wait_charge_state(helper, "discharge") - helper.ec_command("powermock on") - helper.ec_command("sbmock temperature 3700") - helper.wait_output("Force shutdown") - helper.ec_command("sbmock temperature 2981") - time.sleep(1) - - # While powered on and discharging, under-temperature should trigger - # system shutdown - helper.ec_command("powermock on") - helper.ec_command("sbmock temperature 2600") - helper.wait_output("Force shutdown") - helper.ec_command("sbmock temperature 2981") - - # While powered on and charging, over-temperature should stop battery - # from charging - consume_charge_state(helper) - helper.ec_command("gpiomock AC_PRESENT 1") - wait_charge_state(helper, "charge") - helper.ec_command("powermock on") - helper.ec_command("sbmock temperature 3700") - wait_charge_state(helper, "idle") - helper.ec_command("sbmock temperature 2981") - wait_charge_state(helper, "charge") - - # While powered on and charging, under-temperature should stop battery - # from charging - helper.ec_command("sbmock temperature 2600") - wait_charge_state(helper, "idle") - helper.ec_command("sbmock temperature 2981") - wait_charge_state(helper, "charge") - - return True # PASS ! diff --git a/test/charging.tasklist b/test/charging.tasklist deleted file mode 100644 index 26cfc53453..0000000000 --- a/test/charging.tasklist +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * List of enabled tasks in the priority order - * - * The first one has the lowest priority. - * - * For each task, use the macro TASK_TEST(n, r, d, s) where : - * 'n' in the name of the task - * 'r' in the main routine of the task - * 'd' in an opaque parameter passed to the routine at startup - * 's' is the stack size in bytes; must be a multiple of 8 - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/mutex.py b/test/mutex.py deleted file mode 100644 index afd342938c..0000000000 --- a/test/mutex.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Mutexes test -# - -def test(helper): - helper.wait_output("[Mutex main task") - - # 3 locking in a row without contention - helper.wait_output("No contention :done.") - - # serialization (simple contention) - helper.wait_output("Simple contention :") - helper.wait_output("MTX2: locking...done") - helper.wait_output("MTX1: blocking...") - helper.wait_output("MTX1: get lock") - - # multiple contention - helper.wait_output("Massive locking/unlocking :") - #TODO check sequence - helper.wait_output("Test done.") - - return True # PASS ! diff --git a/test/pingpong.py b/test/pingpong.py deleted file mode 100644 index df7d4b38c5..0000000000 --- a/test/pingpong.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Task scheduling test -# - -import time - -# Test during 5s -DURATION=5 - -def test(helper): - helper.wait_output("[starting Task T]") - helper.wait_output("[starting Task C]") - helper.wait_output("[starting Task B]") - helper.wait_output("[starting Task A]") - deadline = time.time() + DURATION - count = [] - while time.time() < deadline: - sched = helper.wait_output("(?P<a>(?:ABC){3,200})T", use_re=True, - timeout=1)["a"] - count.append(len(sched) / 3) - - helper.trace("IRQ count %d, cycles count min %d max %d\n" % - (len(count), min(count), max(count))) - return True # PASS ! diff --git a/test/scancode.py b/test/scancode.py deleted file mode 100644 index 6437e24e59..0000000000 --- a/test/scancode.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# i8042 scancode test -# - -def test(helper): - # Wait for EC initialized - helper.wait_output("--- UART initialized") - - # Disable typematic - helper.ec_command("typematic 1000000 1000000") - - # Enable XLATE (Scan code set 1) - helper.ec_command("ctrlram 0 0x40") - helper.ec_command("mockmatrix 1 1 1") - helper.wait_output("i8042 SEND: 01") # make code - helper.ec_command("mockmatrix 1 1 0") - helper.wait_output("i8042 SEND: 81") # break code - - # Disable XLATE (Scan code set 2) - helper.ec_command("ctrlram 0 0x00") - helper.ec_command("mockmatrix 1 1 1") - helper.wait_output("i8042 SEND: 76") # make code - helper.ec_command("mockmatrix 1 1 0") - helper.wait_output("i8042 SEND: f0 76") # break code - - return True # PASS ! diff --git a/test/scancode.tasklist b/test/scancode.tasklist deleted file mode 100644 index 26cfc53453..0000000000 --- a/test/scancode.tasklist +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * List of enabled tasks in the priority order - * - * The first one has the lowest priority. - * - * For each task, use the macro TASK_TEST(n, r, d, s) where : - * 'n' in the name of the task - * 'r' in the main routine of the task - * 'd' in an opaque parameter passed to the routine at startup - * 's' is the stack size in bytes; must be a multiple of 8 - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/thermal_old.c b/test/thermal_old.c deleted file mode 100644 index 485e19bfb5..0000000000 --- a/test/thermal_old.c +++ /dev/null @@ -1,426 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test thermal engine. - */ - -#include "common.h" -#include "console.h" -#include "hooks.h" -#include "host_command.h" -#include "printf.h" -#include "temp_sensor.h" -#include "test_util.h" -#include "thermal.h" -#include "timer.h" -#include "util.h" - -static int mock_temp[TEMP_SENSOR_COUNT]; -static int fan_rpm; -static int fan_rpm_mode = 1; -static int cpu_throttled; -static int cpu_down; - -extern struct thermal_config_t thermal_config[TEMP_SENSOR_TYPE_COUNT]; -extern const int fan_speed[THERMAL_FAN_STEPS + 1]; - -/*****************************************************************************/ -/* Mock functions */ - -int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) -{ - if (mock_temp[id] >= 0) { - *temp_ptr = mock_temp[id]; - return EC_SUCCESS; - } else { - return -mock_temp[id]; - } -} - -void pwm_set_fan_rpm_mode(int rpm_mode) -{ - fan_rpm_mode = rpm_mode; -} - -void pwm_set_fan_target_rpm(int rpm) -{ - fan_rpm = rpm; -} - -void chipset_force_shutdown(void) -{ - cpu_down = 1; -} - -void chipset_throttle_cpu(int throttled) -{ - cpu_throttled = throttled; -} - -/*****************************************************************************/ -/* Test utilities */ - -/* Test shorthands */ -#define T_CPU TEMP_SENSOR_CPU -#define T_BOARD TEMP_SENSOR_BOARD -#define T_CASE TEMP_SENSOR_CASE -#define THRESHOLD(x, y) (thermal_config[x].thresholds[y]) -#define FAN_THRESHOLD(x, y) THRESHOLD(x, THRESHOLD_COUNT + (y)) - -static void reset_mock_temp(void) -{ - int i; - enum temp_sensor_type type; - for (i = 0; i < TEMP_SENSOR_COUNT; ++i) { - type = temp_sensors[i].type; - mock_temp[i] = FAN_THRESHOLD(type, 0) - 1; - } -} - -static int wait_fan_rpm(int rpm, int timeout_secs) -{ - do { - if (fan_rpm == rpm) - return 1; - usleep(SECOND); - } while (timeout_secs--); - - return 0; -} - -static int wait_value(int *v, int target, int timeout_secs) -{ - do { - if (*v == target) - return 1; - usleep(SECOND); - } while (timeout_secs--); - - return 0; -} - -static int wait_set(int *v, int timeout_secs) -{ - return wait_value(v, 1, timeout_secs); -} - -static int wait_clear(int *v, int timeout_secs) -{ - return wait_value(v, 0, timeout_secs); -} - -/*****************************************************************************/ -/* Tests */ - -static int test_init_val(void) -{ - /* Initial mock temperature values are all zero. */ - TEST_ASSERT(cpu_throttled == 0); - TEST_ASSERT(cpu_down == 0); - TEST_ASSERT(!(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_OVERLOAD))); - TEST_ASSERT(!(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN))); - - return EC_SUCCESS; -} - -static int test_cpu_fan(void) -{ - reset_mock_temp(); - - /* - * Increase CPU temperature to first fan step and check if - * the fan comes up. - */ - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 0); - TEST_ASSERT(wait_fan_rpm(fan_speed[1], 11)); - - /* Increase CPU temperature to second fan step */ - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 1); - TEST_ASSERT(wait_fan_rpm(fan_speed[2], 11)); - - /* Test threshold hysteresis */ - mock_temp[T_CPU]--; - usleep(15 * SECOND); - TEST_ASSERT(fan_rpm == fan_speed[2]); - - /* Test action delay */ - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 4); - usleep((temp_sensors[T_CPU].action_delay_sec - 1) * SECOND); - TEST_ASSERT(fan_rpm == fan_speed[2]); - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 0); - - return EC_SUCCESS; -} - -static int test_safety(void) -{ - reset_mock_temp(); - - /* Trigger CPU throttling */ - mock_temp[T_CPU] = THRESHOLD(T_CPU, THRESHOLD_WARNING); - TEST_ASSERT(wait_set(&cpu_throttled, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_OVERLOAD)); - - /* Lower temperature. CPU not throttled anymore. */ - mock_temp[T_CPU] = THRESHOLD(T_CPU, THRESHOLD_WARNING) - 5; - TEST_ASSERT(wait_clear(&cpu_throttled, 2)); - - /* Thermal shutdown */ - mock_temp[T_CPU] = THRESHOLD(T_CPU, THRESHOLD_CPU_DOWN); - TEST_ASSERT(wait_set(&cpu_down, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN)); - - mock_temp[T_CPU] = 0; - usleep(SECOND); - cpu_down = 0; - - mock_temp[T_CPU] = THRESHOLD(T_CPU, THRESHOLD_POWER_DOWN); - TEST_ASSERT(wait_set(&cpu_down, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN)); - - mock_temp[T_CPU] = 0; - cpu_down = 0; - - return EC_SUCCESS; -} - -static int test_sensor_failure(void) -{ - reset_mock_temp(); - - /* Failure due to sensor not powered should be ignored */ - mock_temp[T_CPU] = -EC_ERROR_NOT_POWERED; - usleep(5 * SECOND); - TEST_ASSERT(!(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL))); - - /* Other failure should be pumped up to host */ - mock_temp[T_CPU] = -EC_ERROR_UNKNOWN; - usleep(5 * SECOND); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL)); - - return EC_SUCCESS; -} - -static int test_sensor_info(void) -{ - struct ec_params_temp_sensor_get_info params; - struct ec_response_temp_sensor_get_info resp; - int i; - - for (i = 0; i < TEMP_SENSOR_COUNT; ++i) { - params.id = i; - TEST_ASSERT(test_send_host_command( - EC_CMD_TEMP_SENSOR_GET_INFO, - 0, ¶ms, sizeof(params), - &resp, sizeof(resp)) == EC_RES_SUCCESS); - TEST_ASSERT_ARRAY_EQ(resp.sensor_name, - temp_sensors[i].name, - strlen(resp.sensor_name)); - TEST_ASSERT(resp.sensor_type == temp_sensors[i].type); - } - - params.id = TEMP_SENSOR_COUNT; - TEST_ASSERT(test_send_host_command( - EC_CMD_TEMP_SENSOR_GET_INFO, - 0, ¶ms, sizeof(params), - &resp, sizeof(resp)) != EC_RES_SUCCESS); - - return EC_SUCCESS; -} - -static int set_threshold(int type, int threshold_id, int val) -{ - struct ec_params_thermal_set_threshold params; - - params.sensor_type = type; - params.threshold_id = threshold_id; - params.value = val; - - return test_send_host_command(EC_CMD_THERMAL_SET_THRESHOLD, 0, ¶ms, - sizeof(params), NULL, 0); -} - -static int get_threshold(int type, int threshold_id, int *val) -{ - struct ec_params_thermal_get_threshold params; - struct ec_response_thermal_get_threshold resp; - int rv; - - params.sensor_type = type; - params.threshold_id = threshold_id; - - rv = test_send_host_command(EC_CMD_THERMAL_GET_THRESHOLD, 0, ¶ms, - sizeof(params), &resp, sizeof(resp)); - if (rv != EC_RES_SUCCESS) - return rv; - - *val = resp.value; - return EC_RES_SUCCESS; -} - -static int verify_threshold(int type, int threshold_id, int val) -{ - int actual_val; - - if (get_threshold(type, threshold_id, &actual_val) != EC_RES_SUCCESS) - return 0; - return val == actual_val; -} - -static int test_threshold_hostcmd(void) -{ - reset_mock_temp(); - - /* Verify thresholds */ - TEST_ASSERT(verify_threshold(T_CPU, THRESHOLD_WARNING, - THRESHOLD(T_CPU, THRESHOLD_WARNING))); - TEST_ASSERT(verify_threshold(T_BOARD, THRESHOLD_WARNING, - THRESHOLD(T_BOARD, THRESHOLD_WARNING))); - TEST_ASSERT(verify_threshold(T_CPU, THRESHOLD_CPU_DOWN, - THRESHOLD(T_CPU, THRESHOLD_CPU_DOWN))); - - /* Lower CPU throttling threshold and trigger */ - TEST_ASSERT(set_threshold(T_CPU, THRESHOLD_WARNING, 350) == - EC_RES_SUCCESS); - mock_temp[T_CPU] = 355; - TEST_ASSERT(wait_set(&cpu_throttled, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_OVERLOAD)); - - /* Lower thermal shutdown threshold */ - TEST_ASSERT(set_threshold(T_CPU, THRESHOLD_CPU_DOWN, 353) == - EC_RES_SUCCESS); - TEST_ASSERT(wait_set(&cpu_down, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN)); - - /* Clear */ - mock_temp[T_CPU] = 0; - TEST_ASSERT(wait_clear(&cpu_throttled, 2)); - cpu_down = 0; - - return EC_SUCCESS; -} - -static int test_threshold_console_cmd(void) -{ - char buf[100]; - - reset_mock_temp(); - - /* Lower CPU threshold and trigger */ - snprintf(buf, 100, "thermalconf %d %d 330\n", T_CPU, THRESHOLD_WARNING); - UART_INJECT(buf); - msleep(100); - mock_temp[T_CPU] = 335; - TEST_ASSERT(wait_set(&cpu_throttled, 11)); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_OVERLOAD)); - - /* Set first fan step to 280 K */ - snprintf(buf, 100, "thermalfan %d 0 280\n", T_CPU); - UART_INJECT(buf); - msleep(100); - mock_temp[T_CPU] = 280; - TEST_ASSERT(wait_fan_rpm(fan_speed[1], 11)); - - return EC_SUCCESS; -} - -static int test_invalid_hostcmd(void) -{ - int dummy; - - TEST_ASSERT(set_threshold(TEMP_SENSOR_TYPE_COUNT, THRESHOLD_WARNING, - 100) != EC_RES_SUCCESS); - TEST_ASSERT(set_threshold(T_CPU, THRESHOLD_COUNT + THERMAL_FAN_STEPS, - 100) != EC_RES_SUCCESS); - TEST_ASSERT(get_threshold(TEMP_SENSOR_TYPE_COUNT, THRESHOLD_WARNING, - &dummy) != EC_RES_SUCCESS); - TEST_ASSERT(get_threshold(T_CPU, THRESHOLD_COUNT + THERMAL_FAN_STEPS, - &dummy) != EC_RES_SUCCESS); - - return EC_SUCCESS; -} - -static int test_auto_fan_ctrl(void) -{ - reset_mock_temp(); - - /* Disable fan control */ - pwm_set_fan_rpm_mode(0); - thermal_control_fan(0); - - /* - * Increase CPU temperature to first fan step and check the fan - * doesn't come up. - */ - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 0); - TEST_ASSERT(!wait_fan_rpm(fan_speed[1], 11)); - - /* Enable fan control */ - TEST_ASSERT(test_send_host_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, 0, - NULL, 0, NULL, 0) == EC_RES_SUCCESS); - TEST_ASSERT(fan_rpm_mode == 1); - TEST_ASSERT(wait_fan_rpm(fan_speed[1], 11)); - - /* Disable fan control */ - pwm_set_fan_rpm_mode(0); - thermal_control_fan(0); - - /* Increase CPU temperature to second fan step */ - mock_temp[T_CPU] = FAN_THRESHOLD(T_CPU, 1); - TEST_ASSERT(!wait_fan_rpm(fan_speed[2], 11)); - - /* Enable fan control by console command */ - UART_INJECT("autofan\n"); - msleep(100); - TEST_ASSERT(fan_rpm_mode == 1); - TEST_ASSERT(wait_fan_rpm(fan_speed[2], 11)); - - - return EC_SUCCESS; -} - -static int check_assumption(void) -{ - TEST_ASSERT((int)TEMP_SENSOR_CPU == (int)TEMP_SENSOR_TYPE_CPU); - TEST_ASSERT((int)TEMP_SENSOR_BOARD == (int)TEMP_SENSOR_TYPE_BOARD); - TEST_ASSERT((int)TEMP_SENSOR_CASE == (int)TEMP_SENSOR_TYPE_CASE); - - TEST_ASSERT(temp_sensors[T_CPU].action_delay_sec != 0); - - TEST_ASSERT(thermal_config[T_CPU].config_flags & - THERMAL_CONFIG_WARNING_ON_FAIL); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - /* Test assumptions */ - RUN_TEST(check_assumption); - - RUN_TEST(test_init_val); - RUN_TEST(test_cpu_fan); - /* No tests for board and case temp sensors as they are ignored. */ - RUN_TEST(test_safety); - RUN_TEST(test_sensor_failure); - RUN_TEST(test_auto_fan_ctrl); - RUN_TEST(test_sensor_info); - RUN_TEST(test_threshold_hostcmd); - RUN_TEST(test_invalid_hostcmd); - RUN_TEST(test_threshold_console_cmd); - - test_print_result(); -} diff --git a/test/thermal_old.py b/test/thermal_old.py deleted file mode 100644 index 3a0453c3bb..0000000000 --- a/test/thermal_old.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Thermal engine unit test -# - -CPU = 0 -BOARD = 1 -CASE = 2 - -def getWarningConfig(helper, sensor_type): - ret = dict() - helper.ec_command("thermalconf %d" % sensor_type) - ret['warning'] = int(helper.wait_output( - "Warning:\s*(?P<t>\d+) K", use_re=True)["t"]) - ret['cpudown'] = int(helper.wait_output( - "CPU Down:\s*(?P<t>\d+) K", use_re=True)["t"]) - ret['powerdown'] = int(helper.wait_output( - "Power Down:\s*(?P<t>\d+) K", use_re=True)["t"]) - return ret - -def getFanConfig(helper, sensor_type): - ret = list() - helper.ec_command("thermalfan %d" % sensor_type) - while True: - try: - match = helper.wait_output("(?P<t>\d+)\s*K:\s*(?P<r>-?\d+)\s", - use_re=True, timeout=1) - ret.append((int(match["t"]), int(match["r"]))) - except: - break - return ret - - -def test(helper): - helper.wait_output("Inits done") - - # Get thermal engine configuration - config = [getWarningConfig(helper, sensor_type) - for sensor_type in xrange(3)] - fan_config = [getFanConfig(helper, sensor_type) - for sensor_type in xrange(3)] - - # Set initial temperature values - helper.ec_command("setcputemp %d" % max(fan_config[CPU][0][0]-1, 0)) - helper.ec_command("setboardtemp %d" % max(fan_config[BOARD][0][0]-1, 0)) - helper.ec_command("setcasetemp %d" % max(fan_config[CASE][0][0]-1, 0)) - - # Increase CPU temperature to first fan step - # Check if fan comes up - helper.ec_command("setcputemp %d" % fan_config[CPU][0][0]) - helper.wait_output("Fan RPM: %d" % fan_config[CPU][0][1], timeout=11) - - # Increase CPU temperature to second fan step - helper.ec_command("setcputemp %d" % fan_config[CPU][1][0]) - helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1], timeout=11) - - # Lower CPU temperature to 1 degree below second fan step - # Check fan speed doesn't change - helper.ec_command("setcputemp %d" % (fan_config[CPU][1][0]-1)) - for i in xrange(12): - helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1], timeout=2) - - # Set CPU temperature to a high value for only one second - # Check fan speed doesn't change - helper.ec_command("setcputemp 400") - helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1]) - helper.ec_command("setcputemp %d" % fan_config[CPU][1][0]) - - # Set case temperature to first fan step - # Check fan is set to second step - helper.ec_command("setcasetemp %d" % fan_config[CASE][0][0]) - for i in xrange(12): - helper.wait_output("Fan RPM: %d" % fan_config[CASE][1][1], timeout=2) - - # Set case temperature to third fan step - # Check fan is set to third step - helper.ec_command("setcasetemp %d" % fan_config[CASE][2][0]) - helper.wait_output("Fan RPM: %d" % fan_config[CASE][2][1], timeout=11) - - # Set CPU temperature to trigger warning and throttle CPU - helper.ec_command("setcputemp %d" % config[CPU]['warning']) - helper.wait_output("Throttle CPU.", timeout=11) - host_event = helper.wait_output("Host event: (?P<h>\d+)", use_re=True, - timeout=2)["h"] - if (int(host_event, 16) & 0x200) == 0: - helper.trace("Fail to get thermal overload event") - return False - - # Lower CPU temperature and check CPU is not throttled - helper.ec_command("setcputemp %d" % (config[CPU]['warning']-5)) - helper.wait_output("No longer throttle CPU.", timeout=2) - - # Set CPU temperature to trigger CPU shutdown - helper.ec_command("setcputemp %d" % config[CPU]['cpudown']) - helper.wait_output("CPU overheated", timeout=11) - - # Set CPU temperature to trigger force shutdown - helper.ec_command("setcputemp %d" % config[CPU]['powerdown']) - helper.wait_output("Force shutdown", timeout=11) - - # Pass! - return True diff --git a/test/typematic.py b/test/typematic.py deleted file mode 100644 index f61f0ccd86..0000000000 --- a/test/typematic.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Keyboard typematic test -# - -import time - -KEY_PRESS_MSG = "i8042 SEND" - -def expect_keypress(helper, lower_bound, upper_bound): - for i in xrange(lower_bound + 1): # Plus 1 break code - helper.wait_output(KEY_PRESS_MSG) - for i in xrange(upper_bound - lower_bound): - if helper.check_no_output(KEY_PRESS_MSG): - return True - if not helper.check_no_output(KEY_PRESS_MSG): - return False - return True - -def test(helper): - # Wait for EC initialized - helper.wait_output("--- UART initialized") - - # Enable keyboard scanning - helper.ec_command("kbd enable") - time.sleep(0.1) # Workaround for crosbug/p/11015 - - # Set typematic rate to 1000ms/500ms and hold down a key for 500ms - # Expect 1 keypress. - helper.ec_command("typematic 1000 500") - helper.ec_command("mockmatrix 1 1 1") - time.sleep(0.5) - helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 1, 1): - return False - - # Hold down a key for 1200ms. Expect 2 keypress. - helper.ec_command("mockmatrix 1 1 1") - time.sleep(1.2) - helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 2, 2): - return False - - # Hold down a key for 1700ms. Expect 3 keypress. - helper.ec_command("mockmatrix 1 1 1") - time.sleep(1.7) - helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 3, 3): - return False - - # Hold down a key for 5400ms. Expect 9 or 10 keypress. - # Due to inevitable delay incurred by each keypress, we cannot be certain - # about the exact number of keypress. Therefore, mismatching by a small - # amount should be accepted. - helper.ec_command("mockmatrix 1 1 1") - time.sleep(5.4) - helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 9, 10): - return False - - return True # PASS ! diff --git a/test/typematic.tasklist b/test/typematic.tasklist deleted file mode 100644 index 26cfc53453..0000000000 --- a/test/typematic.tasklist +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * List of enabled tasks in the priority order - * - * The first one has the lowest priority. - * - * For each task, use the macro TASK_TEST(n, r, d, s) where : - * 'n' in the name of the task - * 'r' in the main routine of the task - * 'd' in an opaque parameter passed to the routine at startup - * 's' is the stack size in bytes; must be a multiple of 8 - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/util/qemu-system-arm b/util/qemu-system-arm Binary files differdeleted file mode 100755 index 27a01a9868..0000000000 --- a/util/qemu-system-arm +++ /dev/null diff --git a/util/run_qemu_test b/util/run_qemu_test deleted file mode 100755 index 1889eedcf3..0000000000 --- a/util/run_qemu_test +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Python wrapper script for running tests under QEMU -# - -import errno -import imp -import json -import os -import optparse -import re -import signal -import socket -import subprocess -import sys -import threading -import time - -QEMU_BINARY="qemu-system-arm" -QEMU_OPTIONS=["-machine","lm4f232h5","-serial","stdio","-display","none"] - -def trace(msg): - sys.stdout.write(msg) - -class QEMUError(Exception): - def __init__(self, value): - self.value = value - - def __str__(self): - return "QEMU Error:" + repr(self.value) - -class QEMUInstance: - PORT=3456 - QMP_ADDR=("127.0.0.1", PORT) - - def __run_qemu(self, cmdline, redirect_stdio=False): - trace("Starting QEMU binary ...\n") - if redirect_stdio: - stdin = subprocess.PIPE - stdout = subprocess.PIPE - else: - stdin = None - stdout = None - self.__qemu = subprocess.Popen(cmdline, shell=False, bufsize=16384, - stdin=stdin, stdout=stdout, close_fds=True) - trace("QEMU started pid:%d\n" % (self.__qemu.pid)) - self.__qemu.wait() - trace("QEMU has terminated\n") - - def __init__(self, qemu_bin, firmware, romcode = None, testmode = False): - self.__events = [] - cmdline = [qemu_bin] + QEMU_OPTIONS + ["-kernel",firmware,"-qmp","tcp:%s:%d" % self.QMP_ADDR] - if romcode: - cmdline += ["-bios",romcode] - self.__sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.__sock.bind(self.QMP_ADDR) - self.__sock.listen(1) - - self.__thr = threading.Thread(target=QEMUInstance.__run_qemu,args=(self,cmdline,testmode)) - self.__thr.start() - try: - trace("Waiting for QEMU connection ...\n") - self.__sock, _ = self.__sock.accept() - self.__sockfd = self.__sock.makefile() - except socket.error: - raise QEMUError('Cannot connect to QMP server') - - version = self.__json_recv() - if version is None or not version.has_key('QMP'): - raise QEMUError('Not QMP support') - # Test basic communication with QMP - resp = self.send_qmp('qmp_capabilities') - if not "return" in resp: - raise QEMUError('QMP not working properly') - trace("QMP connected\n") - - def __json_recv(self, only_event=False): - while True: - data = self.__sockfd.readline() - if not data: - return - return json.loads(data) - - def send_qmp(self, name, args=None): - qmp_cmd = { 'execute': name } - if args: - qmp_cmd['arguments'] = args - try: - self.__sock.sendall(json.dumps(qmp_cmd)) - except socket.error, err: - if err[0] == errno.EPIPE: - return - raise QEMUError("Error on QMP socket:" + err) - return self.__json_recv() - - def serial_readline(self): - return self.__qemu.stdout.readline() - - def serial_write(self, string): - self.__qemu.stdin.write(string) - self.__qemu.stdin.flush() - - def get_event(self, blocking=True): - if not blocking: - self.__sock.setblocking(0) - try: - val = self.__json_recv() - except socket.error, err: - if err[0] == errno.EAGAIN: - # Nothing available - return None - if not blocking: - self.__sock.setblocking(1) - return val - - def close(self): - # Try to terminate QEMU gracefully - if self.__qemu.poll() == None: - self.send_qmp("quit") - time.sleep(0.1) - # Force termination if the process is still here : - if self.__qemu.poll() == None: - self.__qemu.terminate() - self.__thr.join() - self.__sock.close() - self.__sockfd.close() - -class TestFailure(Exception): - def __init__(self, reason): - self.value = reason - - def __str__(self): - return "reason:" + repr(self.value) - -class EcTest: - def __init__(self, qemu_bin, firmware, romcode, test): - self.__qemu_bin = qemu_bin - self.__firmware = firmware - self.__romcode = romcode - self.__test = test - - def timeout_handler(self, signum, frame): - raise TestFailure("Timeout waiting for %s" % self.__timeout_reason) - - def wait_output(self, string, use_re = False, timeout = 5): - self.__timeout_reason = string - old_handler = signal.signal(signal.SIGALRM, lambda - s,f:self.timeout_handler(s,f)) - if use_re: - regexp = re.compile(string) - signal.alarm(timeout) - while True: - ln = self.__qemu.serial_readline() - trace("[EC]%s" % ln) - if use_re: - res = regexp.search(ln) - if res: - signal.alarm(0) - signal.signal(signal.SIGALRM, old_handler) - return res.groupdict() - else: - if string in ln: - signal.alarm(0) - signal.signal(signal.SIGALRM, old_handler) - return - - def check_no_output(self, string, use_re = False, timeout = 1): - success = False - try: - self.wait_output(string, use_re=use_re, timeout=timeout) - except: - success = True - return success - - - def wait_prompt(self): - self.wait_output("> ") - - def ec_command(self, cmd): - self.__qemu.serial_write(cmd + '\r\n') - - def trace(self, msg): - trace(msg) - - def report(self, msg): - sys.stderr.write(" === TEST %s ===\n" % msg) - - def fail(self, msg): - raise TestFailure(msg) - - def run_test(self): - try: - self.__qemu = QEMUInstance(self.__qemu_bin, self.__firmware, - self.__romcode, True) - except QEMUError as e: - self.report("QEMU FATAL ERROR: " + e.value) - return 1 - - # Set up import path so each test can import other modules inside 'test' - sys.path.insert(0, os.path.dirname(os.path.abspath(self.__test))) - - testmod = imp.load_module("testmodule", file(self.__test,"r"), - self.__test, (".py","r",imp.PY_SOURCE)) - self.report("RUN: %s" % os.path.basename(self.__test)) - try: - res = testmod.test(self) - except TestFailure as e: - res = False - self.report("FAIL: %s" % e.value) - self.__qemu.close() - if res: - self.report("PASS") - return 0 - return 1 - -def run_interactive(qemu_bin, firmware, romcode): - try: - qemu = QEMUInstance(qemu_bin, firmware, romcode, False) - except QEMUError as e: - sys.stderr.write('FATAL: %s\n' % e.value) - return 1 - - # Dummy testing code : TODO remove - #print qemu.send_qmp("query-commands") - #print qemu.send_qmp("human-monitor-command", - # { 'command-line': "sendkey ctrl-alt-f1 50",'cpu-index': 0 }) - while True: - msg = qemu.get_event() - trace("[EVENT]%s\n" % msg) - if msg.has_key("event") and msg["event"] == "RESET": - break - qemu.close() - return 0 - -def parse_cmdline(basedir): - parser = optparse.OptionParser("usage: %prog [options] [testname]") - parser.add_option("-b", "--board", dest="board", default="bds", - help="board to use") - parser.add_option("-i", "--image", dest="image", - help="firmware image filename") - parser.add_option("-r", "--rom", dest="romcode", - default=os.path.join(basedir,"util","rom_lm4fs1ge5bb.bin"), - help="ROM code image filename") - parser.add_option("-q", "--qemu", dest="qemu_bin", - default=os.path.join(basedir,"util",QEMU_BINARY), - help="Qemu binary path") - (options, args) = parser.parse_args() - if options.image: - image = options.image - else: - image = os.path.join(basedir,"build",options.board,"ec.bin") - - return options.qemu_bin, image,options.romcode, args - -if __name__ == '__main__': - basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),"..")) - qemu_bin, image, romcode, tests = parse_cmdline(basedir) - if len(tests) > 0: - res = EcTest(qemu_bin, image, romcode, tests[0]).run_test() - else: - res = run_interactive(qemu_bin, image, romcode) - sys.exit(res) |