old tests works
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index b44c2e8..7a3eae6 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -299,10 +299,7 @@
{
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);
}
}
diff --git a/model/sync-seq-no.h b/model/sync-seq-no.h
index 4f84482..7814f91 100644
--- a/model/sync-seq-no.h
+++ b/model/sync-seq-no.h
@@ -124,20 +124,18 @@
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;
}
diff --git a/test/test_app_socket.cc b/test/test_app_socket.cc
index 6a6e04a..d502822 100644
--- a/test/test_app_socket.cc
+++ b/test/test_app_socket.cc
@@ -40,6 +40,9 @@
INIT_LOGGER ("Test.AppSocket");
+#define PRINT
+//std::cout << "Line: " << __LINE__ << std::endl;
+
class TestSocketApp {
public:
map<string, string> data;
@@ -51,9 +54,12 @@
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 @@
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);
diff --git a/test/test_ccnx_wrapper.cc b/test/test_ccnx_wrapper.cc
index 3db44ba..c10930c 100644
--- a/test/test_ccnx_wrapper.cc
+++ b/test/test_ccnx_wrapper.cc
@@ -44,6 +44,15 @@
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::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 @@
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);
}
diff --git a/test/test_scheduler.cc b/test/test_scheduler.cc
index 59687e4..0d67417 100644
--- a/test/test_scheduler.cc
+++ b/test/test_scheduler.cc
@@ -137,6 +137,10 @@
{
}
+void funcPass( const std::vector<MissingDataInfo> &v)
+{
+}
+
void funcRemove( const std::string &/*prefix*/ )
{
}
@@ -144,7 +148,7 @@
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 ();