aboutsummaryrefslogtreecommitdiff
path: root/test/py/tests/test_fs/conftest.py
Commit message (Collapse)AuthorAgeFilesLines
* test/py: Disable error E0611 in two cases for pylintTom Rini2023-12-091-0/+1
| | | | | | | | | | | | | | | | | Recently pylint has started to complain about: No name 'fs_helper' in module 'tests' (no-name-in-module) Due to: from tests import fs_helper However, we have: test/py/tests/fs_helper.py And since we do not want to add a dummy test/py/tests/__init__.py to silence this warning we instead just disable it as needed. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* test: fs: Add test to detect fat typeChristian Taedcke2023-11-281-0/+47
| | | | | | | Ensure that a large FAT12 filesystem and a small FAT16 filesystem are detected correctly. Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>
* test: fs: Add fat12 to supported fs of some testsChristian Taedcke2023-11-281-3/+3
| | | | | | | | | The tests fs_ext, fs_mkdir and fs_unlink support fat12 without modifications. The fs_basic test uses a partition that is too large for fat12, so it is omitted here. Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>
* global: Use proper project name U-BootMichal Simek2023-06-121-6/+6
| | | | | | | | | | | Use proper project name in comments, Kconfig, readmes. Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/0dbdf0432405c1c38ffca55703b6737a48219e79.1684307818.git.michal.simek@amd.com
* test: Split out mk_fs function into a helperSimon Glass2022-11-071-52/+6
| | | | | | This function is useful for other tests. Move it into common code. Signed-off-by: Simon Glass <sjg@chromium.org>
* test/py: Wait for guestmount worker to exit after running guestunmountAlper Nebi Yasak2021-07-051-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some filesystem tests are failing when their image is prepared with guestmount, but succeeding if loop mounts are used instead. The reason seems to be a race condition the guestmount(1) manual page explains: When guestunmount(1)/fusermount(1) exits, guestmount may still be running and cleaning up the mountpoint. The disk image will not be fully finalized. This means that scripts like the following have a nasty race condition: guestmount -a disk.img -i /mnt # copy things into /mnt guestunmount /mnt # immediately try to use 'disk.img' ** UNSAFE ** The solution is to use the --pid-file option to write the guestmount PID to a file, then after guestunmount spin waiting for this PID to exit. The Python standard library has an os.waitpid() function for waiting a child to terminate, but it cannot wait on non-child processes. Implement a utility function that can do this by polling the process repeatedly for a given duration, optionally killing the process if it won't terminate on its own. Apply the suggested solution with this utility function, which makes the failing tests succeed again. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test/py: Use loop mounts if guestmount fails in filesystem testsAlper Nebi Yasak2021-07-051-16/+15
| | | | | | | | | | | | | | If guestmount isn't available on the system, filesystem test setup falls back to using loop mounts to prepare its disk images. If guestmount is available but fails to work, the tests are immediately skipped. Instead of giving up on a guestmount failure, try using loop mounts as an attempt to keep tests running. Also stop checking if guestmount is in PATH, as trying to run a missing guestmount can now follow the same failure codepath and fall back to loop mounts anyway. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
* test: Include /sbin to the PATH when creating file systemAndy Shevchenko2021-06-231-0/+4
| | | | | | | | On some distributions the mkfs is under /sbin and /sbin is not set for mere users. Include /sbin to the PATH when creating file system, so that users won't get a scary traceback from Python. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* test: Fix filesystem tests always being skippedAlper Nebi Yasak2021-05-261-12/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") fixes an issue in the filesystem tests where the test setup may fail to mount an image and still attempt to unmount it. However, the commit unintentionally breaks the test setups in two ways. The newly created unmounted filesystem images are being immediately deleted due to some cleanup steps being misplaced into finally blocks, which makes them always run instead of only on failures. The mount calls always fail since the images never exist, causing the tests to be always skipped. This patch moves these cleanup calls into the except blocks to fix this and makes the tests run again. There are also unmount calls misplaced into finally blocks, making them run after the tests instead of before the tests. These unmount calls make the filesystem image file consistent with the changes made to it as part of the test setup, and this misplacement is making a number of tests fail unexpectedly. The unmount calls must be run before the tests use the image, meaning before the yield call and not in the finally block. They must also be run as a cleanup step when the filesystem setup fails, so they can't be placed as the final call in the try blocks since they would be skipped on such failures. For these reasons, this patch places the unmount calls both in the except blocks and the else blocks of the final setup step. This makes the unexpectedly failing tests to succeed again. Furthermore, this isolates the mount calls to their own try-except statement to avoid reintroducing the original issue of unmounting a not-mounted image while fixing the unmount misplacement. After these fixes, running "make tests" with guestmount available results in two test failures not related to the mentioned commit. If the guestmount executables are unavailable, the mounts fallback to using sudo and result in no failures. Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* test: Don't unmount not (yet) mounted systemAndy Shevchenko2021-03-311-22/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When test suite tries to create a file for a new filesystem test case and fails, the clean up of the exception tries to unmount the image, that has not yet been mounted. When it happens, the fuse_mounted global variable is set to False and inconveniently the test case tries to use sudo, so without this change the admin of the machine gets an (annoying) email: Subject: *** SECURITY information for example.com *** example.com : Feb 5 19:43:47 : ... COMMAND=/bin/umount .../build-sandbox/persistent-data/mnt and second run of the test cases on uncleaned build folder will ask for sudo which is not what expected. Besides that there is a double unmount calls during successfully run test case. All of these due to over engineered Python try-except clause and people didn't get it properly at all. The rule of thumb is that don't use more keywords than try-except in the exception handling code. Nevertheless, here we adjust code to be less intrusive to the initial logic behind that complex and unclear constructions in the test case, although it adds a lot of lines of the code, i.e. splits one exception handler to three, so on each step we know what cleanup shall perform. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test: Update test_fs to not use deprecated pytest.yield_fixture()Tom Rini2021-01-291-10/+5
| | | | | | | | | As noted in comments, yield_fixture has been deprecated for longer than our minimum required version of pytest. Newer versions of pytest cause this to be a louder warning, and as the migration is trivial, perform it now. Signed-off-by: Tom Rini <trini@konsulko.com>
* tests: support mkfs.ext4 without metadata_csumStephen Warren2020-08-071-2/+4
| | | | | | | Modify various test/py filesystem creation routines to support systems that don't implement the metadata_csum ext4 feature. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* test: test_fs error messageHeinrich Schuchardt2020-04-271-2/+3
| | | | | | | | | | | | | | | | | | | For non-root users mkfs.vfat is not in the search path at least on Debian. Hence when running 'make tests' a message indicates that file system tests have been skipped: SKIPPED [13] test/py/tests/test_fs/conftest.py:340: Setup failed for filesystem: fat16 This message is not really helpful as the executed program is not indicated. Provide a more complete message like SKIPPED [13] test/py/tests/test_fs/conftest.py:340: Setup failed for filesystem: fat16. Command 'mkfs.vfat -F 16 build-sandbox/persistent-data/3GB.fat16.img' returned non-zero exit status 127. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test/py: Update test_fs to decode check_output callsTom Rini2019-10-301-12/+12
| | | | | | | | | | | | The check_output function from the subprocess Python module by default returns data as encoded bytes and leaves decoding to the application. Given our uses of the call, it makes the most sense to immediately decode the results. Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
* test/py: Automated conversion to Python 3Tom Rini2019-10-301-2/+2
| | | | | | | | | | | | Use the 2to3 tool to perform numerous automatic conversions from Python 2 syntax to Python 3. Also fix whitespace problems that Python 3 catches that Python 2 did not. Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
* test: fs: Added tests for symlinksJean-Jacques Hiblot2019-04-091-0/+75
| | | | | | | | | | | | Test cases are: 1) basic link creation, verify it can be followed 2) chained links, verify it can be followed 3) replace exiting file a with a link, and a link with a link. verify it can be followed 4) create a broken link, verify it can't be followed Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* test: fs: disable the metadata checksums on ext4 filesystemsJean-Jacques Hiblot2019-04-091-0/+2
| | | | | | | If the metadata checksums are enabled, all write operations will fail. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* test: Use single quote consistentlySimon Glass2019-01-151-4/+4
| | | | | | | | Some tests have ended up using double quotes where single quotes could be used. Adjust this for consistency with the rest of U-Boot's Python code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test/py: test_fs: add docstring comments to helper functionsAkashi Takahiro2018-10-061-0/+133
| | | | | | | | After Siomon's comment, add a descriptive comment (docstring) to each of helper functions in conftest.py. No functionality changed. Signed-off-by: Akashi Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* test/py: test_fs: remove fs_type argument from umount_fs()Akashi Takahiro2018-10-061-7/+7
| | | | | | | Since there is no use of fs_type in umount_fs(), just remove it. Signed-off-by: Akashi Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* test/py: fs: add fstest/unlink testAkashi, Takahiro2018-09-231-0/+62
| | | | | | | | In this commit, test cases for unlink interfaces are added as part of "test_fs" test suite. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* test/py: fs: add fstest/mkdir testAKASHI Takahiro2018-09-231-0/+29
| | | | | | | | In this commit, test cases for mkdir interfaces are added as part of "test_fs" test suite. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* test/py: fs: add extended write operation testAKASHI Takahiro2018-09-231-0/+83
| | | | | | | | | | | | In this commit and the following, test scripts for new filesystem functionalities introduced by my patch set, "fs: fat: extend FAT write operations," are provided. In particular, this patch adds test cases for sub-directory write and write with non-zero offset. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* test/py: convert fs-test.sh to pytestAKASHI Takahiro2018-09-231-0/+218
In this commit, the same set of test cases as in test/fs/fs-test.sh is provided using pytest framework. Actually, fs-test.sh provides three variants:"sb" (sb command), "nonfs" (fatxx and etc.) and "fs" (hostfs), and this patch currently supports only "nonfs" variant; So it is not a replacement of fs-test.sh for now. Simple usage: $ py.test test/py/tests/test_fs [<other options>] You may also specify filesystem types to be tested: $ py.test test/py/tests/test_fs --fs-type fat32 [<other options>] Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>