summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: dm: Add additional GPIO testsSimon Glass2014-10-231-0/+38
| | | | | | Add tests for gpio_requestf() and for memory leaks. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: dm: Support memory leak checking as a core featureSimon Glass2014-10-232-16/+32
| | | | | | | | Check the state of the malloc() heap before each test is run, so that tests can verify that all is well at the end. Provide helper functions to mark the heap and to check that it returns to its initial state. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: gpio: Add gpio_requestf() helper for printf() stringsSimon Glass2014-10-231-0/+18
| | | | | | | Add a helper which permits a printf()-style format string for the requester string. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: dm: Update GPIO tests for new gpio_request() methodSimon Glass2014-10-231-22/+33
| | | | | | | Now that gpio_request() is handled by the uclass, updates the tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: sf: Add tests for SPI flashSimon Glass2014-10-223-1/+60
| | | | | | | | | Add a simple test for SPI that uses SPI flash. It operates by creating a SPI flash file and using the 'sf test' command to test that all operations work correctly. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
* dm: spi: Add testsSimon Glass2014-10-223-0/+130
| | | | | | | These tests use SPI flash (and the sandbox emulation) to operate. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
* dm: core: Add functions for iterating through device childrenSimon Glass2014-10-221-0/+31
| | | | | | | | Buses need to iterate through their children in some situations. Add a few functions to make this easy. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
* test: Add a test for command repeatSimon Glass2014-09-243-17/+52
| | | | | | | This performs a command, then repeats it, and checks that the repeat happens. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Remove tabs from trace testSimon Glass2014-09-241-11/+11
| | | | | | | These cause U-Boot to print a list of available commands. It doesn't break the test, but it is best to remove them from the output. Signed-off-by: Simon Glass <sjg@chromium.org>
* Correct sandbox filesystem commands in FIT image testSimon Glass2014-08-281-4/+4
| | | | | | | | | | | | | | | | | | | | The host filesystem name has changed, so update the tests. The tests now run again correctly: $ make O=b/sandbox sandbox_defconfig all ... $ test/image/test-fit.py -u b/sandbox/u-boot FIT Tests ========= Kernel load Kernel + FDT load Kernel + FDT + Ramdisk load Tests passed Caveat: this is only a sanity check - test coverage is poor Signed-off-by: Simon Glass <sjg@chromium.org>
* test: ums: Add script for testing UMS gadget operationLukasz Majewski2014-08-202-0/+205
| | | | | | | | | This commit adds new test for UMS USB gadget to u-boot mainline tree. It is similar in operation to the one already available in test/dfu directory. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* test: dfu: cosmetic: Add missing license information to DFU test scriptsLukasz Majewski2014-08-202-0/+20
| | | | | | | | | By mistake I've forgotten to add the SPDX license tags for the DFU testing scripts. This commit fixes that and also provides some other relevant information. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* test: dfu: Extend dfu_gadget_test_init.sh to accept sizes of test filesLukasz Majewski2014-08-201-1/+5
| | | | | | | | | | It is now possible to pass to the dfu_gadget_test_init.sh script the sizes of files to be generated. This feature is required by UMS tests which reuse this code. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* Implement generalised RSA public exponents for verified bootMichael van der Westhuizen2014-08-091-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Remove the verified boot limitation that only allows a single RSA public exponent of 65537 (F4). This change allows use with existing PKI infrastructure and has been tested with HSM-based PKI. Change the configuration OF tree format to store the RSA public exponent as a 64 bit integer and implement backward compatibility for verified boot configuration trees without this extra field. Parameterise vboot_test.sh to test different public exponents. Mathematics and other hard work by Andrew Bott. Tested with the following public exponents: 3, 5, 17, 257, 39981, 50457, 65537 and 4294967297. Signed-off-by: Andrew Bott <Andrew.Bott@ipaccess.com> Signed-off-by: Andrew Wishart <Andrew.Wishart@ipaccess.com> Signed-off-by: Neil Piercy <Neil.Piercy@ipaccess.com> Signed-off-by: Michael van der Westhuizen <michael@smart-africa.com> Cc: Simon Glass <sjg@chromium.org>
* test: dfu: add some more test casesStephen Warren2014-08-091-1/+1
| | | | | | | | On Tegra, the DFU buffer size is 1M. Consequently, the 8M test always fails. Add tests for the 1M size, and one byte less as a corner case, so that some large tests are executed and expected to pass. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* test: dfu: cleanup before executionStephen Warren2014-08-091-0/+1
| | | | | | | | | Call cleanup() before running tests too. If a previous test was CTRL-C'd some stale files may have been left around. dfu-util refuses to receive a file to a filename that already exists, which results in false test failures if the files aren't cleaned up first. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* test:dfu: README file updateLukasz Majewski2014-08-091-3/+8
| | | | Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* test: dfu: script enhancementsStephen Warren2014-08-093-26/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Various misc enhancements to dfu_gadget_test.sh: * After every write (download), perform a write to a different file with different data. This ensures that the DFU buffer's content is replaced, so that if the read (upload) succeeds, we know that the correct data was actually read from the storage device, rather than simply being left over in the DFU buffer. This requires two alt setting names to be passed to the script, and a dummy data file to be generated by dfu_gadget_test_init.sh. * Fix the assumption that dfu_gadget_test.sh is run from the directory that contains it, by cd'ing to that directory before invoking ./dfu_gadget_test_init.sh. * Use $DIR$RCV_DIR consistently, rather than using plain $RCV_DIR in some places. * Add 959, 961 test file sizes, to be consistent with having one more than and one less than all the other "round" sizes 64, 128, and 4096. * Remove references to $BKP_DIR from dfu_gadget_test_init.sh, since it isn't used. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* test:dfu: Add test scripts for testing DFU regressionLukasz Majewski2014-08-093-0/+152
| | | | | | | | | | This commit adds test scripts for testing if any commit has introduced regression to the DFU subsystem. It uses md5 to test if sent and received file is correct. The test detailed description is available at README file. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* dm: Add child_pre_probe() and child_post_remove() methodsSimon Glass2014-07-231-0/+68
| | | | | | | | | | | Some devices (particularly bus devices) must track their children, knowing when a new child is added so that it can be set up for communication on the bus. Add a child_pre_probe() method to provide this feature, and a corresponding child_post_remove() method. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Introduce per-child data for devicesSimon Glass2014-07-231-0/+65
| | | | | | | | | | | | | Some device types can have child devices and want to store information about them. For example a USB flash stick attached to a USB host controller would likely use this space. The controller can hold information about the USB state of each of its children. The data is stored attached to the child device in the 'parent_priv' member. It can be auto-allocated by dm when the child is probed. To do this, add a per_child_auto_alloc_size value to the parent driver. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Add functions to access a device's childrenSimon Glass2014-07-231-0/+46
| | | | | | | | | | | | | | | | | Devices can have childen that can be addressed by a simple index, the sequence number or a device tree offset. Add functions to access a child in each of these ways. The index is typically used as a fallback when the sequence number is not available. For example we may use a serial UART with sequence number 0 as the console, but if no UART has sequence number 0, then we can fall back to just using the first UART (index 0). The device tree offset function is useful for buses, where they want to locate one of their children. The device tree can be scanned to find the offset of each child, and that offset can then find the device. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Provide a function to scan child FDT nodesSimon Glass2014-07-234-26/+117
| | | | | | | | | | | | | | At present only root nodes in the device tree are scanned for devices. But some devices can have children. For example a SPI bus may have several children for each of its chip selects. Add a function which scans subnodes and binds devices for each one. This can be used for the root node scan also, so change it. A device can call this function in its bind() or probe() methods to bind its children. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Avoid accessing uclasses before they are readySimon Glass2014-07-231-0/+14
| | | | | | Don't allow access to uclasses before they have been initialised. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Allow a device to be found by its FDT offsetSimon Glass2014-07-231-0/+30
| | | | | | | | Each device that was bound from a device tree has an node that caused it to be bound. Add functions that find and return a device based on a device tree offset. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Display the sequence number for each deviceSimon Glass2014-07-231-0/+2
| | | | | | Add this information to 'dm tree' and 'dm uclass' commands. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Introduce device sequence numberingSimon Glass2014-07-232-2/+63
| | | | | | | | | | | | | | | | | | | | | | | | | In U-Boot it is pretty common to number devices from 0 and access them on the command line using this numbering. While it may come to pass that we will move away from this numbering, the possibility seems remote at present. Given that devices within a uclass will have an implied numbering, it makes sense to build this into driver model as a core feature. The cost is fairly small in terms of code and data space. With each uclass having numbered devices we can ask for SPI port 0 or serial port 1 and receive a single device. Devices typically request a sequence number using aliases in the device tree. These are resolved when the device is probed, to deal with conflicts. Sequence numbers need not be sequential and holes are permitted. At present there is no support for sequence numbers using static platform data. It could easily be added to 'struct driver_info' if needed, but it seems better to add features as we find a use for them, and the use of -1 to mean 'no sequence' makes the default value somewhat painful. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Avoid activating devices in 'dm uclass' commandSimon Glass2014-07-231-3/+3
| | | | | | | | This command currently activates devices as it lists them. This is not desirable since it changes the system state. Fix it and avoid printing a newline if there are no devices in a uclass. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Move device display into its own functionSimon Glass2014-07-231-8/+19
| | | | | | | The device display for 'dm tree' and 'dm uclass' is mostly the same, so move it into a common function. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Allow drivers to be marked 'before relocation'Simon Glass2014-07-235-13/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | Driver model currently only operates after relocation is complete. In this state U-Boot typically has a small amount of memory available. In adding support for driver model prior to relocation we must try to use as little memory as possible. In addition, on some machines the memory has not be inited and/or the CPU is not running at full speed or the data cache is off. These can reduce execution performance, so the less initialisation that is done before relocation the better. An immediately-obvious improvement is to only initialise drivers which are actually going to be used before relocation. On many boards the only such driver is a serial UART, so this provides a very large potential benefit. Allow drivers to mark themselves as 'pre-reloc' which means that they will be initialised prior to relocation. This can be done either with a driver flag or with a 'dm,pre-reloc' device tree property. To support this, the various dm scanning function now take a 'pre_reloc_only' parameter which indicates that only drivers marked pre-reloc should be bound. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Make sure that the root device is probedSimon Glass2014-07-231-1/+1
| | | | | | | | | The root device should be probed just like any other device. The effect of this is to mark the device as activated, so that it can be removed (along with its children) if required. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Vasut <marex@denx.de>
* dm: Use an explicit expect value in core testsSimon Glass2014-07-232-6/+12
| | | | | | | Rather than reusing the 'reg' property, use an explicit property for the expected ping value used in testing. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge branch 'sandbox' of git://git.denx.de/u-boot-x86Tom Rini2014-06-242-5/+5
|\
| * sandbox: restore ability to access host fs through standard commandsStephen Warren2014-06-232-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 95fac6ab4589 "sandbox: Use os functions to read host device tree" removed the ability for get_device_and_partition() to handle the "host" device type, and redirect accesses to it to the host filesystem. This broke some unit tests that use this feature. So, revert that change. The code added back by this patch is slightly different to pacify checkpatch. However, we're then left with "host" being both: - A pseudo device that accesses the hosts real filesystem. - An emulated block device, which accesses "sectors" inside a file stored on the host. In order to resolve this discrepancy, rename the pseudo device from host to hostfs, and adjust the unit-tests for this change. The "help sb" output is modified to reflect this rename, and state where the host and hostfs devices should be used. Signed-off-by: Stephen Warren <swarren@nvidia.com> Tested-by: Josh Wu <josh.wu@atmel.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* | dm: Use '*' to indicate a device is activatedSimon Glass2014-06-211-5/+6
|/ | | | | | | | Make both dm enumeration commands support showing whether a driver is active or not, and use a consistent indicator (an asterisk). Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Vasut <marex@denx.de>
* dm: Fix printf() strings in the 'dm' commandSimon Glass2014-06-201-4/+4
| | | | | | | The values here are int, but the map_to_sysmem() call can return a long. Add a cast to deal with this. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Allow driver model tests only for sandboxSimon Glass2014-06-202-2/+11
| | | | | | | The GPIO tests require the sandbox GPIO driver, so cannot be run on other platforms. Similarly for the 'dm test' command. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Rename struct device_id to udevice_idSimon Glass2014-06-201-1/+1
| | | | | | | It is best to avoid having any occurence of 'struct device' in driver model, so rename to achieve this. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: vboot: explicitly request bashStephen Warren2014-06-191-1/+1
| | | | | | | | vboot_test.sh uses Bashisms. Explicitly use #!/bin/bash so the script doesn't fail if /bin/sh isn't Bash. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
* Add final result tests for run_command_list()Simon Glass2014-06-051-0/+5
| | | | | | | | run_command_list() is supposed to return a return code of 0 for success and 1 for failure. Add a few simple tests that confirm this. These tests work both with the built-in parser and hush. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: rename device struct to udeviceHeiko Schocher2014-05-277-45/+46
| | | | | | | | | | | | using UBI and DM together leads in compiler error, as both define a "struct device", so rename "struct device" in include/dm/device.h to "struct udevice", as we use linux code (MTD/UBI/UBIFS some USB code,...) and cannot change the linux "struct device" Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Marek Vasut <marex@denx.de>
* tools, fit_check_sign: verify a signed fit imageHeiko Schocher2014-03-211-0/+20
| | | | | | | | add host tool "fit_check_sign" which verifies, if a fit image is signed correct. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Simon Glass <sjg@chromium.org>
* rsa: add sha256-rsa2048 algorithmHeiko Schocher2014-03-215-28/+125
| | | | | | | | | | | | | | | | | | | | | based on patch from andreas@oetken.name: http://patchwork.ozlabs.org/patch/294318/ commit message: I currently need support for rsa-sha256 signatures in u-boot and found out that the code for signatures is not very generic. Thus adding of different hash-algorithms for rsa-signatures is not easy to do without copy-pasting the rsa-code. I attached a patch for how I think it could be better and included support for rsa-sha256. This is a fast first shot. aditionally work: - removed checkpatch warnings - removed compiler warnings - rebased against current head Signed-off-by: Heiko Schocher <hs@denx.de> Cc: andreas@oetken.name Cc: Simon Glass <sjg@chromium.org>
* unit-test: make "test -e" test independent of $CWDStephen Warren2014-03-071-5/+9
| | | | | | | | | | | | | | The unit-test for hush's "test -e" currently relies upon being run in the U-Boot build directory, because it tests for the existence of a file that exists in that directory. Fix this by explicitly creating the file we use for the existence test, and deleting it afterwards so that multiple successive unit-test invocations succeed. This required adding an os.c function to erase files. Reported-by: Simon Glass <sjg@chromium.org> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* hush: fix some quoted variable expansion issuesStephen Warren2014-03-071-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following shell command fails: if test -z "$x"; then echo "zero"; else echo "non-zero"; fi (assuming $x does not exist, it prints "non-zero" rather than "zero"). ... since "$x" expands to nothing, and the argument is completely dropped, causing too few to be passed to -z, causing cmd_test() to error out early. This is because when variable expansions are processed by make_string(), the expanded results are concatenated back into a new string. However, no quoting is applied when doing so, so any empty variables simply don't generate any parameter when the combined string is parsed again. Fix this by explicitly replacing quoting any argument that was originally quoted when re-generating a string from the already-parsed argument list. This also fixes loss of whitespace in commands such as: setenv space " " setenv var " 1${space}${space} 2 " echo ">>${var}<<" Reported-by: Russell King <linux@arm.linux.org.uk> Acked-by: Simon Glass <sjg@chromium.org> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
* unit-test: clean up evironment after Hush testsStephen Warren2014-03-071-1/+2
| | | | | | | | | Delete the temporary variables that are used to save unit-test results from the environment after running the test. This prevents polluting the environment, or growing it too much. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: Simon Glass <sjg@chromium.org>
* dm: Add GPIO support and testsSimon Glass2014-03-041-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | Add driver model support for GPIOs. Since existing GPIO drivers do not use driver model, this feature must be enabled by CONFIG_DM_GPIO. After all GPO drivers are converted over we can perhaps remove this config. Tests are provided for the sandbox implementation, and are a sufficient sanity check for basic operation. The GPIO uclass understands the concept of named banks of GPIOs, with each GPIO device providing a single bank. Within each bank the GPIOs are numbered using an offset from 0 to n-1. For example a bank named 'b' with 20 offsets will provide GPIOs named b0 to b19. Anonymous GPIO banks are also supported, and are just numbered without any prefix. Each time a GPIO driver is added to the uclass, the GPIOs are renumbered accordinging, so there is always a global GPIO numbering order. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com> Signed-off-by: Viktor Křivák <viktor.krivak@gmail.com> Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
* dm: Add a 'dm' command for testingSimon Glass2014-03-042-0/+134
| | | | | | | | | | | This command is not required for driver model operation, but can be useful for testing. It provides simple dumps of internal data structures. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com> Signed-off-by: Viktor Křivák <viktor.krivak@gmail.com> Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
* dm: Add basic testsSimon Glass2014-03-0410-0/+1162
| | | | | | | | | | | | | | | | | | | | Add some tests of driver model functionality. Coverage includes: - basic init - binding of drivers to devices using platform_data - automatic probing of devices when referenced - availability of platform data to devices - lifecycle from bind to probe to remove to unbind - renumbering within a uclass when devices are probed/removed - calling driver-defined operations - deactivation of drivers when removed - memory leak across creation and destruction of drivers/uclasses - uclass init/destroy methods - automatic probe/remove of children/parents when needed This function is enabled for sandbox, using CONFIG_DM_TEST. Signed-off-by: Simon Glass <sjg@chromium.org>
* unit-test: add lots of tests for the Hush 'test' commandStephen Warren2014-02-191-0/+89
| | | | | | | | I recently re-wrote cmd_test() to add new features. Add a bunch of unit- tests to make sure I didn't break anything. Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Stephen Warren <swarren@nvidia.com>
OpenPOWER on IntegriCloud