Initial import of CVS-v2_8_branch

This commit is contained in:
Fred Gleason
2014-08-12 15:13:02 -04:00
commit afd67c7af8
1508 changed files with 405304 additions and 0 deletions

94
tests/Makefile.am Normal file
View File

@@ -0,0 +1,94 @@
## automake.am
##
## Automake.am for rivendell/tests
##
## (C) Copyright 2002-2006 Fred Gleason <fredg@paravelsystems.com>
##
## $Id: Makefile.am,v 1.14.8.4.2.1 2014/05/30 00:26:30 cvs Exp $
##
## 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.
##
##
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall @QT_CXXFLAGS@
INCLUDES = -I$(top_srcdir)/lib
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
moc_%.cpp: %.h
$(MOC) $< -o $@
noinst_PROGRAMS = audio_convert_test\
audio_export_test\
audio_import_test\
datedecode_test\
reserve_carts_test\
sas_switch_torture\
sas_torture\
stringcode_test\
test_pam\
timer_test\
upload_test
dist_audio_convert_test_SOURCES = audio_convert_test.cpp audio_convert_test.h
audio_convert_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_audio_export_test_SOURCES = audio_export_test.cpp audio_export_test.h
audio_export_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_audio_import_test_SOURCES = audio_import_test.cpp audio_import_test.h
audio_import_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_datedecode_test_SOURCES = datedecode_test.cpp datedecode_test.h
datedecode_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_reserve_carts_test_SOURCES = reserve_carts_test.cpp reserve_carts_test.h
reserve_carts_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_sas_switch_torture_SOURCES = sas_switch_torture.cpp sas_switch_torture.h
nodist_sas_switch_torture_SOURCES = moc_sas_switch_torture.cpp
sas_switch_torture_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_sas_torture_SOURCES = sas_torture.cpp sas_torture.h
nodist_sas_torture_SOURCES = moc_sas_torture.cpp
sas_torture_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_stringcode_test_SOURCES = stringcode_test.cpp stringcode_test.h
stringcode_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_test_pam_SOURCES = test_pam.cpp test_pam.h
test_pam_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
dist_timer_test_SOURCES = timer_test.cpp timer_test.h
nodist_timer_test_SOURCES = moc_timer_test.cpp
timer_test_LDADD = -lqui
dist_upload_test_SOURCES = upload_test.cpp upload_test.h
upload_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
EXTRA_DIST = rivendell_standard.txt\
visualtraffic.txt
CLEANFILES = *~\
moc_*
MAINTAINERCLEANFILES = *~\
*.tar.gz\
aclocal.m4\
configure\
Makefile.in\
moc_*

View File

@@ -0,0 +1,202 @@
// audio_convert_test.cpp
//
// Test the Rivendell file format converter.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_convert_test.cpp,v 1.3 2011/06/21 22:20:44 cvs Exp $
//
// 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 <qapplication.h>
#include <rddb.h>
#include <rdcmd_switch.h>
#include <rdaudioconvert.h>
#include <audio_convert_test.h>
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
unsigned schema=0;
destination_settings=new RDSettings();
start_point=-1;
end_point=-1;
speed_ratio=1.0;
bool ok=false;
RDAudioConvert::ErrorCode conv_err;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"audio_convert_test",
AUDIO_CONVERT_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--source-file") {
source_filename=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-file") {
destination_filename=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--start-point") {
start_point=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid start point\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--end-point") {
end_point=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid end point\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-format") {
RDSettings::Format format=(RDSettings::Format)cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid destination format\n");
exit(256);
}
switch(format) {
case RDSettings::Pcm16:
case RDSettings::MpegL2:
case RDSettings::MpegL2Wav:
case RDSettings::MpegL3:
case RDSettings::Flac:
case RDSettings::OggVorbis:
destination_settings->setFormat(format);
cmd->setProcessed(i,true);
break;
default:
fprintf(stderr,"audio_convert_test: invalid destination format\n");
exit(256);
}
destination_settings->setFormat(format);
}
if(cmd->key(i)=="--destination-channels") {
unsigned channels=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid destination channels\n");
exit(256);
}
destination_settings->setChannels(channels);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-sample-rate") {
unsigned sample_rate=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid destination sample rate\n");
exit(256);
}
destination_settings->setSampleRate(sample_rate);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-bit-rate") {
unsigned bit_rate=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid destination bit rate\n");
exit(256);
}
destination_settings->setBitRate(bit_rate);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--quality") {
unsigned quality=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_convert_test: invalid destination quality\n");
exit(256);
}
destination_settings->setQuality(quality);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--normalization-level") {
int normalization_level=cmd->value(i).toInt(&ok);
if((!ok)||(normalization_level>0)) {
fprintf(stderr,"audio_convert_test: invalid normalization level\n");
exit(256);
}
destination_settings->setNormalizationLevel(normalization_level);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--speed-ratio") {
speed_ratio=cmd->value(i).toFloat(&ok);
if((!ok)||(speed_ratio<=0)) {
fprintf(stderr,"audio_convert_test: invalid speed-ratio\n");
exit(256);
}
cmd->setProcessed(i,true);
}
}
if(source_filename.isEmpty()) {
fprintf(stderr,"audio_convert_test: missing source-file\n");
exit(256);
}
if(destination_filename.isEmpty()) {
fprintf(stderr,"audio_convert_test: missing destination-file\n");
exit(256);
}
if((destination_settings->bitRate()!=0)&&
(destination_settings->quality()!=0)) {
fprintf(stderr,"audio_convert_test: --destination-bit-rate and --destination-quality are mutually exclusive\n");
exit(256);
}
//
// Read Configuration
//
rdconfig=new RDConfig();
rdconfig->load();
//
// Open Database
//
QString err (tr("audio_convert_test: "));
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
fprintf(stderr,err.ascii());
delete cmd;
exit(256);
}
RDAudioConvert *conv=new RDAudioConvert(rdconfig->stationName(),this);
conv->setSourceFile(source_filename);
conv->setDestinationFile(destination_filename);
conv->setDestinationSettings(destination_settings);
conv->setRange(start_point,end_point);
conv->setSpeedRatio(speed_ratio);
printf("Converting...\n");
conv_err=conv->convert();
printf("Result: %s\n",(const char *)RDAudioConvert::errorText(conv_err));
delete conv;
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

