selftests for drivers/fpga
Subsystems (3)
[email protected]
reviewercover selftests for drivers/fpga
From: Tom Rix <[email protected]>
repo : linux-next
tag : next-20200608
Start applying selftests to drivers/fpga.
While testing out this upcoming change on linux-fpga 'Add interrupt support to FPGA DFL drivers'
I did not see any existing fpga tests.
So I added one.
Tom Rix (1):
selftests: fpga: dfl: A test for afu interrupt support
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/drivers/fpga/Makefile | 9 +++++ .../testing/selftests/drivers/fpga/afu_intr.c | 38 +++++++++++++++++++ tools/testing/selftests/drivers/fpga/config | 1 + 4 files changed, 49 insertions(+) create mode 100644 tools/testing/selftests/drivers/fpga/Makefile create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c create mode 100644 tools/testing/selftests/drivers/fpga/config
Signature · 1 line
2.18.1
[email protected]
reviewerPATCH 1/1 selftests: fpga: dfl: A test for afu interrupt support
From: Tom Rix <[email protected]>
Check that the ioctl DFL_FPGA_PORT_ERR_GET_IRQ_NUM returns an expected result.
Tested on vf device 0xbcc1
Sample run with
$ sudo make -C tools/testing/selftests TARGETS=drivers/fpga run_tests ... ok 1 selftests: drivers/fpga: afu_intr
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/drivers/fpga/Makefile | 9 +++++ .../testing/selftests/drivers/fpga/afu_intr.c | 38 +++++++++++++++++++ tools/testing/selftests/drivers/fpga/config | 1 + 4 files changed, 49 insertions(+) create mode 100644 tools/testing/selftests/drivers/fpga/Makefile create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c create mode 100644 tools/testing/selftests/drivers/fpga/config
tools/testing/selftests/Makefile +1 -0
@@ -9,6 +9,7 @@ TARGETS += clone3 TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += drivers/dma-buf +TARGETS += drivers/fpga TARGETS += efivarfs TARGETS += exec TARGETS += filesystems
tools/testing/selftests/drivers/fpga/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +CFLAGS += -I../../../../../usr/include/ +CFLAGS += -I../../../../../include/uapi/ + +TEST_GEN_PROGS := afu_intr + +top_srcdir ?=../../../../.. + +include ../../lib.mk
tools/testing/selftests/drivers/fpga/afu_intr.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <linux/fcntl.h> +#include <linux/fpga-dfl.h> + +#define TEST_PREFIX "drivers/fpga/afu_intr" + +int main (int argc,char *argv[]) +{ +int devfd, status; +struct dfl_fpga_port_info port_info; +uint32_t irq_num; + + devfd =open ("/dev/dfl-port.0" ,O_RDONLY ); +if (devfd <0 ) { +printf ("%s: [skip,no-ufpgaintr]\n" ,TEST_PREFIX ); +exit (77 ); + } + +/* +* From fpga-dl.h : +* Currently hardware supports up to 1 irq. +* Return: 0 on success, -errno on failure. +*/ + irq_num =-1 ; + status =ioctl (devfd,DFL_FPGA_PORT_ERR_GET_IRQ_NUM , &irq_num); +if (status !=0 || irq_num >255 ) { +printf ("%s: [FAIL,err-get-irq-num]\n" ,TEST_PREFIX ); +close (devfd); +exit (1 ); + } + +close (devfd); +return 0 ; +}
tools/testing/selftests/drivers/fpga/config new file +1 -0
@@ -0,0 +1 @@ +CONFIG_FPGA_DFL_AFU=m
Signature · 1 line
2.18.1
Greg KH
maintainerRe: [PATCH 1/1] selftests: fpga: dfl: A test for afu interrupt support
Quoted 84 lines · On Tue, Jun 09, 2020 at 06:02:08AM -0700, [email protected] wrote:
From: Tom Rix <[email protected]>
Check that the ioctl
DFL_FPGA_PORT_ERR_GET_IRQ_NUMreturns an expected result.Tested on vf device
0xbcc1Sample run with
$ sudo make -C tools/testing/selftests TARGETS=drivers/fpga run_tests ... ok 1 selftests: drivers/fpga: afu_intrSigned-off-by Tom Rix <[email protected]>--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/drivers/fpga/Makefile | 9 +++++ .../testing/selftests/drivers/fpga/afu_intr.c | 38 +++++++++++++++++++ tools/testing/selftests/drivers/fpga/config | 1 + 4 files changed, 49 insertions(+) create mode 100644 tools/testing/selftests/drivers/fpga/Makefile create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c create mode 100644 tools/testing/selftests/drivers/fpga/configtools/testing/selftests/Makefile +1
-0@@ -9,6 +9,7 @@ TARGETS += clone3 TARGETS += cpufreq TARGETS += cpu-hotplug TARGETS += drivers/dma-buf +TARGETS += drivers/fpga TARGETS += efivarfs TARGETS += exec TARGETS += filesystemstools/testing/selftests/drivers/fpga/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +CFLAGS += -I../../../../../usr/include/ +CFLAGS += -I../../../../../include/uapi/ + +TEST_GEN_PROGS := afu_intr + +top_srcdir ?=../../../../.. + +include ../../lib.mktools/testing/selftests/drivers/fpga/afu_intr.c new file +28
-0@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <linux/fcntl.h> +#include <linux/fpga-dfl.h> + +#define TEST_PREFIX "drivers/fpga/afu_intr" + +int main (int argc,char *argv[]) +{ +int devfd, status; +struct dfl_fpga_port_info port_info; +uint32_t irq_num; + + devfd =open ("/dev/dfl-port.0" ,O_RDONLY ); +if (devfd <0 ) { +printf ("%s: [skip,no-ufpgaintr]\n" ,TEST_PREFIX ); +exit (77 ); + } + +/* +* From fpga-dl.h : +* Currently hardware supports up to 1 irq. +* Return: 0 on success, -errno on failure. +*/ + irq_num =-1 ;
tools/testing/selftests/drivers/fpga/afu_intr.c line 38
Quoted 10 lines
tools/testing/selftests/drivers/fpga/afu_intr.c new file +10
-0+ status =ioctl (devfd,DFL_FPGA_PORT_ERR_GET_IRQ_NUM , &irq_num); +if (status !=0 || irq_num >255 ) { +printf ("%s: [FAIL,err-get-irq-num]\n" ,TEST_PREFIX ); +close (devfd); +exit (1 ); + } + +close (devfd); +return 0 ; +}
Why not use the ksft_* functions and frameworks to properly print out the test status and results so that tools can correctly parse it?
It's generally bad-form to make up your own format.
thanks,
gre gk-h
Tom Rix
reviewerRe: [PATCH 1/1] selftests: fpga: dfl: A test for afu interrupt support
Quoted 5 lines
Why not use the ksft_* functions and frameworks to properly print out the test status and results so that tools can correctly parse it?
It's generally bad-form to make up your own format.
I used the the drivers/dma-buf test a basis example. Can you point me at a better example ?
T
Quoted 4 lines
thanks,
gre gk-h
Shuah Khan
maintainerRe: [PATCH 1/1] selftests: fpga: dfl: A test for afu interrupt support
Quoted 8 lines · Tom Rix
Quoted 5 lines
Why not use the ksft_* functions and frameworks to properly print out the test status and results so that tools can correctly parse it?
It's generally bad-form to make up your own format.
I used the the
drivers/dma-buftest a basis example. Can you point me at a better example ?
A few examples to choose from as a reference:
tools/testing/selftests/breakpointstools/testing/selftests/timens
Please reach out to me if you have any questions.
thanks,
-- Shuah