mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-07 07:57:44 +02:00
2023-11-08 Fred Gleason <fredg@paravelsystems.com>
* Added a 'gpio_fuzz_test' test harness in 'tests/'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
96911261d2
commit
a7078a51a6
1
.gitignore
vendored
1
.gitignore
vendored
@ -147,6 +147,7 @@ tests/delete_test
|
|||||||
tests/download_test
|
tests/download_test
|
||||||
tests/feed_image_test
|
tests/feed_image_test
|
||||||
tests/getpids_test
|
tests/getpids_test
|
||||||
|
tests/gpio_fuzz_test
|
||||||
tests/log_unlink_test
|
tests/log_unlink_test
|
||||||
tests/mcast_recv_test
|
tests/mcast_recv_test
|
||||||
tests/metadata_wildcard_test
|
tests/metadata_wildcard_test
|
||||||
|
@ -24462,3 +24462,5 @@
|
|||||||
2023-11-06 Fred Gleason <fredg@paravelsystems.com>
|
2023-11-06 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Added checks to the 'Add Scheduler Code' dialog in rdadmin(1) to
|
* Added checks to the 'Add Scheduler Code' dialog in rdadmin(1) to
|
||||||
enforce the use of only alphanumeric characters plus space.
|
enforce the use of only alphanumeric characters plus space.
|
||||||
|
2023-11-08 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added a 'gpio_fuzz_test' test harness in 'tests/'.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
## Makefile.am
|
## Makefile.am
|
||||||
##
|
##
|
||||||
## (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
|
## (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License version 2 as
|
## it under the terms of the GNU General Public License version 2 as
|
||||||
@ -39,6 +39,7 @@ noinst_PROGRAMS = audio_convert_test\
|
|||||||
download_test\
|
download_test\
|
||||||
feed_image_test\
|
feed_image_test\
|
||||||
getpids_test\
|
getpids_test\
|
||||||
|
gpio_fuzz_test\
|
||||||
log_unlink_test\
|
log_unlink_test\
|
||||||
mcast_recv_test\
|
mcast_recv_test\
|
||||||
metadata_wildcard_test\
|
metadata_wildcard_test\
|
||||||
@ -99,6 +100,9 @@ feed_image_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @
|
|||||||
dist_getpids_test_SOURCES = getpids_test.cpp getpids_test.h
|
dist_getpids_test_SOURCES = getpids_test.cpp getpids_test.h
|
||||||
getpids_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
getpids_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
|
||||||
|
dist_gpio_fuzz_test_SOURCES = gpio_fuzz_test.cpp gpio_fuzz_test.h
|
||||||
|
gpio_fuzz_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
|
||||||
dist_log_unlink_test_SOURCES = log_unlink_test.cpp log_unlink_test.h
|
dist_log_unlink_test_SOURCES = log_unlink_test.cpp log_unlink_test.h
|
||||||
nodist_log_unlink_test_SOURCES = moc_log_unlink_test.cpp
|
nodist_log_unlink_test_SOURCES = moc_log_unlink_test.cpp
|
||||||
log_unlink_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
log_unlink_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
169
tests/gpio_fuzz_test.cpp
Normal file
169
tests/gpio_fuzz_test.cpp
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
// gpio_fuzz_test.cpp
|
||||||
|
//
|
||||||
|
// Generate a series of Rivendell GPIO events.
|
||||||
|
//
|
||||||
|
// (C) Copyright 2010-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QUdpSocket>
|
||||||
|
|
||||||
|
#include <rd.h>
|
||||||
|
#include <rdcmd_switch.h>
|
||||||
|
#include <rdcoreapplication.h>
|
||||||
|
|
||||||
|
#include "gpio_fuzz_test.h"
|
||||||
|
|
||||||
|
MainObject::MainObject(QObject *parent)
|
||||||
|
{
|
||||||
|
bool gpis=false;
|
||||||
|
bool gpos=false;
|
||||||
|
QHostAddress host_address("127.0.0.1");
|
||||||
|
int interval=1000;
|
||||||
|
int first_line_number=-1;
|
||||||
|
int last_line_number=-1;
|
||||||
|
int matrix_number=-1;
|
||||||
|
int line_number=-1;
|
||||||
|
bool verbose=false;
|
||||||
|
bool ok=false;
|
||||||
|
|
||||||
|
QString type;
|
||||||
|
|
||||||
|
RDCmdSwitch *cmd=new RDCmdSwitch("gpio_fuzz_test",GPIO_FUZZ_TEST_USAGE);
|
||||||
|
|
||||||
|
for(unsigned i=0;i<cmd->keys();i++) {
|
||||||
|
if(cmd->key(i)=="--gpis") {
|
||||||
|
gpis=true;
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--gpos") {
|
||||||
|
gpos=true;
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--host-address") {
|
||||||
|
if(!host_address.setAddress(cmd->value(i))) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: invalid --host-address\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--interval") {
|
||||||
|
interval=cmd->value(i).toInt(&ok);
|
||||||
|
if((!ok)||(interval<=0)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: invalid --interval\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--first-line-number") {
|
||||||
|
first_line_number=cmd->value(i).toInt(&ok);
|
||||||
|
if((!ok)||(first_line_number<=0)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: invalid --first-line-number\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--last-line-number") {
|
||||||
|
last_line_number=cmd->value(i).toInt(&ok);
|
||||||
|
if((!ok)||(last_line_number<=0)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: invalid --last-line-number\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--matrix-number") {
|
||||||
|
matrix_number=cmd->value(i).toInt(&ok);
|
||||||
|
if((!ok)||(matrix_number<0)||(matrix_number>=MAX_MATRICES)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: invalid --matrix-number\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--verbose") {
|
||||||
|
verbose=true;
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(!cmd->processed(i)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: unknown option \"%s\"\n",
|
||||||
|
cmd->key(i).toUtf8().constData());
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((!gpis)&&(!gpos)) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: no GPIO types specified\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
if(matrix_number<0) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: no --matrix-number specified\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
if(first_line_number<0) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: no --first-line-number specified\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
if(last_line_number<0) {
|
||||||
|
fprintf(stderr,"gpio_fuzz_test: no --last-line-number specified\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send Socket
|
||||||
|
//
|
||||||
|
QUdpSocket *send_socket=new QUdpSocket(this);
|
||||||
|
|
||||||
|
while(1==1) {
|
||||||
|
if(gpis) {
|
||||||
|
type="I";
|
||||||
|
}
|
||||||
|
if(gpos) {
|
||||||
|
type="O";
|
||||||
|
}
|
||||||
|
if(gpis&&gpos) {
|
||||||
|
if(random()<(RAND_MAX/2)) {
|
||||||
|
type="I";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
type="O";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line_number=
|
||||||
|
first_line_number+((int64_t)(1+last_line_number-first_line_number)*(int64_t)random())/RAND_MAX;
|
||||||
|
QString msg=QString::asprintf("GO %d %s %d 1 300!",
|
||||||
|
matrix_number,
|
||||||
|
type.toUtf8().constData(),
|
||||||
|
line_number);
|
||||||
|
if(verbose) {
|
||||||
|
printf("%s\n",msg.toUtf8().constData());
|
||||||
|
}
|
||||||
|
send_socket->writeDatagram(msg.toUtf8(),host_address,RD_RML_NOECHO_PORT);
|
||||||
|
usleep(1000*interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc,argv);
|
||||||
|
new MainObject();
|
||||||
|
return a.exec();
|
||||||
|
}
|
38
tests/gpio_fuzz_test.h
Normal file
38
tests/gpio_fuzz_test.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// gpio_fuzz_test.h
|
||||||
|
//
|
||||||
|
// Generate a series of Rivendell GPIO events.
|
||||||
|
//
|
||||||
|
// (C) Copyright 2010-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef GPIO_FUZZ_TEST_H
|
||||||
|
#define GPIO_FUZZ_TEST_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#define GPIO_FUZZ_TEST_USAGE "[options]\n\nGenerate a series of Rivendell GPIO events\n\nOptions are:\n--first-line-number=<line-num>\n First number of the range of line numbers to test\n\n--gpis\n Include GPI events in the test\n\n--gpos\n Include GPO events in the test\n\n--host-address=<addr>\n IP address of system to execute events\n\n--interval=<msec>\n Wait <msec> milliseconds between events\n\n--last-line-number=<line-num>\n Last number of the range of line numbers to test\n\n--matrix-number=<num>\n GPIO matrix number (0-7)\n\n--verbose\n Print events to stdout\n\n"
|
||||||
|
|
||||||
|
|
||||||
|
class MainObject : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainObject(QObject *parent=0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // GPIO_FUZZ_TEST_H
|
Loading…
x
Reference in New Issue
Block a user