View File

@@ -0,0 +1,58 @@
// audio_convert_test.h
//
// Test the Rivendell file format converter.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_convert_test.h,v 1.2 2010/07/29 19:32:38 cvs Exp $
//
// 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 AUDIO_CONVERT_TEST_H
#define AUDIO_CONVERT_TEST_H
#include <list>
#include <qobject.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdsettings.h>
#include <rdcmd_switch.cpp>
#define AUDIO_CONVERT_TEST_USAGE "[options]\n\nTest the Rivendell audio converter routines\n\nOptions are:\n--source-file=<filename>\n\n--destination-file=<filename>\n\n--start-point=<msecs>\n\n--end-point=<msecs>\n\n--destination-format=<fmt>\n Supported formats are:\n 0 - PCM16 WAV\n 2 - MPEG Layer 2\n 3 - MPEG Layer 3\n 4 - FLAC\n 5 - OggVorbis\n 6 - MPEG Layer 2 WAV\n\n--destination-channels=<chans>\n\n--destination-sample-rate=<rate>\n\n--destination-bit-rate=<rate>\n\n--destination-quality=<qual>\n\n--normalization-level=<dbfs>\n\n--speed-ratio=<ratio>\n\n"
//
// Global Variables
//
RDConfig *rdconfig;
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
private:
QString source_filename;
QString destination_filename;
int start_point;
int end_point;
float speed_ratio;
RDSettings *destination_settings;
};
#endif // AUDIO_CONVERT_TEST_H

224
tests/audio_export_test.cpp Normal file
View File

@@ -0,0 +1,224 @@
// audio_export_test.cpp
//
// Test the Rivendell file format exporter.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_export_test.cpp,v 1.5.4.1 2013/11/13 23:36:38 cvs Exp $
//
// 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 <qapplication.h>
#include <rddb.h>
#include <rdcmd_switch.h>
#include <rdaudioexport.h>
#include <rdstation.h>
#include <audio_export_test.h>
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
username="user";
password="";
destination_settings=new RDSettings();
cart_number=0;
cut_number=0;
start_point=-1;
end_point=-1;
bool ok=false;
RDAudioConvert::ErrorCode audio_conv_err;
RDAudioExport::ErrorCode conv_err;
unsigned schema=0;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"audio_export_test",
AUDIO_EXPORT_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--username") {
username=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--password") {
password=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--cart-number") {
cart_number=cmd->value(i).toUInt(&ok);
if((!ok)||(cart_number>999999)) {
fprintf(stderr,"audio_export_test: invalid cart number\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--cut-number") {
cut_number=cmd->value(i).toUInt(&ok);
if((!ok)||(cut_number>999)) {
fprintf(stderr,"audio_export_test: invalid cut number\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-file") {
destination_filename=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--start-point") {
start_point=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid start point\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--end-point") {
end_point=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid end point\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-format") {
RDSettings::Format format=(RDSettings::Format)cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid destination format\n");
exit(256);
}
switch(format) {
case RDSettings::Pcm16:
case RDSettings::MpegL2:
case RDSettings::MpegL2Wav:
case RDSettings::MpegL3:
case RDSettings::Flac:
case RDSettings::OggVorbis:
destination_settings->setFormat(format);
cmd->setProcessed(i,true);
break;
default:
fprintf(stderr,"audio_export_test: invalid destination format\n");
exit(256);
}
destination_settings->setFormat(format);
}
if(cmd->key(i)=="--destination-channels") {
unsigned channels=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid destination channels\n");
exit(256);
}
destination_settings->setChannels(channels);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-sample-rate") {
unsigned sample_rate=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid destination sample rate\n");
exit(256);
}
destination_settings->setSampleRate(sample_rate);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-bit-rate") {
unsigned bit_rate=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid destination bit rate\n");
exit(256);
}
destination_settings->setBitRate(bit_rate);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--quality") {
unsigned quality=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_export_test: invalid destination quality\n");
exit(256);
}
destination_settings->setQuality(quality);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--normalization-level") {
int normalization_level=cmd->value(i).toInt(&ok);
if((!ok)||(normalization_level>0)) {
fprintf(stderr,"audio_export_test: invalid normalization level\n");
exit(256);
}
destination_settings->setNormalizationLevel(normalization_level);
cmd->setProcessed(i,true);
}
}
if(cart_number==0) {
fprintf(stderr,"audio_export_test: missing cart-number\n");
exit(256);
}
if(cut_number==0) {
fprintf(stderr,"audio_export_test: missing cut-number\n");
exit(256);
}
if(destination_filename.isEmpty()) {
fprintf(stderr,"audio_export_test: missing destination-file\n");
exit(256);
}
if((destination_settings->bitRate()!=0)&&
(destination_settings->quality()!=0)) {
fprintf(stderr,"audio_export_test: --destination-bit-rate and --destination-quality are mutually exclusive\n");
exit(256);
}
//
// Read Configuration
//
rdconfig=new RDConfig();
rdconfig->load();
//
// Open Database
//
QString err (tr("audio_export_test: "));
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
fprintf(stderr,err.ascii());
delete cmd;
exit(256);
}
RDStation *station=new RDStation(rdconfig->stationName());
RDAudioExport *conv=new RDAudioExport(station,rdconfig,this);
conv->setCartNumber(cart_number);
conv->setCutNumber(cut_number);
conv->setDestinationFile(destination_filename);
conv->setDestinationSettings(destination_settings);
conv->setRange(start_point,end_point);
printf("Exporting...\n");
conv_err=conv->runExport(username,password,&audio_conv_err);
printf("Result: %s\n",
(const char *)RDAudioExport::errorText(conv_err,audio_conv_err));
delete conv;
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

