[RFC,0/4] fpga: add initial KUnit test suite for the subsystem

Message ID 20230203170653.414990-1-marpagan@redhat.com
Headers
Series fpga: add initial KUnit test suite for the subsystem |

Message

Marco Pagani Feb. 3, 2023, 5:06 p.m. UTC
  This patch set introduces a KUnit suite to test the core components
of the FPGA subsystem. More specifically, the suite tests the core
functions of the FPGA manager, FPGA bridge, and FPGA region.

These components are tested using "fake" modules that allow
observing their internals without altering the source code.

The test suite can be run using
[user@localhost linux]$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/fpga/tests

Marco Pagani (4):
  fpga: add initial KUnit test suite
  fpga: add fake FPGA region
  fpga: add fake FPGA manager
  fpga: add fake FPGA bridge

 drivers/fpga/Kconfig                  |   2 +
 drivers/fpga/Makefile                 |   3 +
 drivers/fpga/tests/.kunitconfig       |   5 +
 drivers/fpga/tests/Kconfig            |  15 ++
 drivers/fpga/tests/Makefile           |   6 +
 drivers/fpga/tests/fake-fpga-bridge.c | 214 +++++++++++++++
 drivers/fpga/tests/fake-fpga-bridge.h |  36 +++
 drivers/fpga/tests/fake-fpga-mgr.c    | 365 ++++++++++++++++++++++++++
 drivers/fpga/tests/fake-fpga-mgr.h    |  42 +++
 drivers/fpga/tests/fake-fpga-region.c | 186 +++++++++++++
 drivers/fpga/tests/fake-fpga-region.h |  37 +++
 drivers/fpga/tests/fpga-tests.c       | 264 +++++++++++++++++++
 12 files changed, 1175 insertions(+)
 create mode 100644 drivers/fpga/tests/.kunitconfig
 create mode 100644 drivers/fpga/tests/Kconfig
 create mode 100644 drivers/fpga/tests/Makefile
 create mode 100644 drivers/fpga/tests/fake-fpga-bridge.c
 create mode 100644 drivers/fpga/tests/fake-fpga-bridge.h
 create mode 100644 drivers/fpga/tests/fake-fpga-mgr.c
 create mode 100644 drivers/fpga/tests/fake-fpga-mgr.h
 create mode 100644 drivers/fpga/tests/fake-fpga-region.c
 create mode 100644 drivers/fpga/tests/fake-fpga-region.h
 create mode 100644 drivers/fpga/tests/fpga-tests.c
  

Comments

Russ Weight Feb. 14, 2023, 1:20 a.m. UTC | #1
On 2/3/23 09:06, Marco Pagani wrote:
> This patch set introduces a KUnit suite to test the core components
> of the FPGA subsystem. More specifically, the suite tests the core
> functions of the FPGA manager, FPGA bridge, and FPGA region.
>
> These components are tested using "fake" modules that allow
> observing their internals without altering the source code.
>
> The test suite can be run using
> [user@localhost linux]$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/fpga/tests
When I tried running these tests, I got an error until I created this file:

drivers/fpga/tests/.kunitconfig:
CONFIG_KUNIT=y
CONFIG_FPGA=y
CONFIG_FPGA_REGION=y
CONFIG_FPGA_BRIDGE=y
CONFIG_FPGA_KUNIT_TESTS=y

I think this file needs to be included in your patchset?

- Russ

>
> Marco Pagani (4):
>   fpga: add initial KUnit test suite
>   fpga: add fake FPGA region
>   fpga: add fake FPGA manager
>   fpga: add fake FPGA bridge
>
>  drivers/fpga/Kconfig                  |   2 +
>  drivers/fpga/Makefile                 |   3 +
>  drivers/fpga/tests/.kunitconfig       |   5 +
>  drivers/fpga/tests/Kconfig            |  15 ++
>  drivers/fpga/tests/Makefile           |   6 +
>  drivers/fpga/tests/fake-fpga-bridge.c | 214 +++++++++++++++
>  drivers/fpga/tests/fake-fpga-bridge.h |  36 +++
>  drivers/fpga/tests/fake-fpga-mgr.c    | 365 ++++++++++++++++++++++++++
>  drivers/fpga/tests/fake-fpga-mgr.h    |  42 +++
>  drivers/fpga/tests/fake-fpga-region.c | 186 +++++++++++++
>  drivers/fpga/tests/fake-fpga-region.h |  37 +++
>  drivers/fpga/tests/fpga-tests.c       | 264 +++++++++++++++++++
>  12 files changed, 1175 insertions(+)
>  create mode 100644 drivers/fpga/tests/.kunitconfig
>  create mode 100644 drivers/fpga/tests/Kconfig
>  create mode 100644 drivers/fpga/tests/Makefile
>  create mode 100644 drivers/fpga/tests/fake-fpga-bridge.c
>  create mode 100644 drivers/fpga/tests/fake-fpga-bridge.h
>  create mode 100644 drivers/fpga/tests/fake-fpga-mgr.c
>  create mode 100644 drivers/fpga/tests/fake-fpga-mgr.h
>  create mode 100644 drivers/fpga/tests/fake-fpga-region.c
>  create mode 100644 drivers/fpga/tests/fake-fpga-region.h
>  create mode 100644 drivers/fpga/tests/fpga-tests.c
>
  
