Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add ability to test stoneridge without modifying source.

This lets us test the harness without running any actual tests. One
fake test is run, and DNS will not actually be updated, when everything
is run as necessary.
  • Loading branch information...
commit b48cf4689f6b9590f90e9d364286f6d40f51fef0 1 parent 8223015
@todesschaf todesschaf authored
Showing with 27 additions and 4 deletions.
  1. +14 −2 srdns.py
  2. +6 −2 stoneridge_runner.py
  3. +7 −0 tests/fake.js
View
16 srdns.py
@@ -21,6 +21,8 @@
rundir = tempfile.mkdtemp()
+nochange = False
+
class BaseDnsModifier(SocketServer.BaseRequestHandler):
"""A class providing an interface for modifying DNS servers on a platform.
"""
@@ -87,7 +89,10 @@ def reset_dns(self):
orig_dns = f.read().strip()
if orig_dns is not None:
- self._set_dns(orig_dns)
+ if nochange:
+ print 'Reset to %s' % (orig_dns,)
+ else:
+ self._set_dns(orig_dns)
def set_dns(self, dnsserver):
# Save the current primary dns server
@@ -104,7 +109,10 @@ def set_dns(self, dnsserver):
f.write('%s\n' % (' '.join(orig_dns),))
# Now set the primary dns server to our new one
- self._set_dns(dnsserver)
+ if nochange:
+ print 'Set to %s' % (dnsserver,)
+ else:
+ self._set_dns(dnsserver)
class LinuxDnsModifier(BaseDnsModifier):
def setup(self):
@@ -176,8 +184,12 @@ def main():
parser.add_argument('--pidfile', dest='pidfile')
parser.add_argument('--log', dest='log')
parser.add_argument('--nodaemon', dest='nodaemon', action='store_true')
+ parser.add_argument('--nochange', dest='nochange', action='store_true')
args = parser.parse_args()
+ global nochange
+ nochange = args.nochange
+
if args.nodaemon:
if args.pidfile:
do_mutex_exit(parser, '--pidfile')
View
8 stoneridge_runner.py
@@ -35,8 +35,12 @@ def _build_testlist(self):
if not self.tests:
logging.debug('searching for all tests in %s' %
(stoneridge.testroot,))
- tests = [os.path.basename(f) for f in
- glob.glob(os.path.join(stoneridge.testroot, '*.js'))]
+ if stoneridge.get_config('test', 'enabled'):
+ tests = ['fake.js']
+ else:
+ tests = [os.path.basename(f) for f in
+ glob.glob(os.path.join(stoneridge.testroot, '*.js'))]
+ tests.remove('fake.js')
logging.debug('tests found %s' % (tests,))
return tests
View
7 tests/fake.js
@@ -0,0 +1,7 @@
+function run_test()
+{
+ startTime = new Date();
+ endTime = new Date(startTime.valueOf() + 100);
+ do_write_result("junk", startTime, endTime);
+ do_test_finish();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.