60
tests/audio_export_test.h Normal file
View File

@@ -0,0 +1,60 @@
// audio_export_test.h
//
// Test the Rivendell file format converter.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_export_test.h,v 1.2 2010/07/29 19:32:38 cvs Exp $
//
// 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 AUDIO_EXPORT_TEST_H
#define AUDIO_EXPORT_TEST_H
#include <list>
#include <qobject.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdsettings.h>
#include <rdcmd_switch.cpp>
#define AUDIO_EXPORT_TEST_USAGE "[options]\n\nTest the Rivendell audio exporter routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--cart-number=<cartnum>\n\n--cut-number=<cutnum>\n\n--destination-file=<filename>\n\n--start-point=<msecs>\n\n--end-point=<msecs>\n\n--destination-format=<fmt>\n Supported formats are:\n 0 - PCM16 WAV\n 2 - MPEG Layer 2\n 3 - MPEG Layer 3\n 4 - FLAC\n 5 - OggVorbis\n 6 - MPEG Layer 2 WAV\n\n--destination-channels=<chans>\n\n--destination-sample-rate=<rate>\n\n--destination-bit-rate=<rate>\n\n--destination-quality=<qual>\n\n--normalization-level=<dbfs>\n\n"
//
// Global Variables
//
RDConfig *rdconfig;
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
private:
QString username;
QString password;
unsigned cart_number;
unsigned cut_number;
QString destination_filename;
int start_point;
int end_point;
RDSettings *destination_settings;
};
#endif // AUDIO_EXPORT_TEST_H

164
tests/audio_import_test.cpp Normal file
View File

@@ -0,0 +1,164 @@
// audio_import_test.cpp
//
// Test Rivendell file importing.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_import_test.cpp,v 1.5.4.1 2013/11/13 23:36:38 cvs Exp $
//
// 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 <qapplication.h>
#include <rddb.h>
#include <rdcmd_switch.h>
#include <rdaudioimport.h>
#include <audio_import_test.h>
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
username="user";
password="";
destination_settings=new RDSettings();
cart_number=0;
cut_number=0;
use_metadata=false;
bool ok=false;
RDAudioConvert::ErrorCode audio_conv_err;
RDAudioImport::ErrorCode conv_err;
unsigned schema=0;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"audio_import_test",
AUDIO_IMPORT_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--username") {
username=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--password") {
password=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--cart-number") {
cart_number=cmd->value(i).toUInt(&ok);
if((!ok)||(cart_number>999999)) {
fprintf(stderr,"audio_import_test: invalid cart number\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--cut-number") {
cut_number=cmd->value(i).toUInt(&ok);
if((!ok)||(cut_number>999)) {
fprintf(stderr,"audio_import_test: invalid cut number\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--source-file") {
source_filename=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-channels") {
unsigned channels=cmd->value(i).toInt(&ok);
if(!ok) {
fprintf(stderr,"audio_import_test: invalid destination channels\n");
exit(256);
}
destination_settings->setChannels(channels);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--normalization-level") {
int normalization_level=cmd->value(i).toInt(&ok);
if((!ok)||(normalization_level>0)) {
fprintf(stderr,"audio_import_test: invalid normalization level\n");
exit(256);
}
destination_settings->setNormalizationLevel(normalization_level);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--autotrim-level") {
int autotrim_level=cmd->value(i).toInt(&ok);
if((!ok)||(autotrim_level>0)) {
fprintf(stderr,"audio_import_test: invalid autotrim level\n");
exit(256);
}
destination_settings->setAutotrimLevel(autotrim_level);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--use-metadata") {
use_metadata=true;
cmd->setProcessed(i,true);
}
}
if(cart_number==0) {
fprintf(stderr,"audio_import_test: missing cart-number\n");
exit(256);
}
if(cut_number==0) {
fprintf(stderr,"audio_import_test: missing cut-number\n");
exit(256);
}
if(source_filename.isEmpty()) {
fprintf(stderr,"audio_import_test: missing source-file\n");
exit(256);
}
//
// Read Configuration
//
rdconfig=new RDConfig();
rdconfig->load();
//
// Open Database
//
QString err (tr("audio_import_test: "));
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
fprintf(stderr,err.ascii());
delete cmd;
exit(256);
}
RDStation *station=new RDStation(rdconfig->stationName());
RDAudioImport *conv=new RDAudioImport(station,rdconfig,this);
conv->setCartNumber(cart_number);
conv->setCutNumber(cut_number);
conv->setSourceFile(source_filename);
conv->setDestinationSettings(destination_settings);
conv->setUseMetadata(use_metadata);
printf("Importing...\n");
conv_err=conv->runImport(username,password,&audio_conv_err);
printf("Result: %s\n",
(const char *)RDAudioImport::errorText(conv_err,audio_conv_err));
delete conv;
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

59
tests/audio_import_test.h Normal file
View File

@@ -0,0 +1,59 @@
// audio_import_test.h
//
// Test Rivendell file importing
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: audio_import_test.h,v 1.2 2010/07/29 19:32:38 cvs Exp $
//
// 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 AUDIO_IMPORT_TEST_H
#define AUDIO_IMPORT_TEST_H
#include <list>
#include <qobject.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdsettings.h>
#include <rdcmd_switch.cpp>
#define AUDIO_IMPORT_TEST_USAGE "[options]\n\nTest the Rivendell audio importer routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--cart-number=<cartnum>\n\n--cut-number=<cutnum>\n\n--source-file=<filename>\n\n--destination-channels=<chans>\n\n--normalization-level=<dbfs>\n\n--autotrim-level=<dbfs>\n\n--use-metadata\n\n"
//
// Global Variables
//
RDConfig *rdconfig;
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
private:
QString username;
QString password;
unsigned cart_number;
unsigned cut_number;
QString source_filename;
RDSettings *destination_settings;
bool use_metadata;
};
#endif // AUDIO_IMPORT_TEST_H

