mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-12-18 06:31:25 +01:00
2025-04-29 Fred Gleason <fredg@paravelsystems.com>
* Modified regex code in ' RDConfig::provisioningHostShortName()' and 'RDConfig::provisioningServiceName()' to use the QRegularExpression class rather than QRegExp. * Added a 'test_provisioning' test harness in 'tests/'. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -46,6 +46,7 @@ noinst_PROGRAMS = audio_convert_test\
|
||||
metadata_wildcard_test\
|
||||
meterstrip_test\
|
||||
notification_test\
|
||||
provisioning_test\
|
||||
rdwavefile_test\
|
||||
rdxml_parse_test\
|
||||
readcd_test\
|
||||
@@ -130,6 +131,10 @@ dist_notification_test_SOURCES = notification_test.cpp notification_test.h
|
||||
nodist_notification_test_SOURCES = moc_notification_test.cpp
|
||||
notification_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT6_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||
|
||||
dist_provisioning_test_SOURCES = provisioning_test.cpp provisioning_test.h
|
||||
nodist_provisioning_test_SOURCES = moc_provisioning_test.cpp
|
||||
provisioning_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT6_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||
|
||||
dist_rdwavefile_test_SOURCES = rdwavefile_test.cpp rdwavefile_test.h
|
||||
nodist_rdwavefile_test_SOURCES = moc_rdwavefile_test.cpp
|
||||
rdwavefile_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT6_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@
|
||||
|
||||
92
tests/provisioning_test.cpp
Normal file
92
tests/provisioning_test.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
// provisioning_test.cpp
|
||||
//
|
||||
// Test Rivendell provisioning methods in RDConfig.
|
||||
//
|
||||
// (C) Copyright 2025 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 <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <rd.h>
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdconfig.h>
|
||||
|
||||
#include "provisioning_test.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
QString config_filename=RD_CONF_FILE;
|
||||
QString test_host_name;
|
||||
|
||||
//
|
||||
// Read Command Line
|
||||
//
|
||||
RDCmdSwitch *cmd=new RDCmdSwitch("provisioning_test",PROVISIONING_TEST_USAGE);
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)=="--config-file") {
|
||||
config_filename=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--test-host-name") {
|
||||
test_host_name=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(!cmd->processed(i)) {
|
||||
fprintf(stderr,"provisioning_test: unknown option\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if(test_host_name.isEmpty()) {
|
||||
char name[HOST_NAME_MAX];
|
||||
if(gethostname(name,HOST_NAME_MAX)<0) {
|
||||
fprintf(stderr,"provisioning_test: %s\n",strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
test_host_name=QString::fromUtf8(name);
|
||||
}
|
||||
|
||||
//
|
||||
// Run Test
|
||||
//
|
||||
RDConfig *config=new RDConfig(config_filename);
|
||||
if(!config->load()) {
|
||||
fprintf(stderr,"provisioning_test: failed to load config file\n");
|
||||
exit(1);
|
||||
}
|
||||
printf(" Config File: %s\n",config_filename.toUtf8().constData());
|
||||
printf("Test Hostname: %s\n",test_host_name.toUtf8().constData());
|
||||
printf("\n");
|
||||
printf("provisiongHostShortName: %s\n",
|
||||
config->provisioningHostShortName(test_host_name).toUtf8().constData());
|
||||
printf("provisioningServiceName: %s\n",
|
||||
config->provisioningServiceName(test_host_name).toUtf8().constData());
|
||||
printf("provisioningHostIpAddress: %s\n",
|
||||
config->provisioningHostIpAddress().toString().toUtf8().constData());
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc,argv,false);
|
||||
new MainObject();
|
||||
return a.exec();
|
||||
}
|
||||
36
tests/provisioning_test.h
Normal file
36
tests/provisioning_test.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// provisioning_test.h
|
||||
//
|
||||
// Test Rivendell provisioning methods in RDConfig.
|
||||
//
|
||||
// (C) Copyright 2025 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 PROVISIONING_TEST_H
|
||||
#define PROVISIONING_TEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#define PROVISIONING_TEST_USAGE "--config-file=<filename> --test-host-name=<hostname>"
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainObject(QObject *parent=0);
|
||||
};
|
||||
|
||||
|
||||
#endif // PROVISIONING_TEST_H
|
||||
Reference in New Issue
Block a user