mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-12-05 08:10:21 +01:00
2023-11-08 Fred Gleason <fredg@paravelsystems.com>
* Added a 'rml_torture_test' test harness in 'tests/'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -157,6 +157,7 @@ tests/rdwavefile_test
|
|||||||
tests/rdxml_parse_test
|
tests/rdxml_parse_test
|
||||||
tests/readcd_test
|
tests/readcd_test
|
||||||
tests/reserve_carts_test
|
tests/reserve_carts_test
|
||||||
|
tests/rml_torture_test
|
||||||
tests/sas_switch_torture
|
tests/sas_switch_torture
|
||||||
tests/sas_torture
|
tests/sas_torture
|
||||||
tests/sendmail_test
|
tests/sendmail_test
|
||||||
|
|||||||
@@ -24464,3 +24464,5 @@
|
|||||||
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>
|
2023-11-08 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Added a 'gpio_fuzz_test' test harness in 'tests/'.
|
* Added a 'gpio_fuzz_test' test harness in 'tests/'.
|
||||||
|
2023-11-08 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added a 'rml_torture_test' test harness in 'tests/'.
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ noinst_PROGRAMS = audio_convert_test\
|
|||||||
rdxml_parse_test\
|
rdxml_parse_test\
|
||||||
readcd_test\
|
readcd_test\
|
||||||
reserve_carts_test\
|
reserve_carts_test\
|
||||||
|
rml_torture_test\
|
||||||
sendmail_test\
|
sendmail_test\
|
||||||
stringcode_test\
|
stringcode_test\
|
||||||
test_hash\
|
test_hash\
|
||||||
@@ -136,6 +137,9 @@ readcd_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAG
|
|||||||
dist_reserve_carts_test_SOURCES = reserve_carts_test.cpp reserve_carts_test.h
|
dist_reserve_carts_test_SOURCES = reserve_carts_test.cpp reserve_carts_test.h
|
||||||
reserve_carts_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
reserve_carts_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
|
||||||
|
dist_rml_torture_test_SOURCES = rml_torture_test.cpp rml_torture_test.h
|
||||||
|
rml_torture_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
|
||||||
dist_sendmail_test_SOURCES = sendmail_test.cpp sendmail_test.h
|
dist_sendmail_test_SOURCES = sendmail_test.cpp sendmail_test.h
|
||||||
sendmail_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
sendmail_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||||
|
|
||||||
|
|||||||
106
tests/rml_torture_test.cpp
Normal file
106
tests/rml_torture_test.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
// rml_torture_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 "rml_torture_test.h"
|
||||||
|
|
||||||
|
MainObject::MainObject(QObject *parent)
|
||||||
|
{
|
||||||
|
QStringList rmls;
|
||||||
|
QHostAddress host_address("127.0.0.1");
|
||||||
|
int interval=1000;
|
||||||
|
bool verbose=false;
|
||||||
|
bool ok=false;
|
||||||
|
int offset=0;
|
||||||
|
|
||||||
|
RDCmdSwitch *cmd=new RDCmdSwitch("rml_torture_test",RML_TORTURE_TEST_USAGE);
|
||||||
|
|
||||||
|
for(unsigned i=0;i<cmd->keys();i++) {
|
||||||
|
if(cmd->key(i)=="--rml") {
|
||||||
|
rmls.push_back(cmd->value(i));
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(cmd->key(i)=="--host-address") {
|
||||||
|
if(!host_address.setAddress(cmd->value(i))) {
|
||||||
|
fprintf(stderr,"rml_torture_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,"rml_torture_test: invalid --interval\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,"rml_torture_test: unknown option \"%s\"\n",
|
||||||
|
cmd->key(i).toUtf8().constData());
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
cmd->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(rmls.size()==0) {
|
||||||
|
fprintf(stderr,"rml_torture_test: no RML commands specified\n");
|
||||||
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send Socket
|
||||||
|
//
|
||||||
|
QUdpSocket *send_socket=new QUdpSocket(this);
|
||||||
|
|
||||||
|
while(1==1) {
|
||||||
|
if(verbose) {
|
||||||
|
printf("%s\n",rmls.at(offset).toUtf8().constData());
|
||||||
|
}
|
||||||
|
send_socket->
|
||||||
|
writeDatagram(rmls.at(offset).toUtf8(),host_address,RD_RML_NOECHO_PORT);
|
||||||
|
offset+=1;
|
||||||
|
offset=offset%rmls.size();
|
||||||
|
usleep(1000*interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc,char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc,argv);
|
||||||
|
new MainObject();
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
36
tests/rml_torture_test.h
Normal file
36
tests/rml_torture_test.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// rml_torture_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 RML_TORTURE_TEST_H
|
||||||
|
#define RML_TORTURE_TEST_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#define RML_TORTURE_TEST_USAGE "[options]\n\nGenerate a series of Rivendell RML command\n\nOptions are:\n--rml=<rml-cmd>\n RML command to send (may be given multiple times)\n\n--host-address=<addr>\n IP address of system to execute events\n\n--interval=<msec>\n Wait <msec> milliseconds between commands\n\n--verbose\n Print events to stdout\n\n"
|
||||||
|
|
||||||
|
|
||||||
|
class MainObject : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainObject(QObject *parent=0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // RML_TORTURE_TEST_H
|
||||||
Reference in New Issue
Block a user