sandbox: add a sandbox timer and basic test

Add a sandbox timer which get time from host os and a basic
test.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Thomas Chou
2015-10-30 15:35:52 +08:00
committed by Simon Glass
parent 6752195760
commit 9961a0b6fb
10 changed files with 106 additions and 0 deletions

View File

@@ -33,5 +33,6 @@ obj-y += syscon.o
obj-$(CONFIG_DM_USB) += usb.o
obj-$(CONFIG_DM_PMIC) += pmic.o
obj-$(CONFIG_DM_REGULATOR) += regulator.o
obj-$(CONFIG_TIMER) += timer.o
obj-$(CONFIG_ADC) += adc.o
endif

27
test/dm/timer.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <timer.h>
#include <dm/test.h>
#include <test/ut.h>
DECLARE_GLOBAL_DATA_PTR;
/*
* Basic test of the timer uclass.
*/
static int dm_test_timer_base(struct unit_test_state *uts)
{
struct udevice *dev;
ut_assertok(uclass_get_device(UCLASS_TIMER, 0, &dev));
ut_asserteq(1000000, timer_get_rate(dev));
return 0;
}
DM_TEST(dm_test_timer_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);