<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/test/py/tests/test_fs, branch v2022.01</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/u-boot.git/atom/test/py/tests/test_fs?h=v2022.01</id>
<link rel='self' href='http://cgit.235523.xyz/u-boot.git/atom/test/py/tests/test_fs?h=v2022.01'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<updated>2021-07-29T00:46:34Z</updated>
<entry>
<title>test/py: Improve check for mksquashfs version</title>
<updated>2021-07-29T00:46:34Z</updated>
<author>
<name>Marek Behún</name>
<email>marek.behun@nic.cz</email>
</author>
<published>2021-07-22T20:52:05Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=89795ef3b6b2d12cffb840a98ee374d2e806aa64'/>
<id>urn:sha1:89795ef3b6b2d12cffb840a98ee374d2e806aa64</id>
<content type='text'>
Some builds of squashfs-tools append version string with "-git" or
similar. The float() conversion will fail in this case.

Improve the code to only convert to float() the string before the '-'
character.

Signed-off-by: Marek Behún &lt;marek.behun@nic.cz&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Reviewed-by: Joao Marcos Costa &lt;jmcosta944@gmail.com&gt;
</content>
</entry>
<entry>
<title>test/py: rewrite sqfsls command test suite</title>
<updated>2021-07-05T19:29:12Z</updated>
<author>
<name>Joao Marcos Costa</name>
<email>jmcosta944@gmail.com</email>
</author>
<published>2021-06-30T22:45:05Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=9bde9b5e29a31bf07a6cd4e00643a7de65c5212d'/>
<id>urn:sha1:9bde9b5e29a31bf07a6cd4e00643a7de65c5212d</id>
<content type='text'>
Add more details to test cases by comparing each expected line with the
command's output. Add new test cases:
- sqfsls at an empty directory
- sqfsls at a sub-directory

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Tested-by: Simon Glass &lt;sjg@chromium.org&gt; [on sandbox]
Signed-off-by: Joao Marcos Costa &lt;jmcosta944@gmail.com&gt;
</content>
</entry>
<entry>
<title>test/py: rewrite sqfsload command test suite</title>
<updated>2021-07-05T19:29:10Z</updated>
<author>
<name>Joao Marcos Costa</name>
<email>jmcosta944@gmail.com</email>
</author>
<published>2021-06-30T22:45:04Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=208eb2a4dcd37c0bb1b76b9d71f7bf28b85a899f'/>
<id>urn:sha1:208eb2a4dcd37c0bb1b76b9d71f7bf28b85a899f</id>
<content type='text'>
The previous strategy to know if a file was correctly loaded was to
check for how many bytes were read and compare it against the file's
original size. Since this is not a good solution, replace it by
comparing the checksum of the loaded bytes against the original file's
checksum. Add more test cases: files at a sub-directory and non-existent
file.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Tested-by: Simon Glass &lt;sjg@chromium.org&gt; [on sandbox]
Signed-off-by: Joao Marcos Costa &lt;jmcosta944@gmail.com&gt;
</content>
</entry>
<entry>
<title>test/py: rewrite common tools for SquashFS tests</title>
<updated>2021-07-05T19:28:33Z</updated>
<author>
<name>Joao Marcos Costa</name>
<email>jmcosta944@gmail.com</email>
</author>
<published>2021-06-30T22:45:03Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=04c9813e951ffa9391daec5a8dcda90539ca2989'/>
<id>urn:sha1:04c9813e951ffa9391daec5a8dcda90539ca2989</id>
<content type='text'>
Remove the previous OOP approach, which was confusing and incomplete.
Add more test cases by making SquashFS images with various options,
concerning file fragmentation and its compression. Add comments to
properly document the code.

Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Tested-by: Simon Glass &lt;sjg@chromium.org&gt; [on sandbox]
Signed-off-by: Joao Marcos Costa &lt;jmcosta944@gmail.com&gt;
</content>
</entry>
<entry>
<title>test/py: Wait for guestmount worker to exit after running guestunmount</title>
<updated>2021-07-05T19:28:32Z</updated>
<author>
<name>Alper Nebi Yasak</name>
<email>alpernebiyasak@gmail.com</email>
</author>
<published>2021-06-04T19:04:46Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=99f5303c8b857320b00a63dca81d1f6f7c75c636'/>
<id>urn:sha1:99f5303c8b857320b00a63dca81d1f6f7c75c636</id>
<content type='text'>
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 &lt;alpernebiyasak@gmail.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
</entry>
<entry>
<title>test/py: Use loop mounts if guestmount fails in filesystem tests</title>
<updated>2021-07-05T19:28:32Z</updated>
<author>
<name>Alper Nebi Yasak</name>
<email>alpernebiyasak@gmail.com</email>
</author>
<published>2021-06-04T19:04:45Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=8f5f5d3a4593f26f0a755f5ecfaa7299e42edeeb'/>
<id>urn:sha1:8f5f5d3a4593f26f0a755f5ecfaa7299e42edeeb</id>
<content type='text'>
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 &lt;alpernebiyasak@gmail.com&gt;
</content>
</entry>
<entry>
<title>test: Include /sbin to the PATH when creating file system</title>
<updated>2021-06-23T12:45:03Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2021-06-10T15:08:42Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=b2710faf82998d7be9e4eef554063a5e27e88ec9'/>
<id>urn:sha1:b2710faf82998d7be9e4eef554063a5e27e88ec9</id>
<content type='text'>
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 &lt;andriy.shevchenko@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>test: Fix filesystem tests always being skipped</title>
<updated>2021-05-26T21:26:07Z</updated>
<author>
<name>Alper Nebi Yasak</name>
<email>alpernebiyasak@gmail.com</email>
</author>
<published>2021-05-20T19:09:46Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=77bfaad04836bf64c2bfccf1b9517639e9d27602'/>
<id>urn:sha1:77bfaad04836bf64c2bfccf1b9517639e9d27602</id>
<content type='text'>
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 &lt;alpernebiyasak@gmail.com&gt;
Acked-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>test: Don't unmount not (yet) mounted system</title>
<updated>2021-03-31T11:50:17Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2021-02-11T14:40:12Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=1ba21bb06b08d2f5d62afac29549ade8616929ce'/>
<id>urn:sha1:1ba21bb06b08d2f5d62afac29549ade8616929ce</id>
<content type='text'>
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 &lt;andriy.shevchenko@linux.intel.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
</entry>
<entry>
<title>test: Update test_fs to not use deprecated pytest.yield_fixture()</title>
<updated>2021-01-29T15:36:49Z</updated>
<author>
<name>Tom Rini</name>
<email>trini@konsulko.com</email>
</author>
<published>2021-01-28T19:39:56Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=a59e59c9be844553384b67c36a8040f65ec10011'/>
<id>urn:sha1:a59e59c9be844553384b67c36a8040f65ec10011</id>
<content type='text'>
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 &lt;trini@konsulko.com&gt;
</content>
</entry>
</feed>
