add wpasup test

This commit is contained in:
arcan1s 2014-08-17 15:54:08 +04:00
parent 1930eeb33c
commit d7c8490724
6 changed files with 127 additions and 6 deletions

View File

@ -18,6 +18,9 @@ set (NETCTLAUTO_SOURCES testnetctlauto.cpp)
# netctl profile # netctl profile
set (PROFILE_HEADERS testnetctlprofile.h) set (PROFILE_HEADERS testnetctlprofile.h)
set (PROFILE_SOURCES testnetctlprofile.cpp) set (PROFILE_SOURCES testnetctlprofile.cpp)
# wpa_supplicant
set (WPASUP_HEADERS testwpasup.h)
set (WPASUP_SOURCES testwpasup.cpp)
# include_path # include_path
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/include/ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/include/
@ -37,6 +40,7 @@ if (USE_QT5)
qt5_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS}) qt5_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS})
qt5_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS}) qt5_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS})
qt5_wrap_cpp (PROFILE_MOC_SOURCES ${PROFILE_HEADERS}) qt5_wrap_cpp (PROFILE_MOC_SOURCES ${PROFILE_HEADERS})
qt5_wrap_cpp (WPASUP_MOC_SOURCES ${WPASUP_HEADERS})
else () else ()
find_package (Qt4 COMPONENTS QtCore QtTest REQUIRED) find_package (Qt4 COMPONENTS QtCore QtTest REQUIRED)
include (${QT_USE_FILE}) include (${QT_USE_FILE})
@ -44,6 +48,7 @@ else ()
qt4_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS}) qt4_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS})
qt4_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS}) qt4_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS})
qt4_wrap_cpp (PROFILE_MOC_SOURCES ${PROFILE_HEADERS}) qt4_wrap_cpp (PROFILE_MOC_SOURCES ${PROFILE_HEADERS})
qt4_wrap_cpp (WPASUP_MOC_SOURCES ${WPASUP_HEADERS})
endif() endif()
# netctl # netctl
@ -55,6 +60,9 @@ target_link_libraries (${SUBPROJECT}-netctlauto ${PROJECT_LIBRARY} ${QT_NEEDED_L
# netctl profile # netctl profile
add_executable (${SUBPROJECT}-profile ${PROFILE_HEADERS} ${PROFILE_SOURCES} ${PROFILE_MOC_SOURCES}) add_executable (${SUBPROJECT}-profile ${PROFILE_HEADERS} ${PROFILE_SOURCES} ${PROFILE_MOC_SOURCES})
target_link_libraries (${SUBPROJECT}-profile ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS}) target_link_libraries (${SUBPROJECT}-profile ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# wpa_supplicant
add_executable (${SUBPROJECT}-wpasup ${WPASUP_HEADERS} ${WPASUP_SOURCES} ${WPASUP_MOC_SOURCES})
target_link_libraries (${SUBPROJECT}-wpasup ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties # install properties
add_test (NAME Netctl COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-netctl add_test (NAME Netctl COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-netctl
@ -63,4 +71,6 @@ add_test (NAME NetctlAuto COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-netc
"-o" "../Testing/output-netctlauto.log") "-o" "../Testing/output-netctlauto.log")
add_test (NAME Profile COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-profile add_test (NAME Profile COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-profile
"-o" "../Testing/output-profile.log") "-o" "../Testing/output-profile.log")
add_test (NAME WpaSup COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-wpasup
"-o" "../Testing/output-wpasup.log")

View File

@ -69,6 +69,7 @@ void TestNetctl::removeTestProfile()
void TestNetctl::initTestCase() void TestNetctl::initTestCase()
{ {
qDebug() << "netctlgui library tests"; qDebug() << "netctlgui library tests";
qDebug() << "Netctl class tests (netctl functions)";
qDebug() << "TODO: unfortunately, some functions which is required to work"; qDebug() << "TODO: unfortunately, some functions which is required to work";
qDebug() << "with the working profile isn't tested here (including netctl-auto)"; qDebug() << "with the working profile isn't tested here (including netctl-auto)";
QWARN("Some functions requires root privileges"); QWARN("Some functions requires root privileges");
@ -85,21 +86,15 @@ void TestNetctl::cleanupTestCase()
void TestNetctl::test_getRecommendedConfiguration() void TestNetctl::test_getRecommendedConfiguration()
{ {
QStringList original; QStringList original;
// original.append(QString("CTRL_DIR==/run/wpa_supplicant_netctl-gui"));
// original.append(QString("CTRL_GROUP==network"));
original.append(QString("FORCE_SUDO==false")); original.append(QString("FORCE_SUDO==false"));
original.append(QString("IFACE_DIR==/sys/class/net")); original.append(QString("IFACE_DIR==/sys/class/net"));
original.append(QString("NETCTLAUTO_PATH==/usr/bin/netctl-auto")); original.append(QString("NETCTLAUTO_PATH==/usr/bin/netctl-auto"));
original.append(QString("NETCTLAUTO_SERVICE==netctl-auto")); original.append(QString("NETCTLAUTO_SERVICE==netctl-auto"));
original.append(QString("NETCTL_PATH==/usr/bin/netctl")); original.append(QString("NETCTL_PATH==/usr/bin/netctl"));
// original.append(QString("PID_FILE==/run/wpa_supplicant_netctl-gui.pid"));
original.append(QString("PREFERED_IFACE==wifi0")); original.append(QString("PREFERED_IFACE==wifi0"));
original.append(QString("PROFILE_DIR==/etc/netctl")); original.append(QString("PROFILE_DIR==/etc/netctl"));
original.append(QString("SUDO_PATH==/usr/bin/sudo")); original.append(QString("SUDO_PATH==/usr/bin/sudo"));
original.append(QString("SYSTEMCTL_PATH==/usr/bin/systemctl")); original.append(QString("SYSTEMCTL_PATH==/usr/bin/systemctl"));
// original.append(QString("WPACLI_PATH==/usr/bin/wpa_cli"));
// original.append(QString("WPASUP_PATH==/usr/bin/wpa_supplicant"));
// original.append(QString("WPA_DRIVERS==nl80211,wext"));
QMap<QString, QString> resultMap = Netctl::getRecommendedConfiguration(); QMap<QString, QString> resultMap = Netctl::getRecommendedConfiguration();
QStringList result; QStringList result;
for (int i=0; i<resultMap.keys().count(); i++) for (int i=0; i<resultMap.keys().count(); i++)

View File

@ -77,6 +77,7 @@ void TestNetctlAuto::removeTestProfiles()
void TestNetctlAuto::initTestCase() void TestNetctlAuto::initTestCase()
{ {
qDebug() << "netctlgui library tests"; qDebug() << "netctlgui library tests";
qDebug() << "Netctl class tests (netctl-auto functions)";
qDebug() << "TODO: unfortunately, some functions which is required to work"; qDebug() << "TODO: unfortunately, some functions which is required to work";
qDebug() << "with the working profile isn't tested here (including netctl-auto)"; qDebug() << "with the working profile isn't tested here (including netctl-auto)";
QWARN("Some functions requires root privileges"); QWARN("Some functions requires root privileges");

View File

@ -62,6 +62,7 @@ bool TestNetctlProfile::removeTestProfile()
void TestNetctlProfile::initTestCase() void TestNetctlProfile::initTestCase()
{ {
qDebug() << "netctlgui library tests"; qDebug() << "netctlgui library tests";
qDebug() << "NetctlProfile class tests";
qDebug() << "TODO: unfortunately, some functions which is required to work"; qDebug() << "TODO: unfortunately, some functions which is required to work";
qDebug() << "with the working profile isn't tested here (including netctl-auto)"; qDebug() << "with the working profile isn't tested here (including netctl-auto)";
QWARN("Some functions requires root privileges"); QWARN("Some functions requires root privileges");

View File

@ -0,0 +1,72 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "testwpasup.h"
#include <QtTest>
#include <netctlgui/netctlgui.h>
WpaSup *TestWpaSup::createWpaSupObj()
{
QMap<QString, QString> settings = WpaSup::getRecommendedConfiguration();
settings[QString("FORCE_SUDO")] = QString("true");
WpaSup *wpasup = new WpaSup(false, settings);
return wpasup;
}
void TestWpaSup::initTestCase()
{
qDebug() << "netctlgui library tests";
qDebug() << "WpaSup class tests";
qDebug() << "TODO: unfortunately, some functions which is required to work";
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
QWARN("Some functions requires root privileges");
}
void TestWpaSup::cleanupTestCase()
{
}
void TestWpaSup::test_getRecommendedConfiguration()
{
QStringList original;
original.append(QString("CTRL_DIR==/run/wpa_supplicant_netctl-gui"));
original.append(QString("CTRL_GROUP==network"));
original.append(QString("FORCE_SUDO==false"));
original.append(QString("PID_FILE==/run/wpa_supplicant_netctl-gui.pid"));
original.append(QString("SUDO_PATH==/usr/bin/sudo"));
original.append(QString("WPACLI_PATH==/usr/bin/wpa_cli"));
original.append(QString("WPASUP_PATH==/usr/bin/wpa_supplicant"));
original.append(QString("WPA_DRIVERS==nl80211,wext"));
QMap<QString, QString> resultMap = WpaSup::getRecommendedConfiguration();
QStringList result;
for (int i=0; i<resultMap.keys().count(); i++)
result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);
QWARN("This test may fail on other configuration");
QCOMPARE(result, original);
}
QTEST_MAIN(TestWpaSup);

42
sources/test/testwpasup.h Normal file
View File

@ -0,0 +1,42 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TESTWPASUP_H
#define TESTWPASUP_H
#include <QObject>
class WpaSup;
class TestWpaSup : public QObject
{
Q_OBJECT
private slots:
// initialization
void initTestCase();
void cleanupTestCase();
// wpa_supplicant
void test_getRecommendedConfiguration();
private:
WpaSup *createWpaSupObj();
};
#endif /* TESTWPASUP_H */