91
tests/datedecode_test.cpp Normal file
View File

@@ -0,0 +1,91 @@
// datedecode_test.cpp
//
// Test the Rivendell db connection routines.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: datedecode_test.cpp,v 1.1.2.3 2013/10/16 21:14:37 cvs Exp $
//
// 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 <stdlib.h>
#include <stdio.h>
#include <qapplication.h>
#include <qvariant.h>
#include <rdcmd_switch.h>
#include <rddatedecode.h>
#include "datedecode_test.h"
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
QString date="";
QString datetime="";
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"datedecode_test",
DATEDECODE_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--date") {
date=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--datetime") {
datetime=cmd->value(i);
cmd->setProcessed(i,true);
}
if(!cmd->processed(i)) {
fprintf(stderr,"datedecode_test: unknown option \"%s\"\n",
(const char *)cmd->value(i));
exit(256);
}
}
if((!date.isEmpty())&&(!datetime.isEmpty())) {
fprintf(stderr,
"datedecode_test: --date and --datetime are mutually exclusive\n");
exit(256);
}
if(date.isEmpty()&&datetime.isEmpty()) {
fprintf(stderr,
"datedecode_test: you must specify either --date or --datetime\n");
exit(256);
}
//
// Process Code
//
if(!date.isEmpty()) {
printf("%s\n",
(const char *)RDDateDecode(date,QDate::currentDate()));
}
if(!datetime.isEmpty()) {
printf("%s\n",(const char *)RDDateTimeDecode(datetime,QDateTime(QDate::currentDate(),QTime::currentTime())));
}
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

37
tests/datedecode_test.h Normal file
View File

@@ -0,0 +1,37 @@
// datedecode_test.h
//
// Test the Rivendell date decoder routines.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: datedecode_test.h,v 1.1.2.2 2012/05/10 23:12:43 cvs Exp $
//
// 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 DATEDECODE_TEST_H
#define DATEDECODE_TEST_H
#include <qobject.h>
#define DATEDECODE_TEST_USAGE "[options]\n\nTest the Rivendell date decoding routines\n\nOptions are:\n--date=<date-code>\n Decode the <date-code> string using RDDateDecode() and print the result\n on stdout.\n\n--datetime=<datetime-code>\n Decode the <datetime-code> string using RDDateTimeDecode() and print\n the result on stdout.\n\n"
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
};
#endif // DATEDECODE_TEST_H

View File

@@ -0,0 +1,133 @@
// reserve_carts_test.cpp
//
// Test the Rivendell db connection routines.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: reserve_carts_test.cpp,v 1.1.2.1 2014/05/30 00:26:31 cvs Exp $
//
// 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 <stdlib.h>
#include <stdio.h>
#include <vector>
#include <qapplication.h>
#include <qvariant.h>
#include <rdconfig.h>
#include <rdgroup.h>
#include <rdcmd_switch.h>
#include <rddb.h>
#include "reserve_carts_test.h"
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
RDConfig *config;
QString group_name;
unsigned quantity=0;
bool ok=false;
RDGroup *group=NULL;
std::vector<unsigned> cart_nums;
unsigned schema=0;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"reserve_carts_test",
RESERVE_CARTS_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--group") {
group_name=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--quantity") {
quantity=cmd->value(i).toUInt(&ok);
if(!ok) {
fprintf(stderr,"invalid --quantity specified\n");
exit(256);
}
cmd->setProcessed(i,true);
}
if(!cmd->processed(i)) {
fprintf(stderr,"reserve_carts_test: unknown option \"%s\"\n",
(const char *)cmd->value(i));
exit(256);
}
}
//
// Sanity Checks
//
if(quantity<1) {
fprintf(stderr,"reserve_carts_test: you must reserve at least one cart\n");
exit(256);
}
if(group_name.isEmpty()) {
fprintf(stderr,"you must specify a group\n");
exit(256);
}
//
// Load Configuration
//
config=new RDConfig();
config->load();
//
// Open Database
//
QString err (tr("upload_test: "));
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
fprintf(stderr,err.ascii());
delete cmd;
exit(256);
}
//
// Run the Test
//
group=new RDGroup(group_name);
if(!group->exists()) {
fprintf(stderr,"group \"%s\" does not exist\n",
(const char *)group_name.utf8());
exit(256);
}
if(group->reserveCarts(&cart_nums,config->stationName(),RDCart::Audio,
quantity)) {
printf("reserved the following carts:\n");
for(unsigned i=0;i<cart_nums.size();i++) {
printf("%06u\n",cart_nums[i]);
}
}
else {
printf("reservation failed\n");
}
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

View File

@@ -0,0 +1,37 @@
// reserve_carts_test.h
//
// Test the Rivendell cart reservation routines.
//
// (C) Copyright 2014 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: reserve_carts_test.h,v 1.1.2.1 2014/05/30 00:26:31 cvs Exp $
//
// 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 RESERVE_CARTS_TEST_H
#define RESERVE_CARTS_TEST_H
#include <qobject.h>
#define RESERVE_CARTS_TEST_USAGE "[options]\n\nTest the Rivendell cart reservation routines\n\nOptions are:\n--group=<name>\n Name of group to reserve carts in.\n\n--quantity=<num>\n Number of carts to reserve.\n\n"
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
};
#endif // RESERVE_CARTS_TEST_H

5
tests/rivendell_standard.txt Executable file
View File

@@ -0,0 +1,5 @@
11:32:14 999004 Short Cart 1 00:01:00 01234567890123456789012345678901
11:32:29 010005 Luminiferous Ether 00:02:40 01234567890123456789012345678901
11:51:07 999004 Short Cart 1 00:03:00 01234567890123456789012345678901
11:51:22 010005 Luminiferous Ether 00:01:00 01234567890123456789012345678901
11:52:17 999004 Short Cart 1 02:01:00 01234567890123456789012345678901

View File

@@ -0,0 +1,189 @@
// sas_switch_torture.cpp
//
// A Qt-based application for playing Microsoft WAV files.
//
// (C) Copyright 2002-2005 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: sas_switch_torture.cpp,v 1.9 2011/06/21 22:20:44 cvs Exp $
//
// 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 <stdlib.h>
#include <unistd.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qdatetime.h>
#include <rd.h>
#include <rddb.h>
#include <sas_switch_torture.h>
MainWidget::MainWidget(QWidget *parent,const char *name)
:QWidget(parent,name)
{
unsigned schema=0;
//
// Fix the Window Size
//
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
//
// Generate Fonts
//
QFont font("Helvetica",12,QFont::Normal);
font.setPixelSize(12);
//
// Open Database
//
rd_config=new RDConfig(RD_CONF_FILE);
rd_config->load();
QString err;
test_db=RDInitDb(&schema,&err);
if(!test_db) {
QMessageBox::warning(this,"Can't Connect",
err,0,1,1);
exit(0);
}
//
// Generate Button
//
QPushButton *button=new QPushButton(this,"generate_button");
button->setGeometry(10,10,sizeHint().width()-20,50);
button->setText("Generate Test");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(generateData()));
//
// Remove Button
//
button=new QPushButton(this,"remove_button");
button->setGeometry(10,70,sizeHint().width()-20,50);
button->setText("Remove Test");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(removeData()));
//
// Exit Button
//
button=new QPushButton(this,"cancel_button");
button->setGeometry(10,130,sizeHint().width()-20,50);
button->setText("Exit");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));
}
QSize MainWidget::sizeHint() const
{
return QSize(200,190);
}
QSizePolicy MainWidget::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
void MainWidget::generateData()
{
QString sql;
RDSqlQuery *q;
QString rml;
QString desc;
//
// Create Schedule
//
QTime time;
for(int i=0;i<86400000;i+=TIME_INTERVAL) {
for(int j=0;j<SAS_INPUTS;j++) {
for(int k=0;k<SAS_OUTPUTS;k++) {
desc=QString().sprintf("Switch SAS Output %d",j+1);
sql=QString().sprintf("insert into RECORDINGS set STATION_NAME=\"%s\",\
CHANNEL=%d,SWITCH_INPUT=%d,SWITCH_OUTPUT=%d,\
SUN=\'Y\',MON=\'Y\',TUE=\'Y\',WED=\'Y\',THU=\'Y\',\
FRI=\'Y\',SAT=\'Y\',DESCRIPTION=\"%s\",\
CUT_NAME=\"SAS_SWITCH_TORTURE\",\
START_TIME=\"%s\",TYPE=1",
SAS_STATION,
SAS_MATRIX,
j+1,
k+1,
(const char *)desc,
(const char *)time.toString("hh:mm:ss"));
q=new RDSqlQuery(sql);
delete q;
}
}
time=time.addMSecs(TIME_INTERVAL);
}
}
void MainWidget::removeData()
{
QString sql;
RDSqlQuery *q;
//
// Delete Carts
//
sql=QString("delete from CART where ARTIST=\"SAS_SWITCH_TORTURE\"");
q=new RDSqlQuery(sql);
delete q;
//
// Delete Schedule
//
sql=QString("delete from RECORDINGS where CUT_NAME=\"SAS_SWITCH_TORTURE\"");
q=new RDSqlQuery(sql);
delete q;
}
void MainWidget::cancelData()
{
qApp->quit();
}
void MainWidget::closeEvent(QCloseEvent *e)
{
cancelData();
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv);
MainWidget *w=new MainWidget(NULL,"main");
a.setMainWidget(w);
w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
w->show();
return a.exec();
}

View File

@@ -0,0 +1,63 @@
// sas_switch_torture.h
//
// Generate Rivendell macro carts and scheduling for torture-testing
// an SAS router
//
// (C) Copyright 2002-2004 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: sas_switch_torture.h,v 1.6 2010/07/29 19:32:39 cvs Exp $
//
// 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 SAS_SWITCH_TORTURE_H
#define SAS_SWITCH_TORTURE_H
#include <qwidget.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#define SAS_INPUTS 32
#define SAS_OUTPUTS 16
#define SAS_STATION "hithlum"
#define SAS_MATRIX 1
#define SAS_SLEEP 20
#define CART_START 10000
#define TIME_INTERVAL 2000
class MainWidget : public QWidget
{
Q_OBJECT
public:
MainWidget(QWidget *parent=0,const char *name=0);
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
private slots:
void generateData();
void removeData();
void cancelData();
void closeEvent(QCloseEvent *e);
private:
QSqlDatabase *test_db;
QString test_filename;
RDConfig *rd_config;
};
#endif // SAS_SWITCH_TORTURE_H