Marco Pagani Feb. 15, 2023, 11:19 a.m. UTC | #2
On 2023-02-14 02:20, Russ Weight wrote:
> 
> 
> On 2/3/23 09:06, Marco Pagani wrote:
>> This patch set introduces a KUnit suite to test the core components
>> of the FPGA subsystem. More specifically, the suite tests the core
>> functions of the FPGA manager, FPGA bridge, and FPGA region.
>>
>> These components are tested using "fake" modules that allow
>> observing their internals without altering the source code.
>>
>> The test suite can be run using
>> [user@localhost linux]$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/fpga/tests
> When I tried running these tests, I got an error until I created this file:
> 
> drivers/fpga/tests/.kunitconfig:
> CONFIG_KUNIT=y
> CONFIG_FPGA=y
> CONFIG_FPGA_REGION=y
> CONFIG_FPGA_BRIDGE=y
> CONFIG_FPGA_KUNIT_TESTS=y
> 
> I think this file needs to be included in your patchset?
> 
> - Russ
>


Patch 1/4 includes a .kunitconfig file with these configs set =y

> diff --git a/drivers/fpga/tests/.kunitconfig b/drivers/fpga/tests/.kunitconfig
> new file mode 100644
> index 000000000000..a1c2a2974c39
> --- /dev/null
> +++ b/drivers/fpga/tests/.kunitconfig
> @@ -0,0 +1,5 @@
> +CONFIG_KUNIT=y
> +CONFIG_FPGA=y
> +CONFIG_FPGA_REGION=y
> +CONFIG_FPGA_BRIDGE=y
> +CONFIG_FPGA_KUNIT_TESTS=y

To double-check for any patch format errors, I downloaded the patch set
from lore.kernel.org and applied it on a fresh tree with Git (version
2.39.1) using git am. In my case, Git created the .kunitconfig file and
I was able to run the tests.


>>
>> Marco Pagani (4):
>>   fpga: add initial KUnit test suite
>>   fpga: add fake FPGA region
>>   fpga: add fake FPGA manager
>>   fpga: add fake FPGA bridge
>>
>>  drivers/fpga/Kconfig                  |   2 +
>>  drivers/fpga/Makefile                 |   3 +
>>  drivers/fpga/tests/.kunitconfig       |   5 +
>>  drivers/fpga/tests/Kconfig            |  15 ++
>>  drivers/fpga/tests/Makefile           |   6 +
>>  drivers/fpga/tests/fake-fpga-bridge.c | 214 +++++++++++++++
>>  drivers/fpga/tests/fake-fpga-bridge.h |  36 +++
>>  drivers/fpga/tests/fake-fpga-mgr.c    | 365 ++++++++++++++++++++++++++
>>  drivers/fpga/tests/fake-fpga-mgr.h    |  42 +++
>>  drivers/fpga/tests/fake-fpga-region.c | 186 +++++++++++++
>>  drivers/fpga/tests/fake-fpga-region.h |  37 +++
>>  drivers/fpga/tests/fpga-tests.c       | 264 +++++++++++++++++++
>>  12 files changed, 1175 insertions(+)
>>  create mode 100644 drivers/fpga/tests/.kunitconfig
>>  create mode 100644 drivers/fpga/tests/Kconfig
>>  create mode 100644 drivers/fpga/tests/Makefile
>>  create mode 100644 drivers/fpga/tests/fake-fpga-bridge.c
>>  create mode 100644 drivers/fpga/tests/fake-fpga-bridge.h
>>  create mode 100644 drivers/fpga/tests/fake-fpga-mgr.c
>>  create mode 100644 drivers/fpga/tests/fake-fpga-mgr.h
>>  create mode 100644 drivers/fpga/tests/fake-fpga-region.c
>>  create mode 100644 drivers/fpga/tests/fake-fpga-region.h
>>  create mode 100644 drivers/fpga/tests/fpga-tests.c
>>
> 

Thanks,
Marco
  
Russ Weight Feb. 15, 2023, 4:43 p.m. UTC | #3
On 2/15/23 03:19, Marco Pagani wrote:
>> When I tried running these tests, I got an error until I created this file:
>>
>> drivers/fpga/tests/.kunitconfig:
>> CONFIG_KUNIT=y
>> CONFIG_FPGA=y
>> CONFIG_FPGA_REGION=y
>> CONFIG_FPGA_BRIDGE=y
>> CONFIG_FPGA_KUNIT_TESTS=y
>>
>> I think this file needs to be included in your patchset?
>>
>> - Russ
>>
> Patch 1/4 includes a .kunitconfig file with these configs set =y
>
>> diff --git a/drivers/fpga/tests/.kunitconfig b/drivers/fpga/tests/.kunitconfig
>> new file mode 100644
>> index 000000000000..a1c2a2974c39
>> --- /dev/null
>> +++ b/drivers/fpga/tests/.kunitconfig
>> @@ -0,0 +1,5 @@
>> +CONFIG_KUNIT=y
>> +CONFIG_FPGA=y
>> +CONFIG_FPGA_REGION=y
>> +CONFIG_FPGA_BRIDGE=y
>> +CONFIG_FPGA_KUNIT_TESTS=y
> To double-check for any patch format errors, I downloaded the patch set
> from lore.kernel.org and applied it on a fresh tree with Git (version
> 2.39.1) using git am. In my case, Git created the .kunitconfig file and
> I was able to run the tests.
>
>
I can see the .kunitconfig file in the emailed patch. I had to resolve
some conflicts when I applied patch #1 - I must have missed this file
when I committed the changes.

Thanks,
- Russ