* [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
@ 2024-06-15 9:16 Julien Olivain
2024-06-15 9:16 ` [Buildroot] [PATCH 2/2] support/testing: add lame runtime test Julien Olivain
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Julien Olivain @ 2024-06-15 9:16 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
This is a helper class providing a template for testing audio codec
programs such as lame mp3 encoder, flac tools, ogg vorbis-tools, ...
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
DEVELOPERS | 1 +
.../tests/package/test_audio_codec_base.py | 86 +++++++++++++++++++
2 files changed, 87 insertions(+)
create mode 100644 support/testing/tests/package/test_audio_codec_base.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 52c9b84a9d4..44ff8c01e03 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1796,6 +1796,7 @@ F: support/testing/tests/package/test_acl.py
F: support/testing/tests/package/test_acpica.py
F: support/testing/tests/package/test_acpica/
F: support/testing/tests/package/test_apache.py
+F: support/testing/tests/package/test_audio_codec_base.py
F: support/testing/tests/package/test_bc.py
F: support/testing/tests/package/test_bitcoin.py
F: support/testing/tests/package/test_brotli.py
diff --git a/support/testing/tests/package/test_audio_codec_base.py b/support/testing/tests/package/test_audio_codec_base.py
new file mode 100644
index 00000000000..59c7efcad3c
--- /dev/null
+++ b/support/testing/tests/package/test_audio_codec_base.py
@@ -0,0 +1,86 @@
+import math
+import os
+
+import infra.basetest
+
+
+class TestAudioCodecBase(infra.basetest.BRTest):
+ """Common class to test an audio codec package.
+
+ This base class builds a Buildroot system image containing the
+ package enabled in its config, start the emulator, login to it. It
+ prepares an input test WAV file containing a tone. This WAV file
+ is encoded into a new output file in the native encoder format. It
+ is then decoded to a new output WAV file. This final output WAV
+ file is checked to contain the expected tone generated in the
+ initial input WAV file. There is no specific check about file
+ size, nor audio quality. The acceptance criteria is the
+ recognition of the tone. Note: the tone generation is made with
+ the Sox package, and the tone recognition is made with the Aubio
+ package.
+
+ Each test case that inherits from this class must have:
+ __test__ = True - to let nose2 know that it is a test case
+ config - defconfig fragment with the packages to run the test
+ encode_test() - the function that runs the encoder and produces an
+ encoded file.
+ decode_test() - the function that runs the decoder and produces a
+ decode file.
+ """
+ __test__ = False
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_PACKAGE_AUBIO=y
+ BR2_PACKAGE_SOX=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+ input_file = "reference.wav"
+ decoded_file = "decoded.wav"
+ tone_freq = 440 # General Midi note A3
+
+ def login(self):
+ cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+ self.emulator.boot(arch="armv5",
+ kernel="builtin",
+ options=["-initrd", cpio_file])
+ self.emulator.login()
+
+ def test_run(self):
+ self.login()
+ self.prepare_data()
+ self.encode_test(self.input_file)
+ self.decode_test(self.decoded_file)
+ self.check_test()
+
+ def prepare_data(self):
+ # Generate a sinusoidal tone.
+ cmd = "sox -V -r 48000 -n -b 16 -c 1 "
+ cmd += self.input_file
+ cmd += f" synth 3 sin {self.tone_freq} vol -10dB"
+ self.assertRunOk(cmd)
+
+ def encode_test(self, input_filename):
+ msg = "method must be implemented in derived class"
+ raise NotImplementedError(msg)
+
+ def decode_test(self, output_filename):
+ msg = "method must be implemented in derived class"
+ raise NotImplementedError(msg)
+
+ def note_from_freq(self, freq):
+ """Return a note number from the input frequency in Hertz."""
+ return round((12 * math.log(freq / 440) / math.log(2)) + 69)
+
+ def check_test(self):
+ expected_note = self.note_from_freq(self.tone_freq)
+ out, ret = self.emulator.run(f"aubionotes {self.decoded_file}", timeout=20)
+ self.assertEqual(ret, 0)
+ note_found = False
+ for line in out:
+ values = line.split()
+ if len(values) == 3:
+ note = round(float(values[0]))
+ if note == expected_note:
+ note_found = True
+ self.assertTrue(note_found, "The expected note was not found")
--
2.45.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 2/2] support/testing: add lame runtime test
2024-06-15 9:16 [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Julien Olivain
@ 2024-06-15 9:16 ` Julien Olivain
2024-06-15 18:09 ` [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Yann E. MORIN
2024-08-06 21:24 ` Thomas Petazzoni via buildroot
2 siblings, 0 replies; 8+ messages in thread
From: Julien Olivain @ 2024-06-15 9:16 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Note: this test is an example of use of the base class. If accepted,
I will propose tests for other audio codecs.
---
DEVELOPERS | 1 +
support/testing/tests/package/test_lame.py | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
create mode 100644 support/testing/tests/package/test_lame.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 44ff8c01e03..2a2ccde93c0 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1841,6 +1841,7 @@ F: support/testing/tests/package/test_kexec.py
F: support/testing/tests/package/test_kexec/
F: support/testing/tests/package/test_kmscube.py
F: support/testing/tests/package/test_kmscube/
+F: support/testing/tests/package/test_lame.py
F: support/testing/tests/package/test_less.py
F: support/testing/tests/package/test_libcamera.py
F: support/testing/tests/package/test_libcamera/
diff --git a/support/testing/tests/package/test_lame.py b/support/testing/tests/package/test_lame.py
new file mode 100644
index 00000000000..bffb11672b1
--- /dev/null
+++ b/support/testing/tests/package/test_lame.py
@@ -0,0 +1,20 @@
+from tests.package.test_audio_codec_base import TestAudioCodecBase
+
+
+class TestLame(TestAudioCodecBase):
+ __test__ = True
+ config = TestAudioCodecBase.config + \
+ """
+ BR2_PACKAGE_LAME=y
+ """
+ encoded_file = "encoded.mp3"
+
+ def encode_test(self, input_filename):
+ cmd = "lame --quiet"
+ cmd += f" {input_filename} {self.encoded_file}"
+ self.assertRunOk(cmd)
+
+ def decode_test(self, output_filename):
+ cmd = "lame --quiet --decode"
+ cmd += f" {self.encoded_file} {output_filename}"
+ self.assertRunOk(cmd)
--
2.45.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-06-15 9:16 [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Julien Olivain
2024-06-15 9:16 ` [Buildroot] [PATCH 2/2] support/testing: add lame runtime test Julien Olivain
@ 2024-06-15 18:09 ` Yann E. MORIN
2024-06-21 14:40 ` Julien Olivain
2024-08-06 21:24 ` Thomas Petazzoni via buildroot
2 siblings, 1 reply; 8+ messages in thread
From: Yann E. MORIN @ 2024-06-15 18:09 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
Julien, All,
On 2024-06-15 11:16 +0200, Julien Olivain spake thusly:
> This is a helper class providing a template for testing audio codec
> programs such as lame mp3 encoder, flac tools, ogg vorbis-tools, ...
>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
[--SNIP--]
> diff --git a/support/testing/tests/package/test_audio_codec_base.py b/support/testing/tests/package/test_audio_codec_base.py
> new file mode 100644
> index 00000000000..59c7efcad3c
> --- /dev/null
> +++ b/support/testing/tests/package/test_audio_codec_base.py
> @@ -0,0 +1,86 @@
> +import math
> +import os
> +
> +import infra.basetest
> +
> +
> +class TestAudioCodecBase(infra.basetest.BRTest):
> + """Common class to test an audio codec package.
> +
> + This base class builds a Buildroot system image containing the
> + package enabled in its config, start the emulator, login to it. It
> + prepares an input test WAV file containing a tone. This WAV file
> + is encoded into a new output file in the native encoder format. It
> + is then decoded to a new output WAV file. This final output WAV
> + file is checked to contain the expected tone generated in the
> + initial input WAV file. There is no specific check about file
> + size, nor audio quality. The acceptance criteria is the
> + recognition of the tone. Note: the tone generation is made with
> + the Sox package, and the tone recognition is made with the Aubio
> + package.
> +
> + Each test case that inherits from this class must have:
> + __test__ = True - to let nose2 know that it is a test case
If the class name does not stat with "Test", then nose2 will not
consider it a test case, it would not be necxessary to set __test__ =
False here, and rely on inheriters to set it.
I see that there are many such cases already in the tree, but I don;t
think we should continue in that direction.
Maybe just name this base calss as such:
class BaseAudioCodec(infra.basetest.BRTest):
But see below: I think we should consider it a test by itself: it
validates that the sox-aubio combo does work as expected.
[--SNIP--]
> + def encode_test(self, input_filename):
> + msg = "method must be implemented in derived class"
> + raise NotImplementedError(msg)
I am not python expert, but I think that would be better handled by an
"ABC", and Abstract Base Class (https://docs.python.org/3/library/abc.html),
which I think would look like:
import abc
class BaseAudioCodec(abc.ABC):
@abc.abstractmethod
def encode_test(self, input_filename):
...
Note that the ellipsis is really a real ellipsis, not a placeholder (see
https://docs.python.org/3/reference/datamodel.html#ellipsis).
But as I suggested above, we should just make this class a proper test,
and have empty encode() and decode() functions.
It would validate that the tone generated by sox can be decoded by
aubio.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-06-15 18:09 ` [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Yann E. MORIN
@ 2024-06-21 14:40 ` Julien Olivain
2024-08-07 19:35 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 8+ messages in thread
From: Julien Olivain @ 2024-06-21 14:40 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: buildroot
Hi Yann, All,
On 15/06/2024 18:09, Yann E. MORIN wrote:
> Julien, All,
>
> On 2024-06-15 11:16 +0200, Julien Olivain spake thusly:
>> This is a helper class providing a template for testing audio codec
>> programs such as lame mp3 encoder, flac tools, ogg vorbis-tools, ...
>>
>> Signed-off-by: Julien Olivain <ju.o@free.fr>
>> ---
> [--SNIP--]
>> diff --git a/support/testing/tests/package/test_audio_codec_base.py
>> b/support/testing/tests/package/test_audio_codec_base.py
>> new file mode 100644
>> index 00000000000..59c7efcad3c
>> --- /dev/null
>> +++ b/support/testing/tests/package/test_audio_codec_base.py
>> @@ -0,0 +1,86 @@
>> +import math
>> +import os
>> +
>> +import infra.basetest
>> +
>> +
>> +class TestAudioCodecBase(infra.basetest.BRTest):
>> + """Common class to test an audio codec package.
>> +
>> + This base class builds a Buildroot system image containing the
>> + package enabled in its config, start the emulator, login to it.
>> It
>> + prepares an input test WAV file containing a tone. This WAV file
>> + is encoded into a new output file in the native encoder format.
>> It
>> + is then decoded to a new output WAV file. This final output WAV
>> + file is checked to contain the expected tone generated in the
>> + initial input WAV file. There is no specific check about file
>> + size, nor audio quality. The acceptance criteria is the
>> + recognition of the tone. Note: the tone generation is made with
>> + the Sox package, and the tone recognition is made with the Aubio
>> + package.
>> +
>> + Each test case that inherits from this class must have:
>> + __test__ = True - to let nose2 know that it is a test case
>
> If the class name does not stat with "Test", then nose2 will not
> consider it a test case, it would not be necxessary to set __test__ =
> False here, and rely on inheriters to set it.
>
> I see that there are many such cases already in the tree, but I don;t
> think we should continue in that direction.
>
> Maybe just name this base calss as such:
>
> class BaseAudioCodec(infra.basetest.BRTest):
>
> But see below: I think we should consider it a test by itself: it
> validates that the sox-aubio combo does work as expected.
Renaming the "test_audio_codec_base.py" file to "audio_codec_base.py",
and the "TestAudioCodecBase" class to "AudioCodecBase" will not
prevent the test to be discovered by Nose2. This will prevent the file
and class to be selected at first. But if "__test__ = False" is not
present, it will still be indirectly loaded from the TestLame
import. This can be seen by adding "--log-level debug" in nose2
arguments.
While I do agree we could rename the file and class to better show the
intent this is an "abstract" class which does not include a test, I
think the "__test__ = False" needs to stay here to really prevent it
being loaded.
I'm not sure Nose2 was initially designed to support class hierarchy
like this. Nose2 has helpers to generate test case layers:
https://docs.nose2.io/en/latest/such_dsl.html
https://docs.nose2.io/en/latest/plugins/layers.html
> [--SNIP--]
>> + def encode_test(self, input_filename):
>> + msg = "method must be implemented in derived class"
>> + raise NotImplementedError(msg)
>
> I am not python expert, but I think that would be better handled by an
> "ABC", and Abstract Base Class
> (https://docs.python.org/3/library/abc.html),
> which I think would look like:
>
> import abc
> class BaseAudioCodec(abc.ABC):
> @abc.abstractmethod
> def encode_test(self, input_filename):
> ...
>
> Note that the ellipsis is really a real ellipsis, not a placeholder
> (see
> https://docs.python.org/3/reference/datamodel.html#ellipsis).
>
> But as I suggested above, we should just make this class a proper test,
> and have empty encode() and decode() functions.
>
> It would validate that the tone generated by sox can be decoded by
> aubio.
Regarding the use of "abc", I initially though and tried to use
it. The base class need to inherit from both abc.ABC and
infra.basetest.BRTest. Doing so makes Nose2 fail in test discovery
(probably because it tries to instantiate it). For example, running:
support/testing/run-tests -l ...
fails with output:
TypeError: Can't instantiate abstract class AudioCodecBase without
an implementation for abstract methods 'decode_test', 'encode_test'
The error happen even if files/classes are not beginning by "Test",
and the abstract class has "__test__ = False". Directly calling a
test works, though.
Disregarding the use of ABC or "raise NotImplementedError()", I still
think the class should remain "abstract". The purpose is to catch
forgotten implementations of encode_test()/decode_test() in new test
cases.
I agree the base class audio codec sequence, relying on sox and aubio
_could_ be tested in itself, with a "null" or "passthough" codec,
emulated with cp/mv commands. I think we can do that by adding a new
test inheriting from the base abstract class. We could argue that a
problem in this sox/aubio sequence could be detected in any test (if
not all) using this base class. The reason I did not included this is
because this test takes some time to compile and run, due to the
presence of the target Python. I also think child classes will cover
for most issues in this base class.
If you think this base class test is not needed, I believe the series
can be applied as is.
If you think the base class still need to be self-tested, I can send a
v2 with the following changes:
- rename the "TestAudioCodecBase" class to "AudioCodecBase",
- add a new "TestAudioCodecBase" class for testing "AudioCodecBase"
using cp/mv as a "null codec", in test_audio_codec_base.py.
This means that such a v2 would:
- keep the file name as test_audio_codec_base.py,
- keep __test__ = False/True,
- keep the "raise NotImplementedError()" (i.e don't use abc.ABC)
In the long term, we could also:
- improve or propose changes in Nose2 to handle or exclude abstract
classes,
- switch to another test framework, there was a proposal for pytest
in:
https://patchwork.ozlabs.org/project/buildroot/patch/20221021091531.2989489-2-oguz.ozhan@mind.be/
- ...
What to you think?
>
> Regards,
> Yann E. MORIN.
>
> --
> .-----------------.--------------------.------------------.--------------------.
> | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> conspiracy: |
> | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___
> |
> | +33 561 099 427 `------------.-------: X AGAINST | \e/ There
> is no |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v
> conspiracy. |
> '------------------------------^-------^------------------^--------------------'
Best regards,
Julien.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-06-15 9:16 [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Julien Olivain
2024-06-15 9:16 ` [Buildroot] [PATCH 2/2] support/testing: add lame runtime test Julien Olivain
2024-06-15 18:09 ` [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Yann E. MORIN
@ 2024-08-06 21:24 ` Thomas Petazzoni via buildroot
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-06 21:24 UTC (permalink / raw)
To: Julien Olivain; +Cc: Yann E. MORIN, buildroot
On Sat, 15 Jun 2024 11:16:11 +0200
Julien Olivain <ju.o@free.fr> wrote:
> This is a helper class providing a template for testing audio codec
> programs such as lame mp3 encoder, flac tools, ogg vorbis-tools, ...
>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> DEVELOPERS | 1 +
> .../tests/package/test_audio_codec_base.py | 86 +++++++++++++++++++
> 2 files changed, 87 insertions(+)
> create mode 100644 support/testing/tests/package/test_audio_codec_base.py
Thanks, series applied!
Yann: I have read your good feedback and arguments, but I believe
Julien gave some solid explanations/counter-arguments. Generally
speaking, what Julien proposed is well aligned with the current
"philosophy" of the test cases, so I decided to apply. Also, if we were
to change how abstract test classes are done, we should rework it in a
global manner for all test cases, and not have multiple ways of doing
the same thing in different test cases.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-06-21 14:40 ` Julien Olivain
@ 2024-08-07 19:35 ` Thomas Petazzoni via buildroot
2024-08-07 21:09 ` Julien Olivain
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-07 19:35 UTC (permalink / raw)
To: Julien Olivain; +Cc: Yann E. MORIN, buildroot
Hello Julien,
On Fri, 21 Jun 2024 14:40:20 +0000
Julien Olivain <ju.o@free.fr> wrote:
> Renaming the "test_audio_codec_base.py" file to "audio_codec_base.py",
> and the "TestAudioCodecBase" class to "AudioCodecBase" will not
> prevent the test to be discovered by Nose2. This will prevent the file
> and class to be selected at first. But if "__test__ = False" is not
> present, it will still be indirectly loaded from the TestLame
> import. This can be seen by adding "--log-level debug" in nose2
> arguments.
>
> While I do agree we could rename the file and class to better show the
> intent this is an "abstract" class which does not include a test, I
> think the "__test__ = False" needs to stay here to really prevent it
> being loaded.
Apparently, not. Look at:
https://patchwork.ozlabs.org/project/buildroot/patch/f57167b1488b3c5ad76362dd8bca1b12d281aa19.1696522656.git.yann.morin.1998@free.fr/
proposed by Yann. The abstract class doesn't start with Test, it
doesn't have __test__ = false, and it isn't considered as a test by
nose2.
Now, look at:
https://patchwork.ozlabs.org/project/buildroot/patch/33ee4b08c20f9c4566cfe82c648f01599cab70b5.1696522656.git.yann.morin.1998@free.fr/
which uses multiple inheritance, doesn't defined __test__ = true, and
is properly considered by nose2.
Could you have a look as to why this pattern wouldn't work for your
audio codec situation?
Thanks a lot,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-08-07 19:35 ` Thomas Petazzoni via buildroot
@ 2024-08-07 21:09 ` Julien Olivain
2024-08-07 21:20 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 8+ messages in thread
From: Julien Olivain @ 2024-08-07 21:09 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Yann E. MORIN, buildroot
Hi Thomas,
On 07/08/2024 21:35, Thomas Petazzoni wrote:
> Hello Julien,
>
> On Fri, 21 Jun 2024 14:40:20 +0000
> Julien Olivain <ju.o@free.fr> wrote:
>
>> Renaming the "test_audio_codec_base.py" file to "audio_codec_base.py",
>> and the "TestAudioCodecBase" class to "AudioCodecBase" will not
>> prevent the test to be discovered by Nose2. This will prevent the file
>> and class to be selected at first. But if "__test__ = False" is not
>> present, it will still be indirectly loaded from the TestLame
>> import. This can be seen by adding "--log-level debug" in nose2
>> arguments.
>>
>> While I do agree we could rename the file and class to better show the
>> intent this is an "abstract" class which does not include a test, I
>> think the "__test__ = False" needs to stay here to really prevent it
>> being loaded.
>
> Apparently, not. Look at:
>
>
> https://patchwork.ozlabs.org/project/buildroot/patch/f57167b1488b3c5ad76362dd8bca1b12d281aa19.1696522656.git.yann.morin.1998@free.fr/
>
> proposed by Yann. The abstract class doesn't start with Test, it
> doesn't have __test__ = false, and it isn't considered as a test by
> nose2.
>
> Now, look at:
>
>
> https://patchwork.ozlabs.org/project/buildroot/patch/33ee4b08c20f9c4566cfe82c648f01599cab70b5.1696522656.git.yann.morin.1998@free.fr/
>
> which uses multiple inheritance, doesn't defined __test__ = true, and
> is properly considered by nose2.
>
> Could you have a look as to why this pattern wouldn't work for your
> audio codec situation?
I think the reason the test gets registered many times is because the
"abstract" class contains a test_run() function. The way nose2 scans
for test will search in all the class hierarchy. The only way to
prevent that for now is the __test__ = False.
We can see the selection of test if we add debug in nose2 discovery:
nose2.discover(argv=[script_path,
"-s", test_dir,
"-v",
"--collect-only",
"--log-level", "debug"],
plugins=["nose2.plugins.collect"])
in support/testing/run-tests, and invoking with "run-tests -l".
The reason I've put a test_run() function in the abstract class is
because
I would like to keep the same test sequence for all those audio tests.
Maybe nose2 discovery should not recurse in the class hierarchy? The
only
way I to prevent that would be to modify the loader at:
https://github.com/nose-devs/nose2/blob/main/nose2/plugins/loader/discovery.py
Would you like me to propose a change of this nose2 behavior?
Best regards,
Julien.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class
2024-08-07 21:09 ` Julien Olivain
@ 2024-08-07 21:20 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-07 21:20 UTC (permalink / raw)
To: Julien Olivain; +Cc: Yann E. MORIN, buildroot
Hello,
On Wed, 07 Aug 2024 23:09:00 +0200
Julien Olivain <ju.o@free.fr> wrote:
> I think the reason the test gets registered many times is because the
> "abstract" class contains a test_run() function. The way nose2 scans
> for test will search in all the class hierarchy. The only way to
> prevent that for now is the __test__ = False.
>
> We can see the selection of test if we add debug in nose2 discovery:
>
> nose2.discover(argv=[script_path,
> "-s", test_dir,
> "-v",
> "--collect-only",
> "--log-level", "debug"],
> plugins=["nose2.plugins.collect"])
>
> in support/testing/run-tests, and invoking with "run-tests -l".
>
> The reason I've put a test_run() function in the abstract class is
> because
> I would like to keep the same test sequence for all those audio tests.
Right, and I think it makes sense.
> Maybe nose2 discovery should not recurse in the class hierarchy? The
> only
> way I to prevent that would be to modify the loader at:
> https://github.com/nose-devs/nose2/blob/main/nose2/plugins/loader/discovery.py
>
> Would you like me to propose a change of this nose2 behavior?
No strong opinion. I'm not particularly attached to nose2. I think
someone mentioned pytest as an alternative?
I don't know if nose2 is still actively developed, if it makes sense to
"invest" in this compared to some other solutions.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-08-07 21:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-15 9:16 [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Julien Olivain
2024-06-15 9:16 ` [Buildroot] [PATCH 2/2] support/testing: add lame runtime test Julien Olivain
2024-06-15 18:09 ` [Buildroot] [PATCH 1/2] support/testing: test_audio_codec_base.py: new helper class Yann E. MORIN
2024-06-21 14:40 ` Julien Olivain
2024-08-07 19:35 ` Thomas Petazzoni via buildroot
2024-08-07 21:09 ` Julien Olivain
2024-08-07 21:20 ` Thomas Petazzoni via buildroot
2024-08-06 21:24 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox