Example #1
0
 def test_diff_checker(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples', 'ls.sh')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'ls.sh')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest)
     DiffChecker.DiffChecker.objects.create(task=self.task,
                                            order=0,
                                            shell_script=dest)
     self.solution.check()
Example #2
0
	def test_script_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Power.sh')	
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'Power.sh')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		ScriptChecker.ScriptChecker.objects.create(
					task = self.task,
					order = 0,
					shell_script = dest
					)
		self.solution.check()
Example #3
0
 def test_script_checker(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples', 'Power.sh')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'Power.sh')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest)
     ScriptChecker.ScriptChecker.objects.create(task=self.task,
                                                order=0,
                                                shell_script=dest)
     self.solution.check()
     for checkerresult in self.solution.checkerresult_set.all():
         self.failUnless(checkerresult.passed, checkerresult.log)
Example #4
0
	def test_createfile_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'check style', 'check_ws.xml')	
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'check style', 'createfile.xml')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
					file = dest
					)
		self.solution.check()
Example #5
0
 def test_checkstyle_checker(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples',
                'check style', 'check_ws.xml')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'check style',
                 'check_ws.xml')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest)
     CheckStyleChecker.CheckStyleChecker.objects.create(task=self.task,
                                                        order=0,
                                                        configuration=dest)
     self.solution.check()
Example #6
0
 def test_createfile_illegal_zip_checker(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples',
                'badzipfile.zip')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'badzipfile.zip')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest, binary=True)
     CreateFileChecker.CreateFileChecker.objects.create(task=self.task,
                                                        order=0,
                                                        unpack_zipfile=True,
                                                        file=dest)
     self.assertRaises(InvalidZipFile, self.solution.check)
Example #7
0
	def test_createfile_illegal_zip_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'badzipfile.zip')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'badzipfile.zip')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest, binary=True)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
                                        unpack_zipfile = True,
					file = dest
					)
                self.assertRaises(InvalidZipFile, self.solution.check)
Example #8
0
	def test_checkstyle_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'check style', 'check_ws.xml')	
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'check style', 'check_ws.xml')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		with open(dest) as file:
			CheckStyleChecker.CheckStyleChecker.objects.create(
						task = self.task,
						order = 0,
						configuration = file.read()
						)
		self.solution.check()
Example #9
0
 def test_createfile_checker(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples',
                'check style', 'check_ws.xml')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'check style',
                 'createfile.xml')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest)
     CreateFileChecker.CreateFileChecker.objects.create(task=self.task,
                                                        order=0,
                                                        file=dest)
     self.solution.check()
     for checkerresult in self.solution.checkerresult_set.all():
         self.failUnless(checkerresult.passed, checkerresult.log)
Example #10
0
	def test_createfile_zip_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'simple_zip_file.zip')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'simple_zip_file.zip')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest, binary=True)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
                                        unpack_zipfile = True,
					file = dest
					)
		self.solution.check()
		for checkerresult in self.solution.checkerresult_set.all():
			self.failUnless(checkerresult.passed, checkerresult.log)
Example #11
0
	def test_createfile_zip_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'simple_zip_file.zip')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'simple_zip_file.zip')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest, binary=True)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
                                        unpack_zipfile = True,
					file = dest
					)
		self.solution.check_solution()
		for checkerresult in self.solution.checkerresult_set.all():
			self.failUnless(checkerresult.passed, checkerresult.log)
Example #12
0
	def test_script_memorylimit(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'allocate.pl')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'allocate.pl')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
                with self.settings(TEST_MAXMEM=1):
                    ScriptChecker.ScriptChecker.objects.create(
                                            task = self.task,
                                            order = 0,
                                            shell_script = dest
                                            )
                    self.solution.check()
                    for checkerresult in self.solution.checkerresult_set.all():
                            self.assertIn('Begin', checkerresult.log, "Test did not even start?")
                            self.assertNotIn('End', checkerresult.log, "Test did finish (no timeout?)")
                            self.assertIn('Timeout occured!', checkerresult.log, "Test result does not mention timeout")
                            self.failIf(checkerresult.passed, "Test succeed (no timeout?)")
Example #13
0
	def test_script_memorylimit(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'allocate.pl')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'allocate.pl')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
                with self.settings(TEST_MAXMEM=1):
                    ScriptChecker.ScriptChecker.objects.create(
                                            task = self.task,
                                            order = 0,
                                            shell_script = dest
                                            )
                    self.solution.check_solution()
                    for checkerresult in self.solution.checkerresult_set.all():
                            self.assertIn('Begin', checkerresult.log, "Test did not even start?")
                            self.assertNotIn('End', checkerresult.log, "Test did finish (no timeout?)")
                            self.assertIn('Timeout occured!', checkerresult.log, "Test result does not mention timeout")
                            self.failIf(checkerresult.passed, "Test succeed (no timeout?)")
Example #14
0
 def test_script_timeout(self):
     src = join(dirname(dirname(dirname(__file__))), 'examples', 'loop.sh')
     dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'loop.sh')
     # circumvent SuspiciousOperation exception
     copy_file(src, dest)
     with self.settings(TEST_TIMEOUT=1):
         ScriptChecker.ScriptChecker.objects.create(
             task = self.task,
             order = 0,
             shell_script = dest
         )
         self.solution.check_solution()
         for checkerresult in self.solution.checkerresult_set.all():
             self.assertIn('1', checkerresult.log, "Test did not even start?")
             self.assertIn('Timeout occured!', checkerresult.log, "Test result does not mention timeout")
             self.assertFalse(checkerresult.passed, "Test succeed (no timeout?)")
             self.assertNotIn('done', checkerresult.log, "Test did finish (no timeout?)")
Example #15
0
    def test_c_checker(self):
        src = join(dirname(dirname(dirname(__file__))), 'examples',
                   'Hello World.c')
        dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'Hello World.c')
        # circumvent SuspiciousOperation exception
        copy_file(src, dest)
        CreateFileChecker.CreateFileChecker.objects.create(
            task=self.task,
            order=0,
            file=dest,
        )
        CBuilder.CBuilder.objects.create(
            task=self.task, order=1, _file_pattern=r"^[a-zA-Z0-9_ ]*\.[cC]$")
        self.solution.check_solution()

        # Check if they are all finished, or if one of the dependencies failed.
        for checkerresult in self.solution.checkerresult_set.all():
            self.failUnless(checkerresult.passed, checkerresult.log)
Example #16
0
	def test_createfile_override_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'check style', 'check_ws.xml')	
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'check style', 'createfile.xml')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
					file = dest
					)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 1,
					file = dest
					)
		self.solution.check()
		for checkerresult in self.solution.checkerresult_set.all():
                        if checkerresult.checker.order == 1:
                            self.failIf(checkerresult.passed, checkerresult.log)
Example #17
0
	def test_c_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Hello World.c')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit', 'Hello World.c')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
					file = dest,
					)
		CBuilder.CBuilder.objects.create(
					task = self.task,
					order = 1,
					_file_pattern = r"^[a-zA-Z0-9_ ]*\.[cC]$"
					)
		self.solution.check_solution()

		# Check if they are all finished, or if one of the dependencies failed.
		for checkerresult in self.solution.checkerresult_set.all():
			self.failUnless(checkerresult.passed, checkerresult.log)
Example #18
0
	def test_dejagnu_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'solutions', 'javagently', 'Stream.java')
		dest = join(settings.UPLOAD_ROOT, 'directdeposit',  'javagently', 'Stream.java')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
					file = dest,
					path = "javagently"
					)
		JavaBuilder.JavaBuilder.objects.create(
					task = self.task,
					order = 1,
					_flags = "",
					_output_flags = "",
					_file_pattern = r"^[a-zA-Z0-9_/\\]*\.[jJ][aA][vV][aA]$"
					)
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'DejaGnuTestCases', 'default.exp')	
		test_defs = join(settings.UPLOAD_ROOT, 'directdeposit', 'DejaGnuTestCases', 'default.exp')
		# circumvent SuspiciousOperation exception
		copy_file(src,test_defs)
		DejaGnu.DejaGnuSetup.objects.create(
					task = self.task,
					order = 1,
					test_defs = test_defs
					)
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'DejaGnuTestCases', 'public.exp')
		test_case = join(settings.UPLOAD_ROOT, 'directdeposit', 'DejaGnuTestCases', 'public.exp')
		# circumvent SuspiciousOperation exception
		copy_file(src,test_case)
		DejaGnu.DejaGnuTester.objects.create(
					task = self.task,
					order = 2,
					test_case = test_case
					)

		self.solution.check_solution()

		# Check if they are all finished, or if one of the dependencies failed.
		for checkerresult in self.solution.checkerresult_set.all():
			self.failUnless(checkerresult.passed, checkerresult.log)
Example #19
0
	def test_dejagnu_checker(self):
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'solutions', 'javagently', 'Stream.java')	
		dest = join(settings.UPLOAD_ROOT, 'directdeposit',  'javagently', 'Stream.java')
		# circumvent SuspiciousOperation exception
		copy_file(src,dest)
		CreateFileChecker.CreateFileChecker.objects.create(
					task = self.task,
					order = 0,
					file = dest,
					path = "javagently"
					)
		JavaBuilder.JavaBuilder.objects.create(
					task = self.task,
					order = 0,
					_flags = "",
					_output_flags = "",
					_file_pattern = r"^[a-zA-Z0-9_/\\]*\.[jJ][aA][vV][aA]$"
					)
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'DejaGnuTestCases', 'default.exp')	
		test_defs = join(settings.UPLOAD_ROOT, 'directdeposit', 'DejaGnuTestCases', 'default.exp')
		# circumvent SuspiciousOperation exception
		copy_file(src,test_defs)
		DejaGnu.DejaGnuSetup.objects.create(
					task = self.task,
					order = 1,
					test_defs = test_defs
					)
		src = join(dirname(dirname(dirname(__file__))), 'examples', 'Tasks', 'GGT', 'DejaGnuTestCases', 'public.exp')
		test_case = join(settings.UPLOAD_ROOT, 'directdeposit', 'DejaGnuTestCases', 'public.exp')
		# circumvent SuspiciousOperation exception
		copy_file(src,test_case)
		DejaGnu.DejaGnuTester.objects.create(
					task = self.task,
					order = 2,
					test_case = test_case
					)

		self.solution.check()

		# Check if they are all finished, or if one of the dependencies failed.
		for checkerresult in self.solution.checkerresult_set.all():
			self.failUnless(checkerresult.passed, checkerresult.log)