summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: self: printf: compile test with -Wno-format-securityAhmad Fatoum2023-05-021-0/+1
| | | | | | | | | | | | | For testing purposes, the test code uses a variable for the format string at places, which -Wformat-security doesn't like. The printf test was copied over from the kernel, which sets -Wno-format-security globally. This may not be needed for barebox yet, but let's set at least for this one file. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424115548.114858-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-04-191-1/+1
|\
| * of: implement of_copy_propertyAhmad Fatoum2023-04-171-1/+1
| | | | | | | | | | | | | | | | | | For use in fixups, it can be useful to copy a property verbatim from the barebox DT to the kernel DT. Add a helper that does just that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230414183545.2039170-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add missing device tree artifact cleanup where neededAhmad Fatoum2023-04-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | The DTs in arch/$ARCH/dts are all cleaned up when invoking the make target, but we have a few DTs outside these directories. Clean those up as well and add a clean line for the overlay too. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230408080616.938638-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | test: emulate.pl: fix firmware use with non-tuxmake out-of-tree buildAhmad Fatoum2023-04-111-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | The YAMLs may contain URLs for firmware that needs to be fetched before starting Qemu. This firmware needs to be installed where Qemu will find it, which is _not_ the source directory for out-of-tree builds. This adjust the path. Fixes: 7271ce78d0fc ("test: add emulate.pl, a runner for barebox on emulated targets") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230411071436.1630752-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | test: riscv: fix YAMLs after defconfig renameAhmad Fatoum2023-04-115-1/+1
|/ | | | | | | | | | | | | With the recent consolidation of 64-bit RISC-V defconfigs into a single rv64i_defconfig, the YAMLs for QEMUs become outdated. Sync them with the new naming. Fixes: 42089e3f532b ("RISC-V: squash 64bit defconfigs into rv64i_defconfig") Reported-by: Antony Pavlov <antonynpavlov@gmail.com> Link: https://lore.barebox.org/barebox/20221022105554.c9bbe152814a3c7a682df735@gmail.com/ Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230411071436.1630752-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add json parser testAhmad Fatoum2023-01-103-0/+152
| | | | | | | | | Newly added JSON parsing code doesn't yet have a consumer in-tree. Add a self-test to exercise the API for now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230110084930.3439001-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* vsprintf: implement %pJP for printing JSONPathsAhmad Fatoum2023-01-101-0/+17
| | | | | | | | | | We use an array of strings to represnt a JSONPath. Add a new %pJP format specifier that can be used to print them. This is useful for error messages when the lookup fails. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230110084930.3439001-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: only include ramfs selftest when CONFIG_SELFTEST_FS_RAMFS=yAhmad Fatoum2022-11-022-2/+2
| | | | | | | | | So far, we ignored the symbol and built the test always when CONFIG_SELFTEST=y and CONFIG_FS_RAMFS=y. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221101063216.3216821-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/selftest'Sascha Hauer2022-10-133-0/+212
|\
| * fs: implement unreaddirAhmad Fatoum2022-10-111-1/+16
| | | | | | | | | | | | | | | | | | | | When iterating over a directory, it can be useful to put back the just read directory entry, so it can be retried at a later time. This will be needed for the EFI loader variable support. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * test: self: add ramfs testAhmad Fatoum2022-10-113-0/+195
| | | | | | | | | | | | | | | | | | | | | | Add some simple testing for ramfs: creating a directory, filling it with files, writing some data into them, unlinking some files again, reading data out of them, iterating over the files and cleaning up the directory again. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * test: self: always build envvar test when SELFTEST_ENABLE_ALLAhmad Fatoum2022-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The test can cope with CONFIG_ENVIRONMENT_VARIABLES being disabled and just skips the tests that can't run without. This still has value, because it tests barebox behavior without environment variables enabled. Therefore, enable the test always for CONFIG_SELFTEST_ENABLE_ALL=y Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * test: self: change CONFIG_CMD_SELFTEST default to yAhmad Fatoum2022-10-111-0/+1
| | | | | | | | | | | | | | | | | | | | If a user enables CONFIG_SELFTEST, there's a fair chance, they don't mind having a selftest command to exercise the enabled test. Thus enable this by default. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net'Sascha Hauer2022-10-131-7/+0
|\ \ | |/ |/|
| * tftp: remove selftestSascha Hauer2022-09-221-7/+0
| | | | | | | | | | | | | | | | The out-of-order packet caching will be reworked in the next commit and most of the functions the self test tests will vanish, so nothing to test anymore. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | test: emulate.pl: fix support for multiple block devicesAhmad Fatoum2022-10-101-0/+2
|/ | | | | | | | | Block devices on QEMU command line need a unique id. The id factors in $i, which we failed to increment. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010060504.2082266-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/tftp'Sascha Hauer2022-09-141-0/+7
|\
| * tftp: add selftestEnrico Scholz2022-09-121-0/+7
| | | | | | | | | | | | | | | | Unittest for window cache functions. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-20-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | test: self: provide selftest_is_running()Ahmad Fatoum2022-09-131-1/+25
| | | | | | | | | | | | | | | | | | | | For debugging during self-test run, it can be useful to enable select logging only when the selftest is running. Provide a selftest_is_running() function that can be used to determine whether a test is running. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905070125.537483-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: implement of_prepend_propertyAhmad Fatoum2022-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Like of_append_property for adding at the end of properties, implement of_prepend_property for placing data into the front. This is especially useful to fixup most-specific compatibles into existing nodes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220912155436.1565755-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | of: implement of_rename_property()Ahmad Fatoum2022-09-122-2/+14
|/ | | | | | | | | | | | | | | | | | | | | | | It's often desirable to have the same barebox binary for multiple variants. DT-level differences between the variants are often handled by having extra device tree nodes that are disabled by default and patched as appropriate by board code. It can be useful to have a finer granularity for patching though, that covers only a select property, e.g.: usbotg1 { vbus-supply = <&reg_vbus_common>; vendor,specialvariant-vbus-supply = <&reg_vbus_specialvariant>; }; The new of_rename_property allows board code to easily activate the alternative vbus supply on the specialvariant: of_rename_property(np, "vendor,specialvariant-vbus-supply", "vbus-supply"); Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905103639.1750714-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add tests for of_append_propertyAhmad Fatoum2022-08-112-1/+15
| | | | | | | | | of_append_property has been recently added, so extend the of_manipulation tests to cover it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220809100814.1455984-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: include new tests in CONFIG_SELFTEST_ENABLE_ALLAhmad Fatoum2022-08-091-0/+2
| | | | | | | | | We have gained some tests, since last touching this symbol, so update it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220722045729.3041834-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add simple environment variable testAhmad Fatoum2022-08-093-0/+87
| | | | | | | | | setenv can now accept a format string. Add some tests for the old and new usage. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220722045729.3041834-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add basic testing for malloc()Ahmad Fatoum2022-05-243-0/+97
| | | | | | | | | | | | | | | Surprisingly, the TLSF allocator is prone to overflow. Add some tests that trigger this behavior. These tests run to success with dlmalloc, but some of them fail under tlsf when compiled for 32-bit: test_malloc:40: unexpectedly succeeded to malloc(SIZE_MAX) test_malloc:61: unexpectedly succeeded to (tmp = realloc(p, 0xf0000000)) test_malloc:63: unexpectedly succeeded to tmp = realloc(p, SIZE_MAX) ERROR: malloc: failed 3 out of 12 tests Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220523062756.774153-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add device tree manipulation testAhmad Fatoum2022-02-074-0/+148
| | | | | | | | | | | We had recently gained support for two extra helpers: of_property_sprintf and of_property_write_strings. Add tests for them as well as for general OF creation and unflattening. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207082801.1052894-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: printf: add tests for %*ph printsAhmad Fatoum2022-02-071-0/+18
| | | | | | | | | This modifier was recently added. Turn the description from its commit message into a test. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207082801.1052894-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: printf: log skipped testsAhmad Fatoum2022-02-071-2/+8
| | | | | | | | Report number of skipped tests as well as skip reason. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207082801.1052894-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for .gitignoreAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | Makes the files not appear when searching for files that lack SPDX-License-Identifier. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-052-0/+4
| | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: emulate.pl: fix typo in help textAhmad Fatoum2021-11-301-1/+1
| | | | | | | | s/kconfig_add/kconfig-add/ Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211125160526.3827881-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM64: qemu-virt: enable PCI supportAhmad Fatoum2021-11-221-1/+1
| | | | | | | | | | We now have a driver for the PCI controller on QEMU, so define HW_HAS_PCI. The barebox PCI implementation doesn't yet deal with 64-bit addresses, so use -M virt,highmem=off by default. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211117130044.2437471-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: add tests for progress notifierAhmad Fatoum2021-06-285-0/+86
| | | | | | | | | We don't yet have any boards upstream that make use of the progress notifier, but at least have some tests, so we know it's working. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210619054048.498826-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: add bthread testAhmad Fatoum2021-06-092-0/+25
| | | | | | | | | | | | The bthread -v command already returns an appropriate exit code if threads can't be scheduled. Have it spawn 16 threads and switch between them for a second and verify that all of these threads were indeed terminated. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: run selftests as part of the pytest suiteAhmad Fatoum2021-06-092-0/+12
| | | | | | | | | | | | | | | | | We don't want to enable self tests in the normal configs as they may, in future, bloat size needlessly. Enable it instead in the base.cfg fragment and add a test that verifies the selftest command runs without errors. Selftests can be run on startup for CONFIG_SHELL_NONE systems. This is not implemented here. For such systems the test will be skipped as CONFIG_CMD_SELFTEST won't be defined. To manually skip with emulate.pl, add --no-kconfig-base. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: add emulate.pl, a runner for barebox on emulated targetsAhmad Fatoum2021-06-093-0/+528
| | | | | | | | | | | | | | | | | | | This script is a wrapper around tuxmake, qemu and labgrid-pytest. It parses the same YAML files, labgrid-pytest uses and instructs tuxmake to build and collect the needed images. By default, it will start an interactive emulator session, but with --test, it can also run labgrid-pytest instead. The script has some knowledge of QEMU options to make common tasks like passing images straight-forward. Script is written with both manual use and CI in mind. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: add first sample testsAhmad Fatoum2021-06-097-0/+155
| | | | | | | | | | | The test can be run manually with e.g. labgrid-pytest --lg-env test/arm/qemu_virt64_defconfig.yaml test/py Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: add labgrid-style configs for some emulated targetsAhmad Fatoum2021-06-0922-0/+393
| | | | | | | | | | | | | | | | | | | | | There are various ways barebox can run under emulation, some of them are described in the documentation and some more in the git history. Make running the emulators more convenient to use by collecting some known-good emulator invocations in a machine readable format. These files can be processed by a test/emulate.pl script added in a follow-up commit. They contain enough information to configure, build and run barebox inside an emulator. Those YAML files utilizing QEMUDriver can also be directly parsed by labgrid for running tests. Utilizing labgrid for this will allow using the same test suite for physical targets as well in future. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: self: port Linux printf kselftestAhmad Fatoum2021-06-093-0/+309
| | | | | | | | | | | Port over the Linux v5.11 selftest for printf sans the parts we don't support. This can be used to catch regressions if changes affecting the printf code are made. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* test: add basic barebox self-test infrastructureAhmad Fatoum2021-06-095-0/+67
Self tests is code written to run within barebox to exercise functionality. They offer flexibility to test specific units of barebox instead of the program as a whole. Add a very simple infrastructure for registering and executing self-tests. This is based on the Linux kselftest modules. We don't utilize modules for this, however, because we only have module support on ARM, but we need a generic solution. Selftests can be enabled individually and even tested without shell support to allow tests to happen for size-restricted barebox images as well. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>