[Scummvm-cvs-logs] SF.net SVN: scummvm:[50444] scummvm/branches/gsoc2010-testbed/engines/ testbed
sud03r at users.sourceforge.net
sud03r at users.sourceforge.net
Mon Jun 28 14:58:14 CEST 2010
Revision: 50444
http://scummvm.svn.sourceforge.net/scummvm/?rev=50444&view=rev
Author: sud03r
Date: 2010-06-28 12:58:14 +0000 (Mon, 28 Jun 2010)
Log Message:
-----------
added code to test timers and mutexes, some issues with mutexes present although
Modified Paths:
--------------
scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h
scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp 2010-06-28 12:55:47 UTC (rev 50443)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp 2010-06-28 12:58:14 UTC (rev 50444)
@@ -23,6 +23,7 @@
*/
#include "testbed/misc.h"
+#include "common/timer.h"
namespace Testbed {
@@ -34,6 +35,25 @@
return;
}
+void MiscTests::timerCallback(void *arg) {
+ // Increment arg which actually points to an int
+ // arg must point to a static data, threads otherwise have their own stack
+ int &ptrToNumTimesExecuted = *((int *) arg);
+ ptrToNumTimesExecuted++;
+ printf("LOG: Inside the timed process!\n");
+}
+
+void MiscTests::criticalSection(void *arg) {
+ SharedVars &sv = *((SharedVars *) arg);
+
+ printf("Before: %d %d\n", sv.first, sv.second);
+ sv.first++;
+ g_system->delayMillis(3000);
+ printf("After waking up: %d %d\n", sv.first, sv.second);
+ sv.second *= sv.first;
+ printf("Finally: %d %d\n", sv.first, sv.second);
+}
+
bool MiscTests::testDateTime() {
TimeDate t1, t2;
g_system->getTimeAndDate(t1);
@@ -70,16 +90,33 @@
}
bool MiscTests::testTimers() {
- return true;
+ static int numTimesExecuted = 0;
+ if (g_system->getTimerManager()->installTimerProc(timerCallback, 100000, &numTimesExecuted)) {
+ g_system->delayMillis(150);
+ printf("LOG: Timed Process Invoked %d times\n", numTimesExecuted);
+ g_system->getTimerManager()->removeTimerProc(timerCallback);
+
+ if (1 == numTimesExecuted) {
+ return true;
+ }
+ }
+ return false;
}
bool MiscTests::testMutexes() {
- return true;
+ static SharedVars sv = {1, 1, g_system->createMutex()};
+
+ if (g_system->getTimerManager()->installTimerProc(criticalSection, 100000, &sv)) {
+ g_system->delayMillis(150);
+ criticalSection(&sv);
+ g_system->getTimerManager()->removeTimerProc(criticalSection);
+ }
+ return false;
}
MiscTestSuite::MiscTestSuite() {
- addTest("Date/time", &MiscTests::testDateTime);
- addTest("Timers", &MiscTests::testTimers);
+ // addTest("Date/time", &MiscTests::testDateTime);
+ // addTest("Timers", &MiscTests::testTimers);
addTest("Mutexes", &MiscTests::testMutexes);
}
const char *MiscTestSuite::getName() const {
Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h 2010-06-28 12:55:47 UTC (rev 50443)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/misc.h 2010-06-28 12:58:14 UTC (rev 50444)
@@ -30,12 +30,21 @@
namespace Testbed {
+// Shared variables used in mutex handling test
+struct SharedVars {
+ int first;
+ int second;
+ OSystem::MutexRef mutex;
+};
+
namespace MiscTests {
// Miscellaneous tests include testing datetime, timers and mutexes
// Helper functions for Misc tests
void getHumanReadableFormat(TimeDate &td, Common::String &date);
+void timerCallback(void *arg);
+void criticalSection(void *arg);
// will contain function declarations for Misc tests
bool testDateTime();
Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp 2010-06-28 12:55:47 UTC (rev 50443)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp 2010-06-28 12:58:14 UTC (rev 50444)
@@ -88,7 +88,7 @@
// To be set from config file
// By default Interactive tests are enabled
// XXX: disabling these as of now for fastly testing other tests
- // Testsuite::isInteractive = false;
+ Testsuite::isInteractive = false;
if (Testsuite::isInteractive) {
printf("Running Interactive tests as well\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list