summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-09-16 15:44:19 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-19 23:30:03 +0000
commit883dd51006600d78ccfc6c6ff73a66943492538e (patch)
treed1912eee4a95dfa385a87d7bbbca59a55fa2b137
parenta7f5224a83ac58b569a0a3c3c95549d38f448171 (diff)
downloadchrome-ec-883dd51006600d78ccfc6c6ff73a66943492538e.tar.gz
cleanup: move test mocks to board/host and remove unused mocks
Now that we have a better test framework in place, mock implementations go in either chip/host/ or board/host/, depending on whether they're mocking chip or common/board functionality. Move the remaining mocks there. Also, several mocks were neither compiled nor used, and haven't kept pace with other refactoring; delete those. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all board; pass all unit tests Change-Id: Ie2a81c3ccd4506679192d979aa87fe7ed6c1c5a0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169873
-rw-r--r--board/host/build.mk1
-rw-r--r--board/host/charger.c (renamed from common/mock_charger.c)0
-rw-r--r--board/host/smart_battery.c (renamed from common/mock_smart_battery.c)0
-rw-r--r--common/build.mk1
-rw-r--r--common/mock_i8042.c45
-rw-r--r--common/mock_temp_sensor.c76
-rw-r--r--common/mock_x86_power.c90
7 files changed, 1 insertions, 212 deletions
diff --git a/board/host/build.mk b/board/host/build.mk
index 8b6ee6d2be..42cd2f61b9 100644
--- a/board/host/build.mk
+++ b/board/host/build.mk
@@ -10,3 +10,4 @@ CHIP:=host
board-y=board.o
board-$(HAS_TASK_CHIPSET)+=chipset.o
+board-$(CONFIG_BATTERY_MOCK)+=smart_battery.o charger.o
diff --git a/common/mock_charger.c b/board/host/charger.c
index f63eebbea3..f63eebbea3 100644
--- a/common/mock_charger.c
+++ b/board/host/charger.c
diff --git a/common/mock_smart_battery.c b/board/host/smart_battery.c
index 0620de6e39..0620de6e39 100644
--- a/common/mock_smart_battery.c
+++ b/board/host/smart_battery.c
diff --git a/common/build.mk b/common/build.mk
index 3946396e73..39c38d00c9 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -22,7 +22,6 @@ common-$(CONFIG_BACKLIGHT_X86)+=backlight_x86.o
common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o
common-$(CONFIG_BATTERY_BQ27541)+=battery.o battery_bq27541.o
common-$(CONFIG_BATTERY_LINK)+=battery_link.o
-common-$(CONFIG_BATTERY_MOCK)+=mock_smart_battery.o mock_charger.o
common-$(CONFIG_BATTERY_SMART)+=battery.o smart_battery.o
common-$(CONFIG_CHARGER)+=charge_state.o charger_common.o
common-$(CONFIG_CHARGER_BQ24192)+=charger_bq24192.o
diff --git a/common/mock_i8042.c b/common/mock_i8042.c
deleted file mode 100644
index dac11e2f1b..0000000000
--- a/common/mock_i8042.c
+++ /dev/null
@@ -1,45 +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 EC i8042 interface code.
- */
-
-#include "keyboard_i8042.h"
-#include "timer.h"
-#include "uart.h"
-
-void keyboard_receive(int data, int is_cmd)
-{
- /* Not implemented */
- return;
-}
-
-void keyboard_protocol_task(void)
-{
- /* Do nothing */
- while (1)
- sleep(5);
-}
-
-enum ec_error_list i8042_send_to_host(int len, const uint8_t *bytes)
-{
- int i;
- uart_printf("i8042 SEND:");
- for (i = 0; i < len; ++i)
- uart_printf(" %02x", bytes[i]);
- uart_printf("\n");
- return EC_SUCCESS;
-}
-
-void i8042_enable_keyboard_irq(int enable)
-{
- /* Not implemented */
- return;
-}
-
-void i8042_flush_buffer()
-{
- /* Not implemented */
- return;
-}
diff --git a/common/mock_temp_sensor.c b/common/mock_temp_sensor.c
deleted file mode 100644
index d558f8898e..0000000000
--- a/common/mock_temp_sensor.c
+++ /dev/null
@@ -1,76 +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 temperature sensor module for Chrome EC */
-
-#include "common.h"
-#include "console.h"
-#include "temp_sensor.h"
-#include "timer.h"
-#include "util.h"
-
-static int temp_val[TEMP_SENSOR_TYPE_COUNT];
-
-int temp_sensor_powered(enum temp_sensor_id id)
-{
- /* Always powered */
- return 1;
-}
-
-
-int temp_sensor_read(enum temp_sensor_id id)
-{
- return temp_val[temp_sensors[id].type];
-}
-
-
-void temp_sensor_task(void)
-{
- /* Do nothing */
- while (1)
- sleep(5);
-}
-
-
-static int command_set_temp(int argc, char **argv, int type)
-{
- char *e;
- int t;
-
- ASSERT(argc == 2);
- t = strtoi(argv[1], &e, 0);
- temp_val[type] = t;
- return EC_SUCCESS;
-}
-
-
-static int command_set_cpu_temp(int argc, char **argv)
-{
- return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CPU);
-}
-DECLARE_CONSOLE_COMMAND(setcputemp, command_set_cpu_temp,
- "value",
- "Set mock CPU temperature value",
- NULL);
-
-
-static int command_set_board_temp(int argc, char **argv)
-{
- return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_BOARD);
-}
-DECLARE_CONSOLE_COMMAND(setboardtemp, command_set_board_temp,
- "value",
- "Set mock board temperature value",
- NULL);
-
-
-static int command_set_case_temp(int argc, char **argv)
-{
- return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CASE);
-}
-DECLARE_CONSOLE_COMMAND(setcasetemp, command_set_case_temp,
- "value",
- "Set mock case temperature value",
- NULL);
diff --git a/common/mock_x86_power.c b/common/mock_x86_power.c
deleted file mode 100644
index daceee57b1..0000000000
--- a/common/mock_x86_power.c
+++ /dev/null
@@ -1,90 +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 X86 chipset power control module for Chrome EC */
-
-#include "chipset.h"
-#include "chipset_x86_common.h"
-#include "console.h"
-#include "lpc.h"
-#include "timer.h"
-#include "uart.h"
-#include "util.h"
-
-static int mock_power_on = 0;
-
-void chipset_force_shutdown(void)
-{
- uart_puts("Force shutdown\n");
- mock_power_on = 0;
-}
-
-
-void chipset_reset(int cold_reset)
-{
- uart_printf("X86 Power %s reset\n", cold_reset ? "cold" : "warm");
-}
-
-
-void chipset_throttle_cpu(int throttle)
-{
- /* Print transitions */
- static int last_val = 0;
- if (throttle != last_val) {
- if (throttle)
- uart_printf("Throttle CPU.\n");
- else
- uart_printf("No longer throttle CPU.\n");
- last_val = throttle;
- }
-}
-
-
-void chipset_exit_hard_off(void)
-{
- /* Not implemented */
- return;
-}
-
-
-int chipset_in_state(int state_mask)
-{
- if (mock_power_on)
- return state_mask == CHIPSET_STATE_ON;
- else
- return (state_mask == CHIPSET_STATE_SOFT_OFF) ||
- (state_mask == CHIPSET_STATE_ANY_OFF);
-}
-
-
-void x86_interrupt(enum gpio_signal signal)
-{
- /* Not implemented */
- return;
-}
-
-
-void chipset_task(void)
-{
- /* Do nothing */
- while (1)
- sleep(5);
-}
-
-
-static int command_mock_power(int argc, char **argv)
-{
- if (argc != 2)
- return EC_ERROR_PARAM_COUNT;
-
- if (!parse_bool(argv[1], &mock_power_on))
- return EC_ERROR_PARAM1;
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(powermock, command_mock_power,
- "<on | off>",
- "Mock power state",
- NULL);