[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/threadweaver
From:       Mirko Boehm <mirko () kde ! org>
Date:       2006-06-30 20:36:21
Message-ID: 1151699781.603469.860.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 556598 by mirko:

- cleanup in DependencyPolicy
- one test occasionally fails (recursive sequence test)



 M  +4 -5      Tests/JobTests.cpp  
 M  +13 -3     Tests/run-n-tests.py  
 M  +7 -2      Weaver/DependencyPolicy.cpp  
 M  +3 -0      Weaver/DependencyPolicy.h  


--- trunk/kdenonbeta/threadweaver/Tests/JobTests.cpp #556597:556598
@@ -66,7 +66,7 @@
 
     void initTestCase ()
     {
-        ThreadWeaver::setDebugLevel ( true,  4 );
+        ThreadWeaver::setDebugLevel ( true,  1 );
     }
 
     // call finish() before leave a test to make sure the queue is empty
@@ -254,10 +254,9 @@
         QVERIFY ( empty == true );
     }
 
-   /*
 //     This test is not the most efficient, as the mutex locking takes most of
 //     the execution time. Anyway, it will fail if the jobs are not executed
-//     in the right order.
+//     in the right order, and the order is randomized. 
     void MassiveJobSequenceTest() {
         const int NoOfChars = 1024;
         const char* Alphabet = \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -303,6 +302,7 @@
         QCOMPARE ( sequence, QString( "abc" ) );
     }
 
+    /*
     void SequenceOfSequencesTest() {
         QString sequence;
         AppendCharacterJob jobA ( QChar( 'a' ), &sequence, this );
@@ -344,6 +344,7 @@
         ThreadWeaver::Weaver::instance()->finish();
         QCOMPARE ( sequence, QString( "abcdefghij" ) );
     }
+    */
 
     void QueueAndStopTest() {
         QString sequence;
@@ -369,8 +370,6 @@
         QCOMPARE ( sequence, QString( "abcd" ) );
     }
 
-*/
-
 };
 
 QTEST_MAIN ( JobTests )
--- trunk/kdenonbeta/threadweaver/Tests/run-n-tests.py #556597:556598
@@ -8,13 +8,19 @@
 
 def RunTests( Number ):
     # use Linux as the default:
+    SuccessCount = 0
     Platform = platform.platform()
     Command = "LD_LIBRARY_PATH=../Weaver:../Experimental ./JobTests >/dev/null"
     if re.search( "Darwin", Platform ):
         Command = "DYLD_LIBRARY_PATH=../Weaver:../Experimental \
./JobTests.app/Contents/MacOs/JobTests >/dev/null"  for count in range( Number ):
-        print "Test run #", count + 1
-        os.system ( Command)
+	retValue = os.system ( Command)
+	resultString = " (FAILED)"
+	if retValue == 0:
+	    resultString = " (succeeded)"
+            SuccessCount = SuccessCount + 1
+        print "Test run #" + str(count + 1) + resultString
+    return SuccessCount
 
 Number = 10
 
@@ -23,13 +29,17 @@
 except:
     print "No number given, using default of ", Number
 
+FailedCount = 0
+SuccessCount = 0
+
 t1 = time.time()
-RunTests ( Number )
+SuccessCount = RunTests ( Number )
 t2 = time.time()
 
 
 elapsed = ((t2 - t1) / 60.0, t2 - t1, (t2 - t1) * 1000.0)
 
+print "RunTests: " + str(Number) + " test runs (" + str(SuccessCount) + " \
successful, " + str(Number - SuccessCount) + " failed)"  print "RunTests: %0.3fms \
(%0.3fs)" % ( elapsed[2], elapsed[1] )  print "Averages: %0.3fms per test run \
(%0.3fs)" % ( elapsed[2] / Number, elapsed[1] / Number )  
--- trunk/kdenonbeta/threadweaver/Weaver/DependencyPolicy.cpp #556597:556598
@@ -7,7 +7,7 @@
 
 using namespace ThreadWeaver;
 
-class JobMultiMap : public QMultiMap<Job*, Job*> {};
+typedef QMultiMap<Job*, Job*> JobMultiMap;
 
 class DependencyPolicy::Private
 {
@@ -36,6 +36,11 @@
 {
 }
 
+DependencyPolicy::~DependencyPolicy()
+{
+  delete d;
+}
+
 void DependencyPolicy::addDependency( Job* jobA, Job* jobB )
 {   // jobA depends on jobB
     jobA->assignQueuePolicy( this );
@@ -83,8 +88,8 @@
 QList<Job*> DependencyPolicy::getDependencies( Job* job ) const
 {
     QList<Job*> result;
+    JobMultiMap::const_iterator it;
     QMutexLocker l( & d->mutex() );
-    JobMultiMap::const_iterator it;
 
     for ( it = d->dependencies().begin(); it != d->dependencies().end(); ++it )
     {
--- trunk/kdenonbeta/threadweaver/Weaver/DependencyPolicy.h #556597:556598
@@ -8,6 +8,9 @@
     class DependencyPolicy : public QueuePolicy
     {
     public:
+      /** Destructor. */
+      ~DependencyPolicy();
+
         /** Add jobA as a dependency of jobB.
             jobA will only be executed after jobB has been successfully processed.
             @param jobA the depending job


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic