[U-Boot] [PATCH v2 26/26] dm: test: usb: sandbox: Add keyboard tests for sandbox
Simon Glass
sjg at chromium.org
Mon Nov 9 07:48:08 CET 2015
Add a test that verifies that USB keyboards work correctly on sandbox.
This verifies some additional parts of the USB stack.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Add various patches to support USB keyboards and additional tests
arch/sandbox/dts/test.dts | 5 +++++
test/dm/usb.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 52749c0..b6d9a15 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -325,6 +325,11 @@
sandbox,filepath = "testflash2.bin";
};
+ keyb at 3 {
+ reg = <3>;
+ compatible = "sandbox,usb-keyb";
+ };
+
};
};
};
diff --git a/test/dm/usb.c b/test/dm/usb.c
index fb193e8..7d6b644 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -10,6 +10,7 @@
#include <usb.h>
#include <asm/io.h>
#include <asm/state.h>
+#include <asm/test.h>
#include <dm/device-internal.h>
#include <dm/test.h>
#include <dm/uclass-internal.h>
@@ -258,3 +259,33 @@ static int dm_test_usb_tree_reorder(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_usb_tree_reorder, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_usb_keyb(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ state_set_skip_delays(true);
+ ut_assertok(usb_init());
+
+ /* Initially there should be no characters */
+ ut_asserteq(0, tstc());
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_USB_EMUL, "keyb",
+ &dev));
+
+ /*
+ * Add a string to the USB keyboard buffer - it should appear in
+ * stdin
+ */
+ ut_assertok(sandbox_usb_keyb_add_string(dev, "ab"));
+ ut_asserteq(1, tstc());
+ ut_asserteq('a', getc());
+ ut_asserteq(1, tstc());
+ ut_asserteq('b', getc());
+ ut_asserteq(0, tstc());
+
+ ut_assertok(usb_stop());
+
+ return 0;
+}
+DM_TEST(dm_test_usb_keyb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
--
2.6.0.rc2.230.g3dd15c0
More information about the U-Boot
mailing list