200
tests/sas_torture.cpp Normal file
View File

@@ -0,0 +1,200 @@
// sas_torture.cpp
//
// A Qt-based application for playing Microsoft WAV files.
//
// (C) Copyright 2002 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: sas_torture.cpp,v 1.10 2011/06/21 22:20:44 cvs Exp $
//
// 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 <stdlib.h>
#include <unistd.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qdatetime.h>
#include <rd.h>
#include <rddb.h>
#include <sas_torture.h>
MainWidget::MainWidget(QWidget *parent,const char *name)
:QWidget(parent,name)
{
unsigned schema=0;
//
// Fix the Window Size
//
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
//
// Generate Fonts
//
QFont font("Helvetica",12,QFont::Normal);
font.setPixelSize(12);
//
// Open Database
//
rd_config=new RDConfig(RD_CONF_FILE);
rd_config->load();
QString err;
test_db=RDInitDb(&schema,&err);
if(!test_db) {
QMessageBox::warning(this,"Can't Connect",
err,0,1,1);
exit(0);
}
//
// Generate Button
//
QPushButton *button=new QPushButton(this,"generate_button");
button->setGeometry(10,10,sizeHint().width()-20,50);
button->setText("Generate Test");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(generateData()));
//
// Remove Button
//
button=new QPushButton(this,"remove_button");
button->setGeometry(10,70,sizeHint().width()-20,50);
button->setText("Remove Test");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(removeData()));
//
// Exit Button
//
button=new QPushButton(this,"cancel_button");
button->setGeometry(10,130,sizeHint().width()-20,50);
button->setText("Exit");
button->setFont(font);
connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));
}
QSize MainWidget::sizeHint() const
{
return QSize(200,190);
}
QSizePolicy MainWidget::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
void MainWidget::generateData()
{
QString sql;
RDSqlQuery *q;
QString rml;
QString desc;
//
// Create Carts
//
for(int i=0;i<SAS_OUTPUTS;i++) {
rml=QString();
for(int j=0;j<SAS_INPUTS;j++) {
rml+=QString().sprintf("ST %d %d %d!SP %d!",
SAS_MATRIX,j+1,i+1,SAS_SLEEP);
}
sql=QString().sprintf("insert into CART set NUMBER=%d,TYPE=2,\
GROUP_NAME=\"TEMP\",TITLE=\"Walk SAS Output %d\",\
ARTIST=\"SAS_TORTURE\",MACROS=\"%s\"",
i+CART_START,i+1,(const char *)rml);
q=new RDSqlQuery(sql);
delete q;
}
//
// Create Schedule
//
QTime time;
for(int i=0;i<86400000;i+=TIME_INTERVAL) {
for(int j=0;j<SAS_OUTPUTS;j++) {
desc=QString().sprintf("Walk SAS Output %d",j+1);
sql=QString().sprintf("insert into RECORDINGS set STATION_NAME=\"%s\",\
SUN=\'Y\',MON=\'Y\',TUE=\'Y\',WED=\'Y\',THU=\'Y\',\
FRI=\'Y\',SAT=\'Y\',DESCRIPTION=\"%s\",\
CUT_NAME=\"SAS_TORTURE\",MACRO_CART=%d,\
START_TIME=\"%s\",TYPE=1",
SAS_STATION,
(const char *)desc,
CART_START+j,
(const char *)time.toString("hh:mm:ss"));
q=new RDSqlQuery(sql);
delete q;
}
time=time.addMSecs(TIME_INTERVAL);
}
}
void MainWidget::removeData()
{
QString sql;
RDSqlQuery *q;
//
// Delete Carts
//
sql=QString("delete from CART where ARTIST=\"SAS_TORTURE\"");
q=new RDSqlQuery(sql);
delete q;
//
// Delete Schedule
//
sql=QString("delete from RECORDINGS where CUT_NAME=\"SAS_TORTURE\"");
q=new RDSqlQuery(sql);
delete q;
}
void MainWidget::cancelData()
{
qApp->quit();
}
void MainWidget::closeEvent(QCloseEvent *e)
{
cancelData();
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv);
MainWidget *w=new MainWidget(NULL,"main");
a.setMainWidget(w);
w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
w->show();
return a.exec();
}

64
tests/sas_torture.h Normal file
View File

@@ -0,0 +1,64 @@
// sas_torture.h
//
// Generate Rivendell macro carts and scheduling for torture-testing
// an SAS router
//
// (C) Copyright 2002-2004 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: sas_torture.h,v 1.8 2010/07/29 19:32:39 cvs Exp $
//
// 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 SAS_TORTURE_H
#define SAS_TORTURE_H
#include <qwidget.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#define SAS_INPUTS 32
#define SAS_OUTPUTS 16
#define SAS_STATION "hithlum"
#define SAS_MATRIX 1
#define SAS_SLEEP 20
#define CART_START 10000
#define TIME_INTERVAL 20000
class MainWidget : public QWidget
{
Q_OBJECT
public:
MainWidget(QWidget *parent=0,const char *name=0);
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
private slots:
void generateData();
void removeData();
void cancelData();
void closeEvent(QCloseEvent *e);
private:
void LoadConfig();
QSqlDatabase *test_db;
QString test_filename;
RDConfig *rd_config;
};
#endif // SAS_TORTURE_H

113
tests/stringcode_test.cpp Normal file
View File

@@ -0,0 +1,113 @@
// stringcode_test.cpp
//
// Test the Rivendell string encoder routines.
//
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: stringcode_test.cpp,v 1.1.2.1 2013/10/16 21:14:38 cvs Exp $
//
// 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 <stdlib.h>
#include <stdio.h>
#include <qapplication.h>
#include <qvariant.h>
#include <rdcmd_switch.h>
#include <rdweb.h>
#include "stringcode_test.h"
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
char teststr[1024];
QString str;
bool xml_encode=false;
bool xml_decode=false;
bool url_encode=false;
bool url_decode=false;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"stringcode_test",
STRINGCODE_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--xml-encode") {
xml_encode=true;
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--xml-decode") {
xml_decode=true;
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--url-encode") {
url_encode=true;
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--url-decode") {
url_decode=true;
cmd->setProcessed(i,true);
}
if(!cmd->processed(i)) {
fprintf(stderr,"stringcode_test: unknown option \"%s\"\n",
(const char *)cmd->key(i));
exit(256);
}
}
if((!xml_encode)&&(!xml_decode)&&(!url_encode)&&(!url_decode)) {
fprintf(stderr,"stringcode_test: nothing to do!\n");
exit(256);
}
//
// Get string to test
//
printf("Enter string: ");
fflush(stdout);
if(fgets(teststr,1024,stdin)==NULL) {
teststr[0]=0;
}
str=QString(teststr).replace("\n","");
printf("Testing String: |%s|\n",(const char *)str);
if(xml_encode) {
printf(" RDXmlEscape: |%s|\n",(const char *)RDXmlEscape(str));
}
if(xml_decode) {
printf(" RDXmlUnescape: |%s|\n",(const char *)RDXmlUnescape(str));
}
if(url_encode) {
printf(" RDUrlEscape: |%s|\n",(const char *)RDUrlEscape(str));
}
if(url_decode) {
printf(" RDUrlUnescape: |%s|\n",(const char *)RDUrlUnescape(str));
}
printf("\n");
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

37
tests/stringcode_test.h Normal file
View File

@@ -0,0 +1,37 @@
// stringcode_test.h
//
// Test the Rivendell string encoder routines.
//
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: stringcode_test.h,v 1.1.2.1 2013/10/16 21:14:38 cvs Exp $
//
// 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 STRINGCODE_TEST_H
#define STRINGCODE_TEST_H
#include <qobject.h>
#define STRINGCODE_TEST_USAGE "[options]\n\nTest the Rivendell string encoding routines in RDWeb\n\nOptions are:\n--xml-encode\n Encode using RDXmlEscape()\n\n--xml-decode\n Decode using RDXmlUnescape()\n\n--encode-url\n Encode using RDUrlEscape()\n\n--url-decode\n Decode using RDUrlUnescape()\n\n"
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
};
#endif // STRINGCODE_TEST_H

120
tests/test_pam.cpp Normal file
View File

@@ -0,0 +1,120 @@
// test_pam.cpp
//
// Test PAM Authentication Service
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: test_pam.cpp,v 1.2 2010/07/29 19:32:39 cvs Exp $
//
// 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 <unistd.h>
#include <security/pam_appl.h>
#include <qapplication.h>
#include <rdcmd_switch.h>
#include <test_pam.h>
//
// NOTE: Since this is just a test harness, we make no attempt to
// free() the response data structures after using them!
//
int ConversationResponseCallback(int num_msg,const struct pam_message **msg,
struct pam_response **resp,
void *appdata_ptr)
{
int i;
char *pw;
*resp=new struct pam_response[num_msg];
for(i=0;i<num_msg;i++) {
resp[i]->resp=new char[256];
switch(msg[i]->msg_style) {
case PAM_PROMPT_ECHO_OFF:
pw=getpass(msg[i]->msg);
strncpy(resp[i]->resp,pw,256);
resp[i]->resp_retcode=0;
break;
case PAM_PROMPT_ECHO_ON:
printf("%s ",msg[i]->msg);
fflush(NULL);
fgets(resp[i]->resp,256,stdin);
resp[i]->resp[strlen(resp[i]->resp)-1]=0;
resp[i]->resp_retcode=0;
break;
case PAM_ERROR_MSG:
case PAM_TEXT_INFO:
printf("%s\n",msg[i]->msg);
break;
}
}
return 0;
}
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
int err;
struct pam_conv conv;
pam_handle_t *pamh=NULL;
QString service_name="";
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"test_pam",TEST_PAM_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--service-name") {
service_name=cmd->value(i);
cmd->setProcessed(i,true);
}
}
if(service_name.isEmpty()) {
fprintf(stderr,"test_pam: missing service-name\n");
exit(256);
}
memset(&conv,0,sizeof(conv));
conv.conv=ConversationResponseCallback;
if((err=pam_start(service_name,NULL,&conv,&pamh))!=PAM_SUCCESS) {
perror(pam_strerror(pamh,err));
exit(256);
}
err=pam_authenticate(pamh,0);
if(err==PAM_SUCCESS) {
printf("Success!\n");
}
else {
perror(pam_strerror(pamh,err));
}
pam_end(pamh,err);
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

44
tests/test_pam.h Normal file
View File

@@ -0,0 +1,44 @@
// test_pam.h
//
// Test PAM Authentication Service
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id:
//
// 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 TEST_PAM_H
#define TEST_PAM_H
#include <list>
#include <qobject.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdsettings.h>
#include <rdcmd_switch.cpp>
#define TEST_PAM_USAGE "[options]\n\nTest a PAM-based authentication service\n\n--service-name=<svc-name>\n The name of the PAM service to test (as defined in /etc/pam.d/).\n\n"
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
};
#endif // TEST_PAM_H

85
tests/timer_test.cpp Normal file
View File

@@ -0,0 +1,85 @@
// timer_test.cpp
//
// Test QTimer Accuracy
//
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: timer_test.cpp,v 1.1.2.1 2013/02/07 18:22:06 cvs Exp $
//
// 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 <errno.h>
#include <qapplication.h>
#include <timer_test.h>
MainObject::MainObject(QObject *parent,const char *name)
: QObject(parent,name)
{
//
// Timer
//
test_timer=new QTimer(this);
connect(test_timer,SIGNAL(timeout()),this,SLOT(timeoutData()));
//
// Start Run
//
test_interval=60000;
if(gettimeofday(&test_start_tv,NULL) !=0) {
perror("gettimeofday");
}
test_timer->start(test_interval,true);
}
void MainObject::timeoutData()
{
//
// Calculate Result
//
if(gettimeofday(&test_end_tv,NULL) !=0) {
perror("gettimeofday");
}
double expected=(double)test_interval/1000.0;
double got=Time(&test_end_tv)-Time(&test_start_tv);
printf("Expected: %12.3lf Got: %12.3lf Diff: %8.3lf%%\n",
expected,got,100.0*got/expected);
//
// Start Next Run
//
test_interval*=2;
if(gettimeofday(&test_start_tv,NULL) !=0) {
perror("gettimeofday");
}
test_timer->start(test_interval,true);
}
double MainObject::Time(struct timeval *tv)
{
return (double)tv->tv_sec+(double)tv->tv_usec/1000000.0;
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

49
tests/timer_test.h Normal file
View File

@@ -0,0 +1,49 @@
// timer_test.h
//
// Test QTimer Accuracy
//
// (C) Copyright 2013 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: timer_test.h,v 1.1.2.1 2013/02/07 18:22:06 cvs Exp $
//
// 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 TIMER_TEST_H
#define TIMER_TEST_H
#include <sys/time.h>
#include <qobject.h>
#include <qtimer.h>
class MainObject : public QObject
{
Q_OBJECT;
public:
MainObject(QObject *parent=0,const char *name=0);
private slots:
void timeoutData();
private:
double Time(struct timeval *tv);
QTimer *test_timer;
struct timeval test_start_tv;
struct timeval test_end_tv;
int test_interval;
};
#endif // TIMER_TEST_H

106
tests/upload_test.cpp Normal file
View File

@@ -0,0 +1,106 @@
// upload_test.cpp
//
// Test Rivendell file uploading.
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: upload_test.cpp,v 1.3 2011/06/21 22:20:44 cvs Exp $
//
// 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 <qapplication.h>
#include <rddb.h>
#include <rdcmd_switch.h>
#include <rdupload.h>
#include <upload_test.h>
MainObject::MainObject(QObject *parent,const char *name)
:QObject(parent,name)
{
username="";
password="";
RDUpload::ErrorCode conv_err;
unsigned schema=0;
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"upload_test",
UPLOAD_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--username") {
username=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--password") {
password=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--source-file") {
source_filename=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--destination-url") {
destination_url=cmd->value(i);
cmd->setProcessed(i,true);
}
}
if(source_filename.isEmpty()) {
fprintf(stderr,"upload_test: missing source-file\n");
exit(256);
}
if(destination_url.isEmpty()) {
fprintf(stderr,"upload_test: missing destination-url\n");
exit(256);
}
//
// Read Configuration
//
rdconfig=new RDConfig();
rdconfig->load();
//
// Open Database
//
QString err (tr("upload_test: "));
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
fprintf(stderr,err.ascii());
delete cmd;
exit(256);
}
RDUpload *conv=new RDUpload(rdconfig->stationName(),this);
conv->setSourceFile(source_filename);
conv->setDestinationUrl(destination_url);
printf("Uploading...\n");
conv_err=conv->runUpload(username,password,rdconfig->logXloadDebugData());
printf("Result: %s\n",(const char *)RDUpload::errorText(conv_err));
delete conv;
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject(NULL,"main");
return a.exec();
}

55
tests/upload_test.h Normal file
View File

@@ -0,0 +1,55 @@
// upload_test.h
//
// Test Rivendell file uploading
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: upload_test.h,v 1.2 2010/07/29 19:32:39 cvs Exp $
//
// 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 UPLOAD_TEST_H
#define UPLOAD_TEST_H
#include <list>
#include <qobject.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdcmd_switch.cpp>
#define UPLOAD_TEST_USAGE "[options]\n\nTest the Rivendell upload routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--source-file=<filename>\n\n--destination-url=<url>\n\n"
//
// Global Variables
//
RDConfig *rdconfig;
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0,const char *name=0);
private:
QString username;
QString password;
QString source_filename;
QString destination_url;
};
#endif // UPLOAD_TEST_H

6
tests/visualtraffic.txt Normal file
View File

@@ -0,0 +1,6 @@
|00:05:00|018585 |Wildfire Homework |Ad Council |0030
|00:05:30|017417 |GEICO 9160 WIG |GLOBAL |0030
|00:14:00|017668 |Swiss America |SFR |0060
|00:15:00|018073 |GEICO 9644 CYCLE SAVER |GLOBAL |0030
|00:15:01|017911 |Live United Mary |Ad Council |0030
|00:15:02|018427 |GM 9385 BROKEN KNEES |GLOBAL |0060