old tests works

This commit is contained in:
Zhenkai Zhu committed 2012-06-01 11:52:57 -07:00
1 parent 43ae5c7be0
commit a30e178115
5 files changed
+42 -17

No files matched your search

+1 -4
View File
@@ -299,10 +299,7 @@ SyncLogic::processSyncData (const std::string &name, DigestConstPtr digest, cons
{
diffLog->update (info, seq);
//m_onUpdate (info->toString (), seq, oldSeq);
MissingDataInfo mdi;
mdi.prefix = info->toString();
mdi.low = oldSeq;
mdi.high = seq;
MissingDataInfo mdi = {info->toString(), ++oldSeq, seq};
v.push_back(mdi);
}
}
+7 -9
View File
@@ -124,20 +124,18 @@ public:
bool
operator <= (const SeqNo &seq) const
{
return m_session <= seq.m_session || (m_session == seq.m_session && m_seq <= seq.m_seq);
return m_session == seq.m_session && m_seq <= seq.m_seq;
}
SeqNo &
operator ++ ()
{
m_seq ++;
return *this;
}
SeqNo &
operator --()
{
m_seq --;
if (m_valid) {
m_seq ++;
}
else {
m_valid = true;
}
return *this;
}
+9 -3
View File
@@ -40,6 +40,9 @@ using namespace boost;
INIT_LOGGER ("Test.AppSocket");
#define PRINT
//std::cout << "Line: " << __LINE__ << std::endl;
class TestSocketApp {
public:
map<string, string> data;
@@ -51,9 +54,12 @@ public:
void fetchAll(const vector<MissingDataInfo> &v, SyncAppSocket *socket) {
int n = v.size();
PRINT
for (int i = 0; i < n; i++) {
SeqNo s = v[i].low;
for(++s; s <= v[i].high; ++s) {
for(SeqNo s = v[i].low; s <= v[i].high; ++s) {
PRINT
socket->fetchString(v[i].prefix, s, bind(&TestSocketApp::set, this, _1, _2));
}
}
@@ -101,7 +107,7 @@ BOOST_AUTO_TEST_CASE (AppSocketTest)
string data0 = "Very funny Scotty, now beam down my clothes";
_LOG_DEBUG ("s1 publish");
s1.publishString (p1, 0, data0, 10);
this_thread::sleep (posix_time::milliseconds (120));
this_thread::sleep (posix_time::milliseconds (1000));
// from code logic, we won't be fetching our own data
a1.set(p1 + "/0/0", data0);
+20
View File
@@ -44,6 +44,15 @@ struct TestStruct {
s_str1 = str1;
s_str2 = str2;
}
char *m_buf;
size_t m_len;
void rawSet(string str1, const char *buf, size_t len) {
std::cout << "In rawSet" << std::endl;
m_buf = (char *)calloc(1, len);
memcpy(m_buf, buf, len);
s_str1 = str1;
}
};
BOOST_AUTO_TEST_CASE (CcnxWrapperTest)
@@ -57,6 +66,9 @@ BOOST_AUTO_TEST_CASE (CcnxWrapperTest)
boost::function<void (string, string)> memberFunc =
bind(&TestStruct::set, &foo, _1, _2);
boost::function<void (string, const char *, size_t)> rawFunc =
bind(&TestStruct::rawSet, &foo, _1, _2, _3);
string prefix = "/ucla.edu";
ha.setInterestFilter(prefix, globalFunc);
this_thread::sleep (posix_time::milliseconds (10));
@@ -79,6 +91,14 @@ BOOST_AUTO_TEST_CASE (CcnxWrapperTest)
this_thread::sleep (posix_time::milliseconds (5));
BOOST_CHECK_EQUAL(foo.s_str1, name);
BOOST_CHECK_EQUAL(foo.s_str2, data);
string rawDataName = "/ucla.edu/1";
int num[5] = {0, 1, 2, 3, 4};
ha.publishRawData(rawDataName, (const char *)num, sizeof(num), 30);
hb.sendInterest(rawDataName, rawFunc);
BOOST_CHECK_EQUAL(foo.s_str1, rawDataName);
BOOST_CHECK(memcmp((char *)num, foo.m_buf, foo.m_len) == 0);
}
+5 -1
View File
@@ -137,6 +137,10 @@ void funcUpdate( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const S
{
}
void funcPass( const std::vector<MissingDataInfo> &v)
{
}
void funcRemove( const std::string &/*prefix*/ )
{
}
@@ -144,7 +148,7 @@ void funcRemove( const std::string &/*prefix*/ )
BOOST_AUTO_TEST_CASE (SyncLogicSchedulerTest)
{
SyncLogic *logic = 0;
BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcUpdate, funcRemove));
BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcPass, funcRemove));
this_thread::sleep (posix_time::milliseconds (100));
Scheduler &scheduler = logic->getScheduler ();