Changeset 1846

Show
Ignore:
Timestamp:
09/07/05 09:42:46 (3 years ago)
Author:
madcat
Message:

Imported hncore and hnbase testsuite from oldbld tree.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hydranode/hnbase/test/Jamfile

    r1831 r1846  
    1 exe utils : test-utils.cpp ; 
     1exe config : test-config.cpp ..//hnbase ../../extra ; 
     2exe event : test-event.cpp ..//hnbase ../../extra ; 
     3exe hash : test-hash.cpp ..//hnbase ../../extra ; 
     4exe log : test-log.cpp ..//hnbase ../../extra ; 
     5exe object : test-object.cpp ..//hnbase ../../extra ; 
    26exe range : test-range.cpp ../../extra/test ; 
     7exe resolver : test-resolver.cpp ..//hnbase ../../extra ; 
     8exe sockets : test-sockets.cpp ..//hnbase ../../extra ; 
     9exe ssocket : test-ssocket.cpp ..//hnbase ../../extra ; 
    310exe timed_callback : test-timed_callback.cpp ..//hnbase ../../extra ; 
    4 exe resolver : test-resolver.cpp ..//hnbase ../../extra ; 
     11exe utils : test-utils.cpp ..//hnbase ../../extra ; 
     12exe utils2 : test-utils2.cpp ..//hnbase ../../extra ../../extra/test ; 
    513 
    6 stage bin : utils range resolver timed_callback : <location>bin <hardcode-dll-paths>true ; 
     14stage bin 
     15        : config event hash log object range resolver sockets ssocket 
     16          timed_callback utils utils2 
     17        : <location>bin <hardcode-dll-paths>true ; 
  • hydranode/hnbase/test/test-config.cpp

    r1024 r1846  
    1717 */ 
    1818 
    19 #include <hn/config.h> 
     19#include <hnbase/config.h> 
    2020#include <iostream> 
    2121#include <boost/timer.hpp> 
  • hydranode/hnbase/test/test-event.cpp

    r1203 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 #include <hn/event.h> 
     19#include <hnbase/event.h> 
    2020#include <iostream> 
    2121#include <boost/shared_ptr.hpp> 
  • hydranode/hnbase/test/test-hash.cpp

    r832 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    2121#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    2222 
    23 #include <hn/hash.h> 
     23#include <hnbase/hash.h> 
    2424#include <boost/progress.hpp> 
    2525#include <boost/test/minimal.hpp> 
     
    4646void test_hash() { 
    4747        Hash<MD4Hash> h(TestData1); 
    48         BOOST_CHECK(h.getLength() == 16); 
     48        BOOST_CHECK(h.size() == 16); 
    4949        BOOST_CHECK(!memcmp(h.getData().get(), TestData1, 16)); 
    50         BOOST_CHECK(TestDecoded == Utils::decode(h.getData(), h.getLength())); 
     50        BOOST_CHECK(TestDecoded == Utils::decode(h.getData(), h.size())); 
    5151 
    5252        std::string htmd4("MD4Hash"); 
  • hydranode/hnbase/test/test-log.cpp

    r504 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    2727#include <string> 
    2828#include <boost/format.hpp> 
    29 #include <hn/log.h> 
     29#include <hnbase/log.h> 
    3030 
    3131int main() { 
  • hydranode/hnbase/test/test-object.cpp

    r504 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1919#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    2020 
    21 #include <hn/object.h> 
    22 #include <hn/log.h> 
     21#include <hnbase/object.h> 
     22#include <hnbase/log.h> 
    2323#include <boost/lexical_cast.hpp> 
    2424 
  • hydranode/hnbase/test/test-range.cpp

    r1787 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
  • hydranode/hnbase/test/test-sockets.cpp

    r504 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    3030#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    3131 
    32 #include <hn/log.h> 
    33 #include <hn/sockets.h> 
     32#include <hnbase/log.h> 
     33#include <hnbase/sockets.h> 
    3434#include <map> 
    3535#include <vector> 
     
    7676        for (int i = 0; i < SERVCOUNT; i++) { 
    7777                SocketServer *serv = new SocketServer( 
    78                         makeFunctor( 
    79                                 (SSEventHandler*)0, 
    80                                 *this, 
    81                                 &TestSockets::onServSockEvent 
    82                         ) 
     78                        boost::bind(&TestSockets::onServSockEvent, this, _1, _2) 
    8379                ); 
    8480                IPV4Address addr(0, 2000+i); 
     
    8985        while (true) { 
    9086                SocketWatcher::poll(); 
    91                 EventMain::getInstance().handlePending(); 
     87                EventMain::instance().handlePending(); 
    9288        } 
    9389 
     
    9591 
    9692        // Handle any leftover events 
    97         EventMain::getInstance().handlePending(); 
     93        EventMain::instance().handlePending(); 
    9894 
    9995        // Return to system 
     
    107103                        char msg[] = "Hello from server!"; 
    108104                        SocketClient *client = server->accept( 
    109                                 makeFunctor((SCEventHandler*)0, *this, 
    110                                 &TestSockets::onClieSockEvent) 
     105                                boost::bind( 
     106                                        &TestSockets::onClieSockEvent, 
     107                                        this, _1, _2 
     108                                ) 
    111109                        ); 
    112110                        client->write(msg, 18); 
     
    145143                        logMsg("[TestSockets] Client lost."); 
    146144                        m_clients.remove(client); 
    147                         delete client
     145                        client->destroy()
    148146                        break; 
    149147                } 
  • hydranode/hnbase/test/test-ssocket.cpp

    r201 r1846  
    1 #include <hn/ssocket.h> 
    2 #include <hn/log.h> 
     1/* 
     2 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
     3 * 
     4 *  This program is free software; you can redistribute it and/or modify 
     5 *  it under the terms of the GNU General Public License as published by 
     6 *  the Free Software Foundation; either version 2 of the License, or 
     7 *  (at your option) any later version. 
     8 * 
     9 *  This program is distributed in the hope that it will be useful, 
     10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     12 *  GNU General Public License for more details. 
     13 * 
     14 *  You should have received a copy of the GNU General Public License 
     15 *  along with this program; if not, write to the Free Software 
     16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     17 */ 
     18 
     19#include <hnbase/ssocket.h> 
     20#include <hnbase/log.h> 
    321class ED2K { 
    422public: 
     
    6482        while (true) { 
    6583                SocketWatcher::poll(); 
    66                 EventMain::getInstance().handlePending(); 
     84                EventMain::instance().handlePending(); 
    6785        } 
    6886} 
  • hydranode/hnbase/test/test-utils.cpp

    r1774 r1846  
     1/* 
     2 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
     3 * 
     4 *  This program is free software; you can redistribute it and/or modify 
     5 *  it under the terms of the GNU General Public License as published by 
     6 *  the Free Software Foundation; either version 2 of the License, or 
     7 *  (at your option) any later version. 
     8 * 
     9 *  This program is distributed in the hope that it will be useful, 
     10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     12 *  GNU General Public License for more details. 
     13 * 
     14 *  You should have received a copy of the GNU General Public License 
     15 *  along with this program; if not, write to the Free Software 
     16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     17 */ 
     18 
    119#include <hnbase/utils.h> 
    220void logMsg(const boost::format &msg) { 
  • hydranode/hnbase/test/test-utils2.cpp

    r504 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    2020#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    2121 
    22 #include <hn/utils.h> 
     22#include <hnbase/utils.h> 
     23#include <hnbase/log.h> 
    2324#include <boost/test/unit_test.hpp> 
     25 
    2426using boost::unit_test_framework::test_suite; 
    2527using namespace boost::unit_test_framework; 
     
    5254        BOOST_CHECK(!strcmp(src, dest)); 
    5355} 
    54 #include <hn/log.h> 
    5556void test_hexdump() { 
    5657//      std::string data(10024, '\0'); 
  • hydranode/hncore/test/Jamfile

    r1757 r1846  
    1313        : 
    1414; 
    15 stage bin : hasher : <location>bin <hardcode-dll-paths>true ; 
     15exe ipfilter : test-ipfilter.cpp ..//hncore ../../hnbase ../../extra $(extra_deps) ; 
     16exe metadata : test-metadata.cpp ..//hncore ../../hnbase ../../extra $(extra_deps) 
     17         ../../extra ../../extra/test ; 
     18exe partdata : test-partdata.cpp ..//hncore ../../hnbase ../../extra $(extra_deps) ; 
     19exe workthread : test-workthread.cpp ..//hncore ../../hnbase ../../extra $(extra_deps) ; 
     20 
     21stage bin : hasher ipfilter metadata partdata workthread 
     22        : <location>bin <hardcode-dll-paths>true 
     23
  • hydranode/hncore/test/test-hasher.cpp

    r1757 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 /** @file test-hasher.cpp Regress-test for Files Identification Subsystem */ 
     19/** 
     20 * \file test-hasher.cpp Regress-test for Files Identification Subsystem 
     21 */ 
    2022 
    2123#ifndef DOXYGEN_SHOULD_SKIP_THIS 
  • hydranode/hncore/test/test-ipfilter.cpp

    r541 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 //! @file test-ipfilter.cpp Tests IpFilter API 
     19/** 
     20 * \file test-ipfilter.cpp Tests IpFilter API 
     21 */ 
    2022 
    21 #include <hn/ipfilter.h> 
    22 #include <hn/log.h> 
    23 #include <hn/ipv4addr.h> 
    24 #include <hn/utils.h> 
     23#include <hncore/ipfilter.h> 
     24#include <hnbase/log.h> 
     25#include <hnbase/ipv4addr.h> 
     26#include <hnbase/utils.h> 
    2527#include <boost/test/minimal.hpp> 
    2628 
  • hydranode/hncore/test/test-metadata.cpp

    r1361 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 /** @file test-metadata.cpp Test app for MetaData Subsystem */ 
     19/** 
     20 * \file test-metadata.cpp Test app for MetaData Subsystem 
     21 */ 
    2022 
    2123#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    2224 
    2325 
    24 #include <hn/metadata.h> 
    25 #include <hn/hash.h> 
    26 #include <hn/metadb.h> 
     26#include <hncore/metadata.h> 
     27#include <hnbase/hash.h> 
     28#include <hncore/metadb.h> 
    2729#include <stdexcept> 
    2830#include <fstream> 
    2931#include <boost/test/unit_test.hpp> 
     32#include <boost/test/unit_test_log.hpp> 
     33 
    3034using boost::unit_test_framework::test_suite; 
    3135using namespace boost::unit_test_framework; 
     
    7579        uint8_t opcode = Utils::getVal<uint8_t>(i); 
    7680        BOOST_CHECK(opcode == OP_AMD); 
    77         Utils::getVal<uint16_t>(i); // length 
     81        (void)Utils::getVal<uint16_t>(i); // length 
    7882 
    7983        AudioMetaData *amd1 = new AudioMetaData(i); 
     
    140144        uint8_t opcode = Utils::getVal<uint8_t>(i); 
    141145        BOOST_CHECK(opcode == OP_VMD); 
    142         Utils::getVal<uint16_t>(i); // length 
     146        (void)Utils::getVal<uint16_t>(i); // length 
    143147 
    144148        VideoMetaData *vmd2 = new VideoMetaData(i); 
     
    198202        uint8_t opcode = Utils::getVal<uint8_t>(i); 
    199203        BOOST_CHECK(opcode == OP_ARMD); 
    200         Utils::getVal<uint16_t>(i); // length 
     204        (void)Utils::getVal<uint16_t>(i); // length 
    201205 
    202206        ArchiveMetaData *armd2 = new ArchiveMetaData(i); 
     
    245249        uint8_t opcode = Utils::getVal<uint8_t>(i); 
    246250        BOOST_CHECK(opcode == OP_IMD); 
    247         Utils::getVal<uint16_t>(i); // length 
     251        (void)Utils::getVal<uint16_t>(i); // length 
    248252 
    249253        ImageMetaData *imd2 = new ImageMetaData(i); 
     
    332336                uint8_t opcode = Utils::getVal<uint8_t>(i); 
    333337                BOOST_CHECK(opcode == OP_HASHSET); 
    334                 Utils::getVal<uint16_t>(i); // length 
     338                (void)Utils::getVal<uint16_t>(i); // length 
    335339                uint8_t fhtype = Utils::getVal<uint8_t>(i); 
    336340                BOOST_CHECK(fhtype == OP_HT_MD4); 
     
    391395        md->setImageData(imd); 
    392396        BOOST_CHECK_NO_THROW(md->getImageData()); 
    393         md->setFileSize(123123123); 
     397        md->setSize(123123123); 
    394398        md->setModDate(123123); 
    395399        md->setFileType(FT_UNKNOWN); 
     
    409413        BOOST_CHECK(md->getArchiveData()->getComment() == "Very wierd archive."); 
    410414        BOOST_CHECK(md->getImageData()->getComment() == "This is an odd picture."); 
    411         BOOST_CHECK(md->getFileSize() == 123123123); 
     415        BOOST_CHECK(md->getSize() == 123123123); 
    412416        BOOST_CHECK(md->getModDate() == 123123); 
    413417        BOOST_CHECK(md->getFileType() == FT_UNKNOWN); 
     
    443447        uint8_t opcode = Utils::getVal<uint8_t>(i); 
    444448        BOOST_CHECK(opcode == OP_METADATA); 
    445         Utils::getVal<uint16_t>(i); // length 
     449        (void)Utils::getVal<uint16_t>(i); // length 
    446450 
    447451        MetaData *md1 = new MetaData(i); 
     
    455459        BOOST_CHECK(md1->getArchiveData()->getComment() == "Very wierd archive."); 
    456460        BOOST_CHECK(md1->getImageData()->getComment() == "This is an odd picture."); 
    457         BOOST_CHECK(md1->getFileSize() == 123123123); 
     461        BOOST_CHECK(md1->getSize() == 123123123); 
    458462        BOOST_CHECK(md1->getModDate() == 123123); 
    459463        BOOST_CHECK(md1->getFileType() == FT_UNKNOWN); 
     
    519523        logMsg("Run with `-v` argument for verbose trace output."); 
    520524 
    521         unit_test_log::instance().set_log_threshold_level(log_all_errors); 
     525        unit_test_log.set_threshold_level(log_all_errors); 
    522526        test_suite *rms = BOOST_TEST_SUITE("MetaData Structures I/O Test"); 
    523527 
  • hydranode/hncore/test/test-partdata.cpp

    r556 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 /** \file test-partdata.cpp Simulation and regress-test for PartData class */ 
     19/** 
     20 * \file test-partdata.cpp Simulation and regress-test for PartData class 
     21 */ 
    2022 
    2123#ifndef DOXYGEN_SHOULD_SKIP_THIS 
    2224 
    23 #include <hn/partdata.h> 
    24 #include <hn/log.h> 
    25 #include <hn/metadata.h> 
     25#include <hncore/partdata.h> 
     26#include <hnbase/log.h> 
     27#include <hncore/metadata.h> 
     28 
    2629uint32_t file_size(50*1024*1024); 
    2730uint32_t chunk_size(9500*1024); 
    28 void writeRange(UsedRangePtr ur) { 
     31 
     32void writeRange(Detail::UsedRangePtr ur) { 
    2933        logDebug(boost::format("Writing range %d..%d") % ur->begin() % ur->end()); 
    3034        while (!ur->isComplete()) try { 
    31                 LockedRangePtr lr = ur->getLock(chunk_size/4); 
     35                Detail::LockedRangePtr lr = ur->getLock(chunk_size/4); 
    3236                lr->write(lr->begin(), std::string(lr->length(), '#')); 
    3337        } catch (std::runtime_error &e) { 
     
    3539        } 
    3640} 
     41 
    3742void onFileEvent(PartData *, int evt) { 
    3843        if (evt == PD_COMPLETE) { 
     
    4045        } 
    4146} 
     47 
    4248void onHashEvent(HashWorkPtr p, HashEvent) { 
    4349        PartData *pd = new PartData(file_size, "test.tmp", "final.file"); 
     
    7581        } 
    7682} 
     83 
    7784int main(int, char*[]) { 
    7885        std::ofstream ofs("test.ref", std::ios::out); 
  • hydranode/hncore/test/test-workthread.cpp

    r681 r1846  
    1 /** 
     1/* 
    22 *  Copyright (C) 2004-2005 Alo Sarv <madcat_@users.sourceforge.net> 
    33 * 
     
    1717 */ 
    1818 
    19 /** @file test-workthread.cpp WorkThread API regress test */ 
     19/** 
     20 * \file test-workthread.cpp WorkThread API regress test 
     21 */ 
    2022 
    21 #include <hn/workthread.h> 
    22 #include <hn/event.h> 
     23#include <hncore/workthread.h> 
     24#include <hnbase/event.h> 
    2325#include <boost/enable_shared_from_this.hpp> 
    2426 
  • hydranode/project-root.jam

    r1746 r1846  
    1616                toolset.using darwin ; 
    1717        } else { 
    18                 using gcc
     18                using gcc : : distcc g++
    1919        } 
    2020}