[tor-commits] [vidalia/alpha] test code for torrc classes

chiiph at torproject.org chiiph at torproject.org
Tue Sep 25 23:08:49 UTC 2012


commit 94cf0b247d4e4bb95cf3bd6398ae94060ac35844
Author: Sebastian Baginski <sebthestampede at gmail.com>
Date:   Sat Sep 15 13:26:49 2012 +0200

    test code for torrc classes
---
 CMakeLists.txt           |    3 +
 changes/bug6128          |    2 +
 src/CMakeLists.txt       |    4 +-
 src/tests/CMakeLists.txt |  332 ++++++++++++++++++++++++++
 src/tests/TorrcTest.cpp  |  589 ++++++++++++++++++++++++++++++++++++++++++++++
 src/tests/Torrctest.h    |   44 ++++
 src/tests/testMain.cpp   |   43 ++++
 7 files changed, 1016 insertions(+), 1 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 021de50..08a70bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,6 +115,9 @@ if (USE_GEOIP)
   include(${CMAKE_SOURCE_DIR}/cmake/FindGeoIP.cmake)
 endif(USE_GEOIP)
 
+## Optional include test sources
+option(BUILD_TESTS "Build test sources" OFF)
+
 ## Check for system header files
 check_include_file("limits.h" HAVE_LIMITS_H)
 check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
diff --git a/changes/bug6128 b/changes/bug6128
new file mode 100644
index 0000000..f261f06
--- /dev/null
+++ b/changes/bug6128
@@ -0,0 +1,2 @@
+  Internal cleanups and improvements:
+  o Create test code for Vidalia torrc classes. Fixes ticket 6128.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4a25aac..fefa2c6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,4 +65,6 @@ add_subdirectory(common)
 add_subdirectory(tools)
 add_subdirectory(torcontrol)
 add_subdirectory(vidalia)
-
+if (BUILD_TESTS)
+  add_subdirectory(tests)
+endif (BUILD_TESTS)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
new file mode 100644
index 0000000..1d0bf34
--- /dev/null
+++ b/src/tests/CMakeLists.txt
@@ -0,0 +1,332 @@
+##
+##  $Id$
+## 
+##  This file is part of Vidalia, and is subject to the license terms in the
+##  LICENSE file, found in the top level directory of this distribution. If 
+##  you did not receive the LICENSE file with this file, you may obtain it
+##  from the Vidalia source package distributed by the Vidalia Project at
+##  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
+##  including this file, may be copied, modified, propagated, or distributed 
+##  except according to the terms described in the LICENSE file.
+##
+
+add_definitions( -DBUILD_TESTS )
+
+include_directories(
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions
+)
+
+## About dialog sources
+set(vidalia_SRCS 
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.h
+)
+
+## Plugin framework sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginEngine.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginWrapper.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/HelperProcessPrototype.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/TorrcPrototype.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/VidaliaExtensions.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/VidaliaExtensionsInit.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_BootstrapStatus.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_Circuit.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlCommand.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlConnection.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlMethod.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlReply.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlSocket.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ReplyLine.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_RouterDescriptor.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_RouterStatus.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_SendCommandEvent.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_Stream.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorControl.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorEvents.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorProcess.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorSignal.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_VidaliaTab.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlConnection.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlMethod.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlSocket.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorControl.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorEvents.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorProcess.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorSignal.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_VidaliaTab.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginEngine.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginWrapper.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/HelperProcessPrototype.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/TorrcPrototype.h
+)
+
+## Configuration dialog sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AbstractTorSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPageStack.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/DomainValidator.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ExitPolicy.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/IpValidator.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Local8BitStringValidator.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NicknameValidator.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Policy.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/PortValidator.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VidaliaSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VSettings.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/TorrcParser.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/Torrc.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AbstractTorSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPageStack.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/DomainValidator.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Local8BitStringValidator.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NicknameValidator.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/PortValidator.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VidaliaSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VSettings.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/Torrc.h
+)
+if (USE_MINIUPNPC)
+  include_directories(${MINIUPNPC_INCLUDE_DIR})
+  set(vidalia_SRCS ${vidalia_SRCS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControl.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControlThread.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.cpp
+  )
+  qt4_wrap_cpp(vidalia_SRCS
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControl.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControlThread.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.h
+  )
+endif(USE_MINIUPNPC)
+
+## Main Vidalia sources (without main.cpp)
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/Vidalia.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/LanguageSupport.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VTabWidget.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VAttachButton.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaWindow.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VMessageBox.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaTab.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/HelperProcess.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/FirstRunWizard.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/Vidalia.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VTabWidget.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VAttachButton.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaWindow.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VMessageBox.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaTab.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/HelperProcess.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/FirstRunWizard.h
+)
+
+if (USE_MINIUPNPC)
+  qt4_wrap_ui(vidalia_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.ui)
+endif(USE_MINIUPNPC)
+
+## Specify all the Qt Designer .ui files
+qt4_wrap_ui(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.ui
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.ui
+)
+
+## Add the resource files (icons, etc.)
+qt4_add_resources(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/res/vidalia.qrc
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/content/content.qrc
+  ${CMAKE_CURRENT_BINARY_DIR}/../vidalia/i18n/vidalia_i18n.qrc
+)
+
+## Network map sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitItem.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitListWidget.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CountryInfo.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpRecord.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpResolver.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterDescriptorView.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListItem.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListWidget.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/StreamItem.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitListWidget.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CountryInfo.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpResolver.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterDescriptorView.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListWidget.h
+)
+if (USE_MARBLE)
+  set(vidalia_SRCS ${vidalia_SRCS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidget.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidgetPopupMenu.cpp
+  )
+  qt4_wrap_cpp(vidalia_SRCS
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidget.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidgetPopupMenu.h
+  )
+else(USE_MARBLE)
+  set(vidalia_SRCS ${vidalia_SRCS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapImageView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/ZImageView.cpp
+  )
+  qt4_wrap_cpp(vidalia_SRCS
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapImageView.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/ZImageView.h
+  )
+endif(USE_MARBLE)
+if (USE_GEOIP)
+  set(vidalia_SRCS ${vidalia_SRCS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpDatabase.cpp
+  )
+  qt4_wrap_cpp(vidalia_SRCS
+    ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpDatabase.h
+  )
+endif(USE_GEOIP)
+
+## Help browser sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpTextBrowser.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpTextBrowser.h
+)
+
+## Message log sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFile.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogHeaderView.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogMessageColumnDelegate.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeItem.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeWidget.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItem.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItemDelegate.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventWidget.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFilter.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFile.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogHeaderView.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeWidget.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItemDelegate.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventWidget.h
+)
+
+
+## Bootstrap test sources
+set(vidalia_SRCS ${vidalia_SRCS}
+  testMain.cpp
+  TorrcTest.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+  TorrcTest.h
+)
+
+set(test_BIN VidaliaTestSuite)
+
+add_executable(${test_BIN} ${vidalia_SRCS})
+target_link_libraries(${test_BIN}
+  ${QT_LIBRARIES}
+  ${QT_QTTEST_LIBRARY}
+  common
+  torcontrol
+)
+if (USE_MINIUPNPC)
+  target_link_libraries(${test_BIN} miniupnpc)
+endif(USE_MINIUPNPC)
+if (USE_BREAKPAD)
+  target_link_libraries(${test_BIN} ${BREAKPAD_LIBRARY})
+endif(USE_BREAKPAD)
+if (USE_MARBLE)
+  target_link_libraries(${test_BIN}
+    ${MARBLE_LIBRARIES}
+    ${QT_QTSVG_LIBRARY}
+  )
+endif(USE_MARBLE)
+if (USE_GEOIP)
+  target_link_libraries(${test_BIN} ${GEOIP_LIBRARIES})
+endif(USE_GEOIP)
+
+if (APPLE)
+  target_link_libraries(${test_BIN}
+    "-framework AppKit"
+    iconv
+  )
+endif(APPLE)
diff --git a/src/tests/TorrcTest.cpp b/src/tests/TorrcTest.cpp
new file mode 100644
index 0000000..1e2a026
--- /dev/null
+++ b/src/tests/TorrcTest.cpp
@@ -0,0 +1,589 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+**  including this file, may be copied, modified, propagated, or distributed
+**  except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TorrcTest.cpp
+** \brief  test of torrc handling
+*/
+
+#include "TorrcTest.h"
+#include "TorrcParser.h"
+#include "Torrc.h"
+#include "Vidalia.h"
+#include "MainWindow.h"
+#include <QTimer>
+#include <QEventLoop>
+
+/** Constructor. */
+TorrcTestSuite::TorrcTestSuite(QObject *parent)
+  :QObject(parent)
+{
+  
+}
+
+/** Destructor. */
+TorrcTestSuite::~TorrcTestSuite()
+{
+
+}
+
+/** Test TorrcLine class */
+void TorrcTestSuite::testTorrcLine()
+{
+  const int count = 100;
+
+  // test single lined values
+  for (int i=0 ; i<count ; ++i) {
+    const QString content = QString("test_content_%1").arg(i);
+    const QString comment = QString("test_comment_%1").arg(i);
+    TorrcLine tLine(content,comment);
+    QCOMPARE(content, tLine.content());
+    QCOMPARE(comment, tLine.comment());
+    QVERIFY(tLine.isMultilined() == false);
+    tLine.setComment(content);
+    tLine.setContent(comment);
+    QCOMPARE(comment, tLine.content());
+    QCOMPARE(content, tLine.comment());
+    QVERIFY(tLine.isMultilined() == false);
+  }
+
+  // test multilined TorrcLine
+  for (int i=0 ; i<count ; ++i) {
+    const QString content = QString("test\\multiline\\content\\%1\\").arg(i);
+    const QString comment = QString("test\\multiline\\comment\\%1\\").arg(i);
+    TorrcLine tLine(content,comment);
+    QCOMPARE(content, tLine.content());
+    QCOMPARE(comment, tLine.comment());
+    QVERIFY(tLine.isMultilined() == true);
+    tLine.setComment(content);
+    tLine.setContent(comment);
+    QCOMPARE(comment, tLine.content());
+    QCOMPARE(content, tLine.comment());
+    QVERIFY(tLine.isMultilined() == true);
+  }
+}
+
+/** Test parser class */
+void TorrcTestSuite::testTorrcParser()
+{
+  const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+  QFile file(testFilePath);
+  if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+    QVERIFY(false && "Cannot open test torrc file!");
+  const int optCount = 100;
+  QList< QPair<QString,QString> > testData;
+  // create test file
+  QString content;
+  for (int i=0 ; i<optCount ; ++i) {
+    const QString optName = QString("option_%1 value_%1").arg(i);
+    const QString optComt = QString("#comment_%1").arg(i);
+    content += optName + optComt;
+    testData.append( QPair<QString,QString>(optName,optComt) );
+    if (i<optCount-1)
+        content += "\n";
+  }
+  file.write(content.toAscii());
+  file.close();
+
+  TorrcParser parser;
+  QMap<QString, QPair<QString, TorOpt> > map;
+  QList<TorrcLine*> lines = parser.parse(testFilePath,map);
+  QVERIFY(lines.isEmpty() == false);
+  QCOMPARE(lines.count(), optCount);
+
+  for (int i=0 ; i<optCount ; ++i) {
+    TorrcLine * line = lines.at(i);
+    QVERIFY(line != NULL);
+    QCOMPARE(line->content(), testData[i].first);
+    QCOMPARE(line->comment(), testData[i].second);
+  }
+
+  // verify loaded values (all should be null)
+  QCOMPARE(map.count(), optCount);
+  foreach (QString key, map.keys()) {
+    QString value = map[key].first;
+    TorOpt opt = map[key].second;
+    QVERIFY(value.startsWith("value_"));
+    QVERIFY(opt.isNull());
+  }
+
+  qDeleteAll(lines);
+  QVERIFY( QFile::remove(testFilePath) );
+}
+
+QList<TorOpt> createTestOpts();
+QString createTestValue(TorOpt::OptType);
+QString defaultValue(const QString &);
+
+/** Test main Torrc class */
+void TorrcTestSuite::testTorrc()
+{
+  const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+  QFile file(testFilePath);
+  if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+    QVERIFY(false && "Cannot open test torrc file!");
+  QList<TorOpt> opts = createTestOpts();
+  QList< QPair<QString,QString> > testData;
+  foreach (const TorOpt &opt, opts) {
+    testData.append( QPair<QString,QString>(opt.name(),createTestValue(opt.type())) );
+  }
+  // create test file with real option names and values
+  QString content;
+  for (int i=0 ; i<testData.count() ; ++i) {
+    const QString optName = testData[i].first + " " + testData[i].second;
+    const QString optComt = QString("#comment_%1").arg(i);
+    content += optName + optComt;
+    if (i<testData.count()-1)
+      content += "\n";
+  }
+  file.write(content.toAscii());
+  file.close();
+
+  TorrcParser parser;
+  QMap<QString, QPair<QString, TorOpt> > map;
+  QList<TorrcLine*> lines = parser.parse(testFilePath,map);
+  QVERIFY(lines.isEmpty() == false);
+  QCOMPARE(lines.count(), testData.count());
+
+  for (int i=0 ; i<testData.count() ; ++i) {
+    TorrcLine * line = lines.at(i);
+    QVERIFY(line != NULL);
+    QCOMPARE(line->content(), QString(testData[i].first + " " + testData[i].second).trimmed());
+    QCOMPARE(line->comment(), QString("#comment_%1").arg(i));
+  }
+
+  // verify loaded values
+  foreach (QString key, map.keys()) {
+    QString value = map[key].first;
+    TorOpt opt = map[key].second;
+    QCOMPARE(value, createTestValue(opt.type()));
+    QVERIFY(opt.isNull() == false);
+    QVERIFY(testData.contains( QPair<QString,QString>(key,value) ));
+  }
+
+  qDeleteAll(lines);
+
+  // test torrc object
+  Torrc torrc(testFilePath);
+  QCOMPARE(torrc.getTorrcPath(), testFilePath);
+  for (int i=0 ; i<testData.count() ; ++i) {
+    // test the data in torrc file
+    QVERIFY(torrc.isValid(testData[i].first, testData[i].second));
+    QStringList values = torrc.value(testData[i].first);
+    if (testData[i].second.isEmpty()==false) {
+      QVERIFY(values.contains(testData[i].second));
+    }
+    // test if clearing a value works ok
+    torrc.clear(QStringList() << testData[i].first);
+    values = torrc.value(testData[i].first);
+    if (testData[i].second.isEmpty()==false) {
+      QVERIFY(values.contains(testData[i].second) == false);
+    }
+  }
+  QVERIFY(torrc.apply(Vidalia::torControl()));
+  // after applying changes, we test the file content
+  QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+  content = file.readAll();
+  file.close();
+  for (int i=0 ; i<testData.count() ; ++i) {
+    QVERIFY(content.contains(testData[i].first) == false);
+  }
+  // test adding values to empty file
+  QVERIFY(QFile::remove(testFilePath));
+  QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
+  file.write("");
+  file.close();
+  torrc.load(testFilePath);
+  int lastKeyPos = -1; // value for checking if <key, value> pairs are present in the file
+  for (int i=0 ; i<testData.count() ; ++i) {
+    torrc.setValue(testData[i].first,testData[i].second);
+    QVERIFY(torrc.apply(Vidalia::torControl()));
+    QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+    content = file.readAll();
+    file.close();
+    // if value is default for given key, file should not contain the entry
+    if (testData[i].second == defaultValue(testData[i].first)) {
+      QVERIFY(content.contains(testData[i].first)==false);
+    } else {
+      // check if key is in the file, and the value follows
+      QVERIFY(content.contains(testData[i].first));
+      lastKeyPos = content.indexOf(testData[i].first,lastKeyPos+1);
+      int nlPos = content.indexOf("\n",lastKeyPos);
+      if (nlPos == -1)
+        nlPos = content.length();
+      const int valPos = content.indexOf(testData[i].second,lastKeyPos);
+      QVERIFY(valPos != -1);
+      QVERIFY(valPos < nlPos);
+    }
+  }
+  QVERIFY(QFile::remove(testFilePath));
+}
+
+inline bool
+compareValues(const QVariant& var, const QString& value){
+  bool ok = false;
+  const double r = value.toDouble(&ok);
+  if (ok)
+    return qFuzzyCompare(var.toDouble(),r);
+  else
+    return var.toString() == value;
+}
+
+void TorrcTestSuite::testRunningTor()
+{
+  MainWindow * mw = new MainWindow;
+  mw->show();
+  TorControl * torControl = Vidalia::torControl();
+  QVERIFY(torControl);
+
+  // start tor, make sure we wont wait forever
+  QEventLoop loop;
+  QTimer timeoutCheck;
+  timeoutCheck.setSingleShot(true);
+  timeoutCheck.setInterval(120*1000);
+  connect(&timeoutCheck, SIGNAL(timeout()), &loop, SLOT(quit()));
+  connect(torControl, SIGNAL(started()), &loop, SLOT(quit()));
+  QTimer::singleShot(0,mw,SLOT(start()));
+  timeoutCheck.start();
+  loop.exec();
+  qApp->processEvents();
+
+  if (timeoutCheck.isActive()) {
+    vWarn("Tor process started.");
+    QVERIFY(torControl->isConnected());
+    QVERIFY(torControl->isRunning());
+
+    // create test torrc file
+    const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+    QFile file(testFilePath);
+    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+      QVERIFY(false && "Cannot open test torrc file!");
+
+    QHash<QString,QString> testData;
+    testData["AccountingMax"] = "0";
+    testData["AllowDotExit"] =  "0";
+    testData["AllowInvalidNodes"] =  "middle,rendezvous";
+    testData["AllowNonRFC953Hostnames"] = "0";
+    testData["AllowSingleHopCircuits"] = "0";
+    testData["BridgeRecordUsageByCountry"] = "0";
+    testData["CircuitIdleTimeout"] = "3600";
+    testData["CircuitPriorityHalflife"] = "-100.0";
+    testData["ControlPort"] = "9051";
+    testData["CookieAuthentication"] = "0";
+    testData["DataDirectory"] = "C:\\DifferentDataDirectory";
+    testData["PortForwarding"] = "0";
+    testData["ProtocolWarnings"] = "0";
+    testData["User"] = "userid";
+    // data directory should remain unchanged
+    const QString dataDir = torControl->getConf("DataDirectory").toString();
+
+    QString content;
+    foreach (QString key, testData) {
+      content += key + " " + testData[key] + "#comment\n";
+    }
+    file.write(content.toAscii());
+    file.close();
+    Torrc torrc(testFilePath);
+    QVERIFY( torrc.apply(torControl) );
+
+    // check values in running tor instance
+    foreach (QString key, testData) {
+      const QVariant val = torControl->getConf(key);
+      if (key == "DataDirectory"){
+        QCOMPARE(dataDir,val.toString());
+      } else
+        QVERIFY(compareValues(val,testData[key]));
+    }
+    // create new test data, different from current tor values
+    testData.remove("DataDirectory");
+    testData["AccountingMax"] = "1";
+    testData["AllowDotExit"] =  "1";
+    testData["AllowInvalidNodes"] =  "middle";
+    testData["AllowNonRFC953Hostnames"] = "1";
+    testData["AllowSingleHopCircuits"] = "1";
+    testData["BridgeRecordUsageByCountry"] = "1";
+    testData["CircuitIdleTimeout"] = "900";
+    testData["CircuitPriorityHalflife"] = "-150.0";
+    testData["ControlPort"] = "8974";
+    testData["CookieAuthentication"] = "1";
+    testData["PortForwarding"] = "1";
+    testData["ProtocolWarnings"] = "1";
+    testData["User"] = "u2id";
+
+    // check if values are applied ok
+    QVERIFY( torrc.apply(torControl) );
+    foreach (QString key, testData) {
+      const QVariant val = torControl->getConf(key);
+      QVERIFY(compareValues(val,testData[key]));
+    }
+    QVERIFY(QFile::remove(testFilePath));
+  } else {
+    QVERIFY(false && "Cannot start the tor process!");
+  }
+  mw->deleteLater();
+}
+
+QList<TorOpt>
+createTestOpts()
+{
+  QList<TorOpt> opt;
+  opt << TorOpt("AccountingMax", TorOpt::DataSize, "0");
+  opt << TorOpt("AccountingStart", TorOpt::String, "");
+  opt << TorOpt("Address", TorOpt::String, "");
+  opt << TorOpt("AllowDotExit", TorOpt::Boolean, "0");
+  opt << TorOpt("AllowInvalidNodes", TorOpt::CommaList, "middle,rendezvous");
+  opt << TorOpt("AllowNonRFC953Hostnames", TorOpt::Boolean, "0");
+  opt << TorOpt("AllowSingleHopCircuits", TorOpt::Boolean, "0");
+  opt << TorOpt("AllowSingleHopExits", TorOpt::Boolean, "0");
+  opt << TorOpt("AlternateBridgeAuthority", TorOpt::LineList, "");
+  opt << TorOpt("AlternateDirAuthority", TorOpt::LineList, "");
+  opt << TorOpt("AlternateHSAuthority", TorOpt::LineList, "");
+  opt << TorOpt("AssumeReachable", TorOpt::Boolean, "0");
+  opt << TorOpt("AuthDirBadDir", TorOpt::LineList, "");
+  opt << TorOpt("AuthDirBadExit", TorOpt::LineList, "");
+  opt << TorOpt("AuthDirInvalid", TorOpt::LineList, "");
+  opt << TorOpt("AuthDirReject", TorOpt::LineList, "");
+  opt << TorOpt("AuthDirRejectUnlisted", TorOpt::Boolean, "0");
+  opt << TorOpt("AuthDirListBadDirs", TorOpt::Boolean, "0");
+  opt << TorOpt("AuthDirListBadExits", TorOpt::Boolean, "0");
+  opt << TorOpt("AuthDirMaxServersPerAddr", TorOpt::Integer, "2");
+  opt << TorOpt("AuthDirMaxServersPerAuthAddr", TorOpt::Integer, "5");
+  opt << TorOpt("AuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("AutomapHostsOnResolve", TorOpt::Boolean, "0");
+  opt << TorOpt("AutomapHostsSuffixes", TorOpt::CommaList, ".onion,.exit");
+  opt << TorOpt("AvoidDiskWrites", TorOpt::Boolean, "0");
+  opt << TorOpt("BandwidthBurst", TorOpt::DataSize, "10485760");
+  opt << TorOpt("BandwidthRate", TorOpt::DataSize, "5242880");
+  opt << TorOpt("BridgeAuthoritativeDir", TorOpt::Boolean, "0");
+  opt << TorOpt("Bridge", TorOpt::LineList, "");
+  opt << TorOpt("BridgePassword", TorOpt::String, "");
+  opt << TorOpt("BridgeRecordUsageByCountry", TorOpt::Boolean, "1");
+  opt << TorOpt("BridgeRelay", TorOpt::Boolean, "0");
+  opt << TorOpt("CellStatistics", TorOpt::Boolean, "0");
+  opt << TorOpt("LearnCircuitBuildTimeout", TorOpt::Boolean, "1");
+  opt << TorOpt("CircuitBuildTimeout", TorOpt::TimeInterval, "0");
+  opt << TorOpt("CircuitIdleTimeout", TorOpt::TimeInterval, "3600");
+  opt << TorOpt("CircuitStreamTimeout", TorOpt::TimeInterval, "0");
+  opt << TorOpt("CircuitPriorityHalflife", TorOpt::Float, "-100.0");
+  opt << TorOpt("ClientDNSRejectInternalAddresses", TorOpt::Boolean, "1");
+  opt << TorOpt("ClientOnly", TorOpt::Boolean, "0");
+  opt << TorOpt("ClientRejectInternalAddresses", TorOpt::Boolean, "1");
+  opt << TorOpt("ClientTransportPlugin", TorOpt::LineList, "");
+  opt << TorOpt("ConsensusParams", TorOpt::String, "");
+  opt << TorOpt("ConnLimit", TorOpt::Integer, "1000");
+  opt << TorOpt("ConnDirectionStatistics", TorOpt::Boolean, "0");
+  opt << TorOpt("ConstrainedSockets", TorOpt::Boolean, "0");
+  opt << TorOpt("ConstrainedSockSize", TorOpt::DataSize, "8192");
+  opt << TorOpt("ContactInfo", TorOpt::String, "");
+  opt << TorOpt("ControlListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("ControlPort", TorOpt::Port, "9051");
+  opt << TorOpt("ControlPortFileGroupReadable", TorOpt::Boolean, "0");
+  opt << TorOpt("ControlPortWriteToFile", TorOpt::Filename, "");
+  opt << TorOpt("ControlSocket", TorOpt::LineList, "");
+  opt << TorOpt("ControlSocketsGroupWritable", TorOpt::Boolean, "0");
+  opt << TorOpt("CookieAuthentication", TorOpt::Boolean, "0");
+  opt << TorOpt("CookieAuthFileGroupReadable", TorOpt::Boolean, "0");
+  opt << TorOpt("CookieAuthFile", TorOpt::String, "");
+  opt << TorOpt("CountPrivateBandwidth", TorOpt::Boolean, "0");
+  opt << TorOpt("DataDirectory", TorOpt::Filename, "");
+  opt << TorOpt("DirAllowPrivateAddresses", TorOpt::Boolean, "0");
+  opt << TorOpt("TestingAuthDirTimeToLearnReachability", TorOpt::TimeInterval, "1800");
+  opt << TorOpt("DirListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("DirPolicy", TorOpt::LineList, "");
+  opt << TorOpt("DirPort", TorOpt::Port, "0");
+  opt << TorOpt("DirPortFrontPage", TorOpt::Filename, "");
+  opt << TorOpt("DirServer", TorOpt::LineList, "");
+  opt << TorOpt("DisableAllSwap", TorOpt::Boolean, "0");
+  opt << TorOpt("DisableIOCP", TorOpt::Boolean, "1");
+  opt << TorOpt("DisableNetwork", TorOpt::Boolean, "0");
+  opt << TorOpt("DNSPort", TorOpt::LineList, "");
+  opt << TorOpt("DNSListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("DownloadExtraInfo", TorOpt::Boolean, "0");
+  opt << TorOpt("EnforceDistinctSubnets", TorOpt::Boolean, "1");
+  opt << TorOpt("EntryNodes", TorOpt::RouterList, "");
+  opt << TorOpt("EntryStatistics", TorOpt::Boolean, "0");
+  opt << TorOpt("TestingEstimatedDescriptorPropagationTime", TorOpt::TimeInterval, "600");
+  opt << TorOpt("ExcludeNodes", TorOpt::RouterList, "");
+  opt << TorOpt("ExcludeExitNodes", TorOpt::RouterList, "");
+  opt << TorOpt("ExcludeSingleHopRelays", TorOpt::Boolean, "1");
+  opt << TorOpt("ExitNodes", TorOpt::RouterList, "");
+  opt << TorOpt("ExitPolicy", TorOpt::LineList, "");
+  opt << TorOpt("ExitPolicyRejectPrivate", TorOpt::Boolean, "1");
+  opt << TorOpt("ExitPortStatistics", TorOpt::Boolean, "0");
+  opt << TorOpt("ExtraInfoStatistics", TorOpt::Boolean, "1");
+  opt << TorOpt("FallbackNetworkstatusFile", TorOpt::Filename, "/usr/local/share/tor/fallback-consensus");
+  opt << TorOpt("FascistFirewall", TorOpt::Boolean, "0");
+  opt << TorOpt("FirewallPorts", TorOpt::CommaList, "");
+  opt << TorOpt("FastFirstHopPK", TorOpt::Boolean, "1");
+  opt << TorOpt("FetchDirInfoEarly", TorOpt::Boolean, "0");
+  opt << TorOpt("FetchDirInfoExtraEarly", TorOpt::Boolean, "0");
+  opt << TorOpt("FetchServerDescriptors", TorOpt::Boolean, "1");
+  opt << TorOpt("FetchHidServDescriptors", TorOpt::Boolean, "1");
+  opt << TorOpt("FetchUselessDescriptors", TorOpt::Boolean, "0");
+  opt << TorOpt("FetchV2Networkstatus", TorOpt::Boolean, "0");
+  opt << TorOpt("GeoIPFile", TorOpt::Filename, "/usr/local/share/tor/geoip");
+  opt << TorOpt("GiveGuardFlagTo_CVE_2011_2768_VulnerableRelays", TorOpt::Boolean, "0");
+  opt << TorOpt("HardwareAccel", TorOpt::Boolean, "0");
+  opt << TorOpt("HeartbeatPeriod", TorOpt::TimeInterval, "21300");
+  opt << TorOpt("AccelName", TorOpt::String, "");
+  opt << TorOpt("AccelDir", TorOpt::Filename, "");
+  opt << TorOpt("HashedControlPassword", TorOpt::String, "");
+  opt << TorOpt("HidServDirectoryV2", TorOpt::Boolean, "1");
+  opt << TorOpt("HiddenServiceDir", TorOpt::Dependant, "");
+  opt << TorOpt("HiddenServiceOptions", TorOpt::Virtual, "");
+  opt << TorOpt("HiddenServicePort", TorOpt::Dependant, "");
+  opt << TorOpt("HiddenServiceVersion", TorOpt::Dependant, "");
+  opt << TorOpt("HiddenServiceAuthorizeClient", TorOpt::Dependant, "");
+  opt << TorOpt("HidServAuth", TorOpt::LineList, "");
+  opt << TorOpt("HSAuthoritativeDir", TorOpt::Boolean, "0");
+  opt << TorOpt("HTTPProxy", TorOpt::String, "");
+  opt << TorOpt("HTTPProxyAuthenticator", TorOpt::String, "");
+  opt << TorOpt("HTTPSProxy", TorOpt::String, "");
+  opt << TorOpt("HTTPSProxyAuthenticator", TorOpt::String, "");
+  opt << TorOpt("ServerTransportPlugin", TorOpt::LineList, "");
+  opt << TorOpt("Socks4Proxy", TorOpt::String, "");
+  opt << TorOpt("Socks5Proxy", TorOpt::String, "");
+  opt << TorOpt("Socks5ProxyUsername", TorOpt::String, "");
+  opt << TorOpt("Socks5ProxyPassword", TorOpt::String, "");
+  opt << TorOpt("KeepalivePeriod", TorOpt::TimeInterval, "300");
+  opt << TorOpt("Log", TorOpt::LineList, "");
+  opt << TorOpt("LogMessageDomains", TorOpt::Boolean, "0");
+  opt << TorOpt("LogTimeGranularity", TorOpt::TimeMsecInterval, "1000");
+  opt << TorOpt("LongLivedPorts", TorOpt::CommaList, "21,22,706,1863,5050,5190,5222,5223,6523,6667,6697,8300");
+  opt << TorOpt("MapAddress", TorOpt::LineList, "");
+  opt << TorOpt("MaxAdvertisedBandwidth", TorOpt::DataSize, "1073741824");
+  opt << TorOpt("MaxCircuitDirtiness", TorOpt::TimeInterval, "600");
+  opt << TorOpt("MaxClientCircuitsPending", TorOpt::Integer, "32");
+  opt << TorOpt("MaxOnionsPending", TorOpt::Integer, "100");
+  opt << TorOpt("MyFamily", TorOpt::String, "");
+  opt << TorOpt("NewCircuitPeriod", TorOpt::TimeInterval, "30");
+  opt << TorOpt("NamingAuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("NATDListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("NATDPort", TorOpt::LineList, "0");
+  opt << TorOpt("Nickname", TorOpt::String, "");
+  opt << TorOpt("WarnUnsafeSocks", TorOpt::Boolean, "1");
+  opt << TorOpt("NodeFamily", TorOpt::LineList, "");
+  opt << TorOpt("NumCPUs", TorOpt::Integer, "0");
+  opt << TorOpt("NumEntryGuards", TorOpt::Integer, "3");
+  opt << TorOpt("ORListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("ORPort", TorOpt::Port, "0");
+  opt << TorOpt("OutboundBindAddress", TorOpt::String, "");
+  opt << TorOpt("PerConnBWBurst", TorOpt::DataSize, "0");
+  opt << TorOpt("PerConnBWRate", TorOpt::DataSize, "0");
+  opt << TorOpt("PidFile", TorOpt::String, "");
+  opt << TorOpt("TestingTorNetwork", TorOpt::Boolean, "0");
+  opt << TorOpt("OptimisticData", TorOpt::BooleanAuto, "auto");
+  opt << TorOpt("PortForwarding", TorOpt::Boolean, "0");
+  opt << TorOpt("PortForwardingHelper", TorOpt::Filename, "tor-fw-helper");
+  opt << TorOpt("PreferTunneledDirConns", TorOpt::Boolean, "1");
+  opt << TorOpt("ProtocolWarnings", TorOpt::Boolean, "0");
+  opt << TorOpt("PublishServerDescriptor", TorOpt::CommaList, "1");
+  opt << TorOpt("PublishHidServDescriptors", TorOpt::Boolean, "1");
+  opt << TorOpt("ReachableAddresses", TorOpt::LineList, "");
+  opt << TorOpt("ReachableDirAddresses", TorOpt::LineList, "");
+  opt << TorOpt("ReachableORAddresses", TorOpt::LineList, "");
+  opt << TorOpt("RecommendedVersions", TorOpt::LineList, "");
+  opt << TorOpt("RecommendedClientVersions", TorOpt::LineList, "");
+  opt << TorOpt("RecommendedServerVersions", TorOpt::LineList, "");
+  opt << TorOpt("RefuseUnknownExits", TorOpt::BooleanAuto, "auto");
+  opt << TorOpt("RejectPlaintextPorts", TorOpt::CommaList, "");
+  opt << TorOpt("RelayBandwidthBurst", TorOpt::DataSize, "0");
+  opt << TorOpt("RelayBandwidthRate", TorOpt::DataSize, "0");
+  opt << TorOpt("RendPostPeriod", TorOpt::TimeInterval, "3600");
+  opt << TorOpt("RephistTrackTime", TorOpt::TimeInterval, "36000");
+  opt << TorOpt("RunAsDaemon", TorOpt::Boolean, "0");
+  opt << TorOpt("SafeLogging", TorOpt::String, "1");
+  opt << TorOpt("SafeSocks", TorOpt::Boolean, "0");
+  opt << TorOpt("ServerDNSAllowBrokenConfig", TorOpt::Boolean, "1");
+  opt << TorOpt("ServerDNSAllowNonRFC953Hostnames", TorOpt::Boolean, "0");
+  opt << TorOpt("ServerDNSDetectHijacking", TorOpt::Boolean, "1");
+  opt << TorOpt("ServerDNSRandomizeCase", TorOpt::Boolean, "1");
+  opt << TorOpt("ServerDNSResolvConfFile", TorOpt::String, "");
+  opt << TorOpt("ServerDNSSearchDomains", TorOpt::Boolean, "0");
+  opt << TorOpt("ServerDNSTestAddresses", TorOpt::CommaList, "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org");
+  opt << TorOpt("ShutdownWaitLength", TorOpt::TimeInterval, "30");
+  opt << TorOpt("SocksListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("SocksPolicy", TorOpt::LineList, "");
+  opt << TorOpt("SocksPort", TorOpt::LineList, "9051");
+  opt << TorOpt("SocksTimeout", TorOpt::TimeInterval, "200");
+  opt << TorOpt("StrictNodes", TorOpt::Boolean, "0");
+  opt << TorOpt("TestSocks", TorOpt::Boolean, "0");
+  opt << TorOpt("TokenBucketRefillInterval", TorOpt::TimeMsecInterval, "100");
+  opt << TorOpt("TrackHostExits", TorOpt::CommaList, "");
+  opt << TorOpt("TrackHostExitsExpire", TorOpt::TimeInterval, "1800");
+  opt << TorOpt("TransListenAddress", TorOpt::LineList, "");
+  opt << TorOpt("TransPort", TorOpt::LineList, "0");
+  opt << TorOpt("TunnelDirConns", TorOpt::Boolean, "1");
+  opt << TorOpt("UpdateBridgesFromAuthority", TorOpt::Boolean, "0");
+  opt << TorOpt("UseBridges", TorOpt::Boolean, "0");
+  opt << TorOpt("UseEntryGuards", TorOpt::Boolean, "1");
+  opt << TorOpt("UseMicrodescriptors", TorOpt::BooleanAuto, "auto");
+  opt << TorOpt("User", TorOpt::String, "");
+  opt << TorOpt("V1AuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("V2AuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("V3AuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("TestingV3AuthInitialVotingInterval", TorOpt::TimeInterval, "1800");
+  opt << TorOpt("TestingV3AuthInitialVoteDelay", TorOpt::TimeInterval, "300");
+  opt << TorOpt("TestingV3AuthInitialDistDelay", TorOpt::TimeInterval, "300");
+  opt << TorOpt("V3AuthVotingInterval", TorOpt::TimeInterval, "3600");
+  opt << TorOpt("V3AuthVoteDelay", TorOpt::TimeInterval, "300");
+  opt << TorOpt("V3AuthDistDelay", TorOpt::TimeInterval, "300");
+  opt << TorOpt("V3AuthNIntervalsValid", TorOpt::Integer, "3");
+  opt << TorOpt("V3AuthUseLegacyKey", TorOpt::Boolean, "0");
+  opt << TorOpt("V3BandwidthsFile", TorOpt::Filename, "");
+  opt << TorOpt("VersioningAuthoritativeDirectory", TorOpt::Boolean, "0");
+  opt << TorOpt("VirtualAddrNetwork", TorOpt::String, "127.192.0.0/10");
+  opt << TorOpt("WarnPlaintextPorts", TorOpt::CommaList, "23,109,110,143");
+  opt << TorOpt("_UseFilteringSSLBufferevents", TorOpt::Boolean, "0");
+  opt << TorOpt("__ReloadTorrcOnSIGHUP", TorOpt::Boolean, "1");
+  opt << TorOpt("__AllDirActionsPrivate", TorOpt::Boolean, "0");
+  opt << TorOpt("__DisablePredictedCircuits", TorOpt::Boolean, "0");
+  opt << TorOpt("__LeaveStreamsUnattached", TorOpt::Boolean, "0");
+  opt << TorOpt("__HashedControlSessionPassword", TorOpt::LineList, "");
+  opt << TorOpt("__OwningControllerProcess", TorOpt::String, "");
+  opt << TorOpt("MinUptimeHidServDirectoryV2", TorOpt::TimeInterval, "1500");
+  opt << TorOpt("VoteOnHidServDirectoriesV2", TorOpt::Boolean, "1");
+  opt << TorOpt("_UsingTestNetworkDefaults", TorOpt::Boolean, "0");
+  return opt;
+}
+
+QString
+createTestValue(TorOpt::OptType type)
+{
+  switch (type) {
+  case TorOpt::TimeInterval: return "32684";
+  case TorOpt::TimeMsecInterval: return "5000";
+  case TorOpt::String: return "test_string";
+  case TorOpt::RouterList: return "";
+  case TorOpt::LineList: return "123 456 789";
+  case TorOpt::Float: return "3.14";
+  case TorOpt::Dependant: return "dep";
+  case TorOpt::Virtual: return "virt";
+  case TorOpt::Filename: return "/usr/share/test/test.txt";
+  case TorOpt::CommaList: return "12,43,521,123";
+  case TorOpt::Boolean: return "1";
+  case TorOpt::BooleanAuto: return "1";
+  case TorOpt::Integer: return "7";
+  case TorOpt::DataSize: return "128";
+  case TorOpt::Port: return "9053";
+  case TorOpt::NIL: return "";
+  }
+}
+
+QString
+defaultValue(const QString& optName)
+{
+  static QList<TorOpt> opts = createTestOpts();
+  foreach (const TorOpt& opt, opts) {
+    if (opt.name() == optName)
+      return opt.defaultValue();
+  }
+  return QString();
+}
diff --git a/src/tests/Torrctest.h b/src/tests/Torrctest.h
new file mode 100644
index 0000000..14bce17
--- /dev/null
+++ b/src/tests/Torrctest.h
@@ -0,0 +1,44 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+**  including this file, may be copied, modified, propagated, or distributed
+**  except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TorrcTest.h
+** \brief test of torrc file handling
+*/
+
+#ifndef _TORRC_TEST_H
+#define _TORRC_TEST_H
+
+#include <QtTest/QTest>
+
+/** Full torrc test suite. */
+class TorrcTestSuite : public QObject
+{
+  Q_OBJECT
+
+public:
+  /** Constructor. */
+  TorrcTestSuite(QObject * parent = NULL);
+  /** Destructor. */
+  ~TorrcTestSuite();
+
+private slots:
+  /** Test TorrcLine class */
+  void testTorrcLine();
+  /** Test parser class */
+  void testTorrcParser();
+  /** Test main Torrc class */
+  void testTorrc();
+  /** Test with running Tor */
+  void testRunningTor();
+
+};
+
+#endif
diff --git a/src/tests/testMain.cpp b/src/tests/testMain.cpp
new file mode 100644
index 0000000..7632636
--- /dev/null
+++ b/src/tests/testMain.cpp
@@ -0,0 +1,43 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+**  including this file, may be copied, modified, propagated, or distributed
+**  except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file testMain.cpp
+** \brief Main Vidalia entry point for test target
+*/
+
+#include "Vidalia.h"
+#include "stringutil.h"
+#include "TorrcTest.h"
+
+#include <QtTest/QTest>
+
+/** Helper method to run test cases. */
+template<typename T>
+void runTest(){
+  T * t = new T();
+  const int ret = QTest::qExec(t,QApplication::arguments());
+  if( ret != 0 ){
+    vError(QString("%1: test failed!").arg(t->metaObject()->className()));
+  }
+  delete t;
+}
+
+/** Main application entry point. */
+int
+main(int argc, char *argv[])
+{
+  const QStringList args = char_array_to_stringlist(argv+1, argc-1);
+  Vidalia vidalia(args, argc, argv);
+  /* Launch each test class */
+  runTest<TorrcTestSuite>();
+  return 0;
+}
+



More information about the tor-commits mailing list