diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 55994f3d89..2056044a4b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -5,6 +5,8 @@ set_target_properties(mtc PROPERTIES FOLDER "Tools") add_subdirectory(scribe) set_target_properties(scribe PROPERTIES FOLDER "Tools") +add_subdirectory(udt-test) +set_target_properties(udt-test PROPERTIES FOLDER "Tools") + add_subdirectory(vhacd-util) set_target_properties(vhacd-util PROPERTIES FOLDER "Tools") - diff --git a/tools/udt-test/CMakeLists.txt b/tools/udt-test/CMakeLists.txt new file mode 100644 index 0000000000..7f47677269 --- /dev/null +++ b/tools/udt-test/CMakeLists.txt @@ -0,0 +1,6 @@ +set(TARGET_NAME udt-test) +setup_hifi_project() + +link_hifi_libraries(networking) + +copy_dlls_beside_windows_executable() \ No newline at end of file diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp new file mode 100644 index 0000000000..d2f8bf6e40 --- /dev/null +++ b/tools/udt-test/src/UDTTest.cpp @@ -0,0 +1,46 @@ +// +// UDTTest.cpp +// tools/udt-test/src +// +// Created by Stephen Birarda on 2015-07-30. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "UDTTest.h" + +#include + +const QCommandLineOption PORT_OPTION { "p", "listening port for socket (defaults to random)", "port", 0 }; + +UDTTest::UDTTest(int& argc, char** argv) : + QCoreApplication(argc, argv) +{ + parseArguments(); + + _socket.bind(QHostAddress::LocalHost, _argumentParser.value(PORT_OPTION).toUInt()); + qDebug() << "Test socket is listening on" << _socket.localPort(); +} + +void UDTTest::parseArguments() { + // use a QCommandLineParser to setup command line arguments and give helpful output + _argumentParser.setApplicationDescription("High Fidelity Assignment Client"); + _argumentParser.addHelpOption(); + + const QCommandLineOption helpOption = _argumentParser.addHelpOption(); + + _argumentParser.addOption(PORT_OPTION); + + if (!_argumentParser.parse(QCoreApplication::arguments())) { + qCritical() << _argumentParser.errorText(); + _argumentParser.showHelp(); + Q_UNREACHABLE(); + } + + if (_argumentParser.isSet(helpOption)) { + _argumentParser.showHelp(); + Q_UNREACHABLE(); + } +} diff --git a/tools/udt-test/src/UDTTest.h b/tools/udt-test/src/UDTTest.h new file mode 100644 index 0000000000..86d15974d0 --- /dev/null +++ b/tools/udt-test/src/UDTTest.h @@ -0,0 +1,32 @@ +// +// UDTTest.h +// tools/udt-test/src +// +// Created by Stephen Birarda on 2015-07-30. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once + +#ifndef hifi_UDTTest_h +#define hifi_UDTTest_h + +#include +#include + +#include + +class UDTTest : public QCoreApplication { +public: + UDTTest(int& argc, char** argv); +private: + void parseArguments(); + + QCommandLineParser _argumentParser; + udt::Socket _socket; +}; + +#endif // hifi_UDTTest_h diff --git a/tools/udt-test/src/main.cpp b/tools/udt-test/src/main.cpp new file mode 100644 index 0000000000..ccb7d0af0f --- /dev/null +++ b/tools/udt-test/src/main.cpp @@ -0,0 +1,19 @@ +// +// main.cpp +// tools/udt-test/src +// +// Created by Stephen Birarda on 7/30/15. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + +#include + +#include "UDTTest.h" + +int main(int argc, char* argv[]) { + UDTTest app(argc, argv); + return app.exec(); +} +