[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: master Commit: 0165782dbde8cea4da45cd65df0c7e5f7fc17e12 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0165782dbde8cea4da45cd65df0c7e5f7fc17e12 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: stable-3.0.x Commit: 0165782dbde8cea4da45cd65df0c7e5f7fc17e12 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0165782dbde8cea4da45cd65df0c7e5f7fc17e12 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL;
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/drivers Commit: 0165782dbde8cea4da45cd65df0c7e5f7fc17e12 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0165782dbde8cea4da45cd65df0c7e5f7fc17e12 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/drivers Commit: a45d979c699a01ae7293ab2075c9db2aa6c6a204 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a45d979c699a01ae7293ab2075c9db2aa6c6a204 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/drivers Commit: defe11f57a83c6a92062b09ab7d9dff4f1374046 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=defe11f57a83c6a92062b09ab7d9dff4f1374046 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/gpio Commit: 6cab0a45871ba6116b2ef76008d171a38dfba7ad URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6cab0a45871ba6116b2ef76008d171a38dfba7ad Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/gpio Commit: 898532ac4952edc99093c530002483e8a7fa9e27 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=898532ac4952edc99093c530002483e8a7fa9e27 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/gpio Commit: a2851a6eb9b8e774d8907cf53a5effeea244cc3a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a2851a6eb9b8e774d8907cf53a5effeea244cc3a Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +
[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite
Module: xenomai-3 Branch: wip/gpio Commit: e29e39f3b5a6a73d6b6ca5dc3e45dbc63c7c9045 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e29e39f3b5a6a73d6b6ca5dc3e45dbc63c7c9045 Author: Philippe Gerum Date: Wed Jun 1 15:59:27 2016 +0200 testsuite/gpiotest: add GPIO test suite --- testsuite/Makefile.am |2 + testsuite/gpiotest/Makefile.am | 19 testsuite/gpiotest/gpiotest.c | 188 3 files changed, 209 insertions(+) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index e83e6cb..c345472 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -4,12 +4,14 @@ SUBDIRS = latency smokey if XENO_COBALT SUBDIRS += \ clocktest \ + gpiotest\ switchtest \ xeno-test endif DIST_SUBDIRS = \ clocktest \ + gpiotest\ latency \ smokey \ switchtest \ diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am new file mode 100644 index 000..b01427b --- /dev/null +++ b/testsuite/gpiotest/Makefile.am @@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = gpiotest + +gpiotest_SOURCES = gpiotest.c + +gpiotest_CPPFLAGS =\ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +gpiotest_LDADD = \ + ../../lib/smokey/libsmokey.la \ + ../../lib/@XENO_CORE_LIB@ \ +@XENO_USER_LDADD@ \ + -lpthread -lrt diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c new file mode 100644 index 000..838f498 --- /dev/null +++ b/testsuite/gpiotest/gpiotest.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2016 Philippe Gerum . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +smokey_test_plugin(interrupt, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Wait for interrupts from a GPIO pin.\n" + "\tdevice=." +); + +smokey_test_plugin(read_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Read GPIO value.\n" + "\tdevice=." +); + +smokey_test_plugin(write_value, + SMOKEY_ARGLIST( + SMOKEY_STRING(device), + ), + "Write GPIO value.\n" + "\tdevice=." +); + +static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret; + fd_set set; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(interrupt, device)) { + warning("missing device= specification"); + return -EINVAL; + } + + device = SMOKEY_ARG_STRING(interrupt, device); + fd = open(device, O_RDWR); + if (fd < 0) { + ret = -errno; + warning("cannot open device %s [%s]", + device, symerror(ret)); + return ret; + } + + ret = ioctl(fd, GPIO_RTIOC_IRQEN); + if (ret) { + ret = -errno; + warning("GPIO_RTIOC_IRQEN failed on %s [%s]", + device, symerror(ret)); + return ret; + } + + FD_ZERO(&set); + FD_SET(fd, &set); + + for (;;) { + ret = select(fd + 1, &set, NULL, NULL, NULL); + if (ret < 0) { + ret = -errno; + warning("failed listening to %s [%s]", + device, symerror(ret)); + } + printf("kick %d!\n", ret); + } + + close(fd); + + return 0; +} + +static int run_read_value(struct smokey_test *t, int argc, char *const argv[]) +{ + const char *device = NULL; + int fd, ret, value = -1; + + smokey_parse_args(t, argc, argv); + + if (!SMOKEY_ARG_ISSET(read_value, device)) { + warning("missing device= specification"); + return -EINVAL; +