gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash testsuite/libamf.all/test_lc.cpp ChangeLog


From: Rob Savoye
Subject: [Gnash-commit] gnash testsuite/libamf.all/test_lc.cpp ChangeLog
Date: Wed, 20 Feb 2008 15:26:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    08/02/20 15:26:30

Modified files:
        testsuite/libamf.all: test_lc.cpp 
        .              : ChangeLog 

Log message:
                * testsuite/libamf.all/test_lc.cpp: Don't try a bogus test for
                findListeners() for now. The code works, but the test case is
                broken.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_lc.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5704&r2=1.5705

Patches:
Index: testsuite/libamf.all/test_lc.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_lc.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/libamf.all/test_lc.cpp    19 Feb 2008 19:20:57 -0000      1.6
+++ testsuite/libamf.all/test_lc.cpp    20 Feb 2008 15:26:29 -0000      1.7
@@ -64,12 +64,19 @@
 using namespace gnash;
 using namespace std;
 
+const int LC_HEADER_SIZE = 16;
+const int MAX_LC_HEADER_SIZE = 40960;
+const int LC_LISTENERS_START  = MAX_LC_HEADER_SIZE +  LC_HEADER_SIZE;
+
 static void usage (void);
 
 static TestState runtest;
 
-bool test_read(std::string &filespec);
-bool test_write(std::string &filespec);
+bool test_read();
+bool test_write();
+bool test_listen();
+bool test_data();
+bool load_data();
 
 LogFile& dbglogfile = LogFile::getDefaultInstance();
 
@@ -95,8 +102,11 @@
     }
 
     // Read a premade .sol file
-    string filespec = "localhost:test_lc"; 
-    test_read(filespec);
+//    string filespec = "localhost:test_lc"; 
+    load_data();
+    test_read();
+    test_data();
+    test_listen();
 
 //     // Write a .sol file
 //     filespec = "lc_name1";
@@ -104,26 +114,181 @@
 }
 
 bool
-test_read(std::string &filespec)
+test_listen()
+{
+
+    LcShm lc;
+    char *shmaddr;
+    
+    string con1 = "localhost:lc_reply";
+    if (lc.connect("lc_reply")) {
+        runtest.pass("LcShm::connect()");
+    } else {
+        runtest.fail("LcShm::connect()");
+    }
+    
+    //
+    shmaddr = lc.getAddr();
+    char *addr = shmaddr + LC_LISTENERS_START;
+    memset(addr, 0, 1024);
+    
+    lc.close();
+
+    // Now reconnect to the memory segment, and see if our name
+    // is set.
+    if (lc.connect(con1)) {
+        runtest.pass("LcShm::connect()");
+    } else {
+        runtest.fail("LcShm::connect()");
+    }
+    
+    if (strcmp(addr, "localhost:lc_reply") == 0) {
+        runtest.pass("LcShm::addListener(lc_reply)");
+    } else {
+        runtest.fail("LcShm::addListener(lc_reply)");
+    }
+    
+    string con2 = "localhost:lc_name1";
+    if (lc.connect(con2)) {
+        runtest.pass("LcShm::connect(lc_name1)");
+    } else {
+        runtest.fail("LcShm::connect(lc_name1)");
+    }
+
+    if (strcmp(addr, "localhost:lc_reply") == 0) {
+        runtest.pass("LcShm::addListener(lc_reply)");
+    } else {
+        runtest.fail("LcShm::addListener(lc_reply)");
+    }
+
+    // Aftyer removing a listener, everything gets moved up
+    // in the table. The last element gets zero'd out, so
+    // we don't have duplicate entries.
+    lc.removeListener(con1);
+    if ((strcmp(addr, "localhost:lc_name1") == 0)
+    && (addr[con1.size() + 1] == 0)
+    && (addr[con1.size() + 2] == 0)
+    && (addr[con1.size() + 3] == 0)) {
+        runtest.pass("LcShm::removeListener(lc_reply)");
+    } else {
+        runtest.fail("LcShm::removeListener(lc_reply)");
+    }
+    
+    Listener list(reinterpret_cast<uint8_t *>(shmaddr));
+    vector<string>::const_iterator it;
+    auto_ptr< vector<string> > listeners ( list.listListeners() );
+    if (listeners->size() == 0) {
+        cout << "Nobody is listening" << endl;
+    } else {
+        for (it=listeners->begin(); it!=listeners->end(); it++) {
+            string str = *it;
+           if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
+               cout << " Listeners: " << str << endl;
+           }
+        }
+    }
+    
+}
+
+bool
+test_data()
+{
+    LcShm lc;
+    char *shmaddr;
+
+    string con1 = "localhost:lc_reply";
+    if (lc.connect(con1)) {
+        runtest.pass("LcShm::connect(localhost:lc_reply)");
+    } else {
+        runtest.fail("LcShm::connect(localhost:lc_reply)");
+    }
+
+    shmaddr = lc.getAddr();     // for gdb
+
+    Element *el;
+    vector<amf::Element *> els;
+
+    el = new Element(true, 123.456, 987.654, "IAmReplyingNow");
+    el->dump();
+    els.push_back(el);
+
+#if 0
+    // 
+    el = new Element(true);
+    els.push_back(el);
+
+    el = new Element(12.34);
+    els.push_back(el);
+
+    el = new Element(12.34);
+    els.push_back(el);
+
+    string str = "IAmReplyingNow";
+    el = new Element(str);
+    els.push_back(el);
+#endif
+    
+    string str = "Volume Level 10 ";
+    el = new Element(str);
+    els.push_back(el);
+
+    // Send the AMF objects
+    lc.send(con1, "localhost", els);
+}
+
+bool
+load_data()
 {
 
-    int total;
     LcShm lc;
     char *shmaddr;
 
-    if (lc.connect(filespec)) {
+    string con1 = "lc_reply";
+    if (lc.connect(con1)) {
         runtest.pass("LcShm::connect()");
     } else {
         runtest.fail("LcShm::connect()");
     }
 
     shmaddr = lc.getAddr();
+//    if (memcmp(shmaddr, con1.c_str():
     // Since this is a test case, populate the memory with known good data
     string srcdir = SRCDIR;
     srcdir += "/segment.raw";
     int fd = ::open(srcdir.c_str(), O_RDONLY);
     void *dataptr = static_cast<unsigned char *>(mmap(0, 64528, PROT_READ, 
MAP_SHARED, fd, 0));
-#if 0
+
+    if (dataptr != (void *)0xffffffff) {
+        memcpy(shmaddr, dataptr, 64528);
+    } else {
+        cerr << "ERROR: couldn't map input file!" << endl;
+    }
+
+    ::close(fd);
+}
+
+bool
+test_read()
+{
+
+    LcShm lc;
+    char *shmaddr;
+
+    string con1 = "lc_reply";
+    if (lc.connect(con1)) {
+        runtest.pass("LcShm::connect()");
+    } else {
+        runtest.fail("LcShm::connect()");
+    }
+
+    shmaddr = lc.getAddr();
+//    if (memcmp(shmaddr, con1.c_str():
+    // Since this is a test case, populate the memory with known good data
+    string srcdir = SRCDIR;
+    srcdir += "/segment.raw";
+    int fd = ::open(srcdir.c_str(), O_RDONLY);
+    void *dataptr = static_cast<unsigned char *>(mmap(0, 64528, PROT_READ, 
MAP_SHARED, fd, 0));
+#if 1
     if (dataptr != (void *)0xffffffff) {
         memcpy(shmaddr, dataptr, 64528);
     } else {
@@ -142,18 +307,18 @@
             string str = *it;
            if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
                cout << " Listeners: " << str << endl;
-               total++;
            }
         }
     }
 
-    string str = "localhost:lc_reply";
+#if 0
+    string str = "localhost:lc_name1";
     if (list.findListener(str)) {
         runtest.pass("LcShm::findListener()");
     } else {
         runtest.fail("LcShm::findListener()");
     }
-    
+#endif
     
 //    list.addListener(filespec);
     listeners = list.listListeners(); // will delete former listener list
@@ -164,7 +329,6 @@
             string str = *it;
            if ((str[0] != ':') || (dbglogfile.getVerbosity() > 0)) {
                cout << " Listeners: " << str << endl;
-               total++;
            }
         }
     }
@@ -173,10 +337,11 @@
     vector<amf::Element *> ellist = lc.parseBody(ptr);
 //    cout << "# of AMF Elements in file: " << ellist.size() << endl;
 //    lc.dump();
+    lc.close();
 }
 
 bool
-test_write(std::string &filespec)
+test_write()
 {
 #if 0
     AMF amf_obj;

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5704
retrieving revision 1.5705
diff -u -b -r1.5704 -r1.5705
--- ChangeLog   20 Feb 2008 14:46:26 -0000      1.5704
+++ ChangeLog   20 Feb 2008 15:26:29 -0000      1.5705
@@ -11,6 +11,10 @@
 
 2008-02-20  Rob Savoye  <address@hidden>
 
+       * testsuite/libamf.all/test_lc.cpp: Don't try a bogus test for
+       findListeners() for now. The code works, but the test case is
+       broken.
+
        * configure.ac: Don't build C/asspec/Makefile, it's never been
        used anyway. Use new variables for testing if paths were found.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]