gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog testsuite/libbase/Makefile.am t...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog testsuite/libbase/Makefile.am t...
Date: Tue, 03 Oct 2006 13:46:00 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/10/03 13:46:00

Modified files:
        .              : ChangeLog 
        testsuite/libbase: Makefile.am NoSeekFileTest.cpp 

Log message:
                * testsuite/libbase/NoSeekFileTest.cpp: fixed test, added test
                  for named cache file.
                * testsuite/libbase/Makefile.am: improved clean rule.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1011&r2=1.1012
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libbase/Makefile.am?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libbase/NoSeekFileTest.cpp?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1011
retrieving revision 1.1012
diff -u -b -r1.1011 -r1.1012
--- ChangeLog   3 Oct 2006 13:33:22 -0000       1.1011
+++ ChangeLog   3 Oct 2006 13:46:00 -0000       1.1012
@@ -1,5 +1,8 @@
 2006-10-03 Sandro Santilli  <address@hidden>
 
+       * testsuite/libbase/NoSeekFileTest.cpp: fixed test, added test
+         for named cache file.
+       * testsuite/libbase/Makefile.am: improved clean rule.
        * libbase/noseek_fd_adapter.cpp: fixed named-cache operation
          (cache file was not opened for read)
 

Index: testsuite/libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libbase/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/libbase/Makefile.am       29 Sep 2006 22:20:46 -0000      1.7
+++ testsuite/libbase/Makefile.am       3 Oct 2006 13:46:00 -0000       1.8
@@ -82,7 +82,8 @@
 
 CLEANFILES =                   \
       testrun.sum              \
-      testrun.log
+      testrun.log             \
+      NoSeekFileTestCache
 
 TESTS = \
        NoSeekFileTest          \

Index: testsuite/libbase/NoSeekFileTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libbase/NoSeekFileTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testsuite/libbase/NoSeekFileTest.cpp        29 Sep 2006 22:20:46 -0000      
1.1
+++ testsuite/libbase/NoSeekFileTest.cpp        3 Oct 2006 13:46:00 -0000       
1.2
@@ -47,6 +47,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <dejagnu.h>
+#include <sstream>
 
 using namespace std;
 
@@ -66,50 +67,96 @@
 
 
 bool 
-compare_reads(tu_file* reader, int fd)
+compare_reads(tu_file* reader, int fd, char* first, char* second)
 {
        char buf[CHUNK_SIZE];
        char buf2[CHUNK_SIZE];
 
-       while (size_t sz1 = reader->read_bytes(buf, CHUNK_SIZE) )
+       stringstream ss;
+
+
+       size_t read_bytes = 0;
+
+       for(;;)
        {
+               size_t sz1 = reader->read_bytes(buf, CHUNK_SIZE);
                size_t sz2 = read(fd, buf2, CHUNK_SIZE);
 
                if ( sz1 != sz2 )
                {
-                       runtest.fail("Different read size from wrapped and raw 
file");
+                       ss << "Different read size from " << first
+                               << " (" << sz1 << ") and " << second
+                               << " (" << sz2 << ") file";
+                       runtest.fail(ss.str());
                        dump_buffer("wrapped", buf, sz1, cout);
                        dump_buffer("raw", buf2, sz2, cout);
                        return false;
                }
+
+               if ( sz1 == 0 ) {
+                       break;
+               }
+
                if ( memcmp(buf, buf2, sz1) )
                {
-                       runtest.fail("Different read content from wrapped and 
raw file");
+                       ss << "Different read content from " << first
+                               << " and " << second << " file";
+                       runtest.fail(ss.str());
                        dump_buffer("wrapped", buf, sz1, cout);
                        dump_buffer("raw", buf2, sz2, cout);
                        return false;
                }
+
+               read_bytes+=sz1;
+       }
+
+       if ( read_bytes == 0 ) 
+       {
+               runtest.fail("No bytes read from either " + string(first) + " 
or " + string(second) + " file");
+               return false;
+       }
+
+       if ( ! reader->get_eof() )
+       {
+               ss << "tu_file not at EOF at end of read";
+               runtest.fail(ss.str());
+               return false;
        }
+
+       ss << "compared " << read_bytes << " bytes from "
+               << first << " and " << second;
+
+       runtest.pass(ss.str());
+       return true;
+
+
        return true;
+
 }
 
 int
 main(int /*argc*/, char** /*argv*/)
 {
        const char* input = INPUT; // Should be the path to this file
+       const char* cachename = "NoSeekFileTestCache";
 
        int fd = open(input, O_RDONLY);
-       int fd2 = open(input, O_RDONLY);
+       int raw = open(input, O_RDONLY);
 
        dup2(fd, 0);
 
-       tu_file* reader = noseek_fd_adapter::make_stream(fileno(stdin));
+       tu_file* reader = noseek_fd_adapter::make_stream(0, cachename);
        assert(reader);
 
-       if ( compare_reads(reader, fd2) )
-       {
-               runtest.pass("Same reads from wrapped and raw file");
-       }
+       compare_reads(reader, raw, "wrapped", "raw");
+
+       lseek(raw, 0, SEEK_SET);
+       reader->set_position(0);
+       compare_reads(reader, raw, "wrapped-rewind", "raw-rewind");
+
+       tu_file orig(cachename, "r");
+       lseek(raw, 0, SEEK_SET);
+       compare_reads(&orig, raw, "cache", "raw");
 
        return 0;
 }




reply via email to

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