# Path: mozz/test.py
# def run_test_module(name, file):
# 	outputfile = mozz.util.python_path_basename(file) + '.out'
# 
# 	m = sys.modules[name]
# 	ldr = unittest.loader.defaultTestLoader
# 	tests = ldr.loadTestsFromModule(m)
# 
# 	with open(outputfile, 'w') as f:
# 		duper = mozz.util.IOWriteDuplicator(
# 			sys.stderr, f
# 		)
# 		unittest.runner.TextTestRunner(
# 			verbosity = 2,
# 			stream = duper
# 		).run(tests)
# 
# def abs_path(base_file, rel_path):
# 	return os.path.join(
# 		os.path.dirname(os.path.abspath(base_file)),
# 		rel_path
# 	)


import unittest
import sys
import mozz
import mozz.sig
from mozz.test import run_test_module, abs_path

		@s.at_addr(0x400658)
		def main_ret(host):
			d['got_main_ret'] += 1
			self.assertEqual(state[0], 3)
			self.assertEqual(d['got_step'], d['steps_after_write']+10)
			state[0] += 1
			host.inferior().exit_step_mode()
			self.assertFalse(host.inferior().is_in_step_mode())
		
		@s.on_exit()
		def on_exit(host):
			host.log("inferior exited")
			self.assertEqual(state[0], 4)
			self.assertEqual(d['got_step'], d['steps_after_write']+10)
			d['got_on_exit'] += 1
			state[0] += 1
			host.log("asdfoaisjdfoij")

		mozz.run_session(s)

		self.assertEqual(d['got_at_write'], 1)
		self.assertEqual(d['got_after_write'], 1)
		self.assertEqual(state[0], 5)
		self.assertEqual(d['got_step'], d['steps_after_write']+10)
		self.assertEqual(d['got_start'], d['steps_after_write']+10+3)
		self.assertEqual(d['got_sig'], 0)
		self.assertEqual(d['got_on_exit'], 1)
		self.assertEqual(d['got_main_ret'], 1)


# Path: mozz/test.py
# def run_test_module(name, file):
# 	outputfile = mozz.util.python_path_basename(file) + '.out'
# 
# 	m = sys.modules[name]
# 	ldr = unittest.loader.defaultTestLoader
# 	tests = ldr.loadTestsFromModule(m)
# 
# 	with open(outputfile, 'w') as f:
# 		duper = mozz.util.IOWriteDuplicator(
# 			sys.stderr, f
# 		)
# 		unittest.runner.TextTestRunner(
# 			verbosity = 2,
# 			stream = duper
# 		).run(tests)
# 
# def abs_path(base_file, rel_path):
# 	return os.path.join(
# 		os.path.dirname(os.path.abspath(base_file)),
# 		rel_path
# 	)


# Path: test/step_basic_test.py
import unittest
import sys
import mozz
import mozz.sig
from mozz.test import run_test_module, abs_path


		@s.at_addr(0x400658)
		def main_ret(host):
			d['got_main_ret'] += 1
			self.assertEqual(state[0], 3)
			self.assertEqual(d['got_step'], d['steps_after_write']+10)
			state[0] += 1
			host.inferior().exit_step_mode()
			self.assertFalse(host.inferior().is_in_step_mode())
		
		@s.on_exit()
		def on_exit(host):
			host.log("inferior exited")
			self.assertEqual(state[0], 4)
			self.assertEqual(d['got_step'], d['steps_after_write']+10)
			d['got_on_exit'] += 1
			state[0] += 1
			host.log("asdfoaisjdfoij")

		mozz.run_session(s)

		self.assertEqual(d['got_at_write'], 1)
		self.assertEqual(d['got_after_write'], 1)
		self.assertEqual(state[0], 5)
		self.assertEqual(d['got_step'], d['steps_after_write']+10)
		self.assertEqual(d['got_start'], d['steps_after_write']+10+3)
		self.assertEqual(d['got_sig'], 0)
		self.assertEqual(d['got_on_exit'], 1)
		self.assertEqual(d['got_main_ret'], 1)


run_test_module(__name__, __file__)