From: <Or...@us...> - 2008-06-17 08:54:04
|
Revision: 259 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=259&view=rev Author: Oracle_ Date: 2008-06-17 01:54:04 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Added Paths: ----------- ACMServer/trunk/sharp tester/README.txt ACMServer/trunk/sharp tester/conf/ ACMServer/trunk/sharp tester/conf/authz ACMServer/trunk/sharp tester/conf/passwd ACMServer/trunk/sharp tester/conf/svnserve.conf ACMServer/trunk/sharp tester/dav/ ACMServer/trunk/sharp tester/db/ ACMServer/trunk/sharp tester/db/current ACMServer/trunk/sharp tester/db/format ACMServer/trunk/sharp tester/db/fs-type ACMServer/trunk/sharp tester/db/revprops/ ACMServer/trunk/sharp tester/db/revprops/0 ACMServer/trunk/sharp tester/db/revs/ ACMServer/trunk/sharp tester/db/revs/0 ACMServer/trunk/sharp tester/db/transactions/ ACMServer/trunk/sharp tester/db/uuid ACMServer/trunk/sharp tester/db/write-lock ACMServer/trunk/sharp tester/format ACMServer/trunk/sharp tester/hooks/ ACMServer/trunk/sharp tester/hooks/post-commit.tmpl ACMServer/trunk/sharp tester/hooks/post-lock.tmpl ACMServer/trunk/sharp tester/hooks/post-revprop-change.tmpl ACMServer/trunk/sharp tester/hooks/post-unlock.tmpl ACMServer/trunk/sharp tester/hooks/pre-commit.tmpl ACMServer/trunk/sharp tester/hooks/pre-lock.tmpl ACMServer/trunk/sharp tester/hooks/pre-revprop-change.tmpl ACMServer/trunk/sharp tester/hooks/pre-unlock.tmpl ACMServer/trunk/sharp tester/hooks/start-commit.tmpl ACMServer/trunk/sharp tester/locks/ ACMServer/trunk/sharp tester/locks/db-logs.lock ACMServer/trunk/sharp tester/locks/db.lock Added: ACMServer/trunk/sharp tester/README.txt =================================================================== --- ACMServer/trunk/sharp tester/README.txt (rev 0) +++ ACMServer/trunk/sharp tester/README.txt 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,5 @@ +This is a Subversion repository; use the 'svnadmin' tool to examine +it. Do not add, delete, or modify files here unless you know how +to avoid corrupting the repository. + +Visit http://subversion.tigris.org/ for more information. Added: ACMServer/trunk/sharp tester/conf/authz =================================================================== --- ACMServer/trunk/sharp tester/conf/authz (rev 0) +++ ACMServer/trunk/sharp tester/conf/authz 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,21 @@ +### This file is an example authorization file for svnserve. +### Its format is identical to that of mod_authz_svn authorization +### files. +### As shown below each section defines authorizations for the path and +### (optional) repository specified by the section name. +### The authorizations follow. An authorization line can refer to a +### single user, to a group of users defined in a special [groups] +### section, or to anyone using the '*' wildcard. Each definition can +### grant read ('r') access, read-write ('rw') access, or no access +### (''). + +[groups] +# harry_and_sally = harry,sally + +# [/foo/bar] +# harry = rw +# * = + +# [repository:/baz/fuz] +# @harry_and_sally = rw +# * = r Added: ACMServer/trunk/sharp tester/conf/passwd =================================================================== --- ACMServer/trunk/sharp tester/conf/passwd (rev 0) +++ ACMServer/trunk/sharp tester/conf/passwd 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,8 @@ +### This file is an example password file for svnserve. +### Its format is similar to that of svnserve.conf. As shown in the +### example below it contains one section labelled [users]. +### The name and password for each user follow, one account per line. + +[users] +# harry = harryssecret +# sally = sallyssecret Added: ACMServer/trunk/sharp tester/conf/svnserve.conf =================================================================== --- ACMServer/trunk/sharp tester/conf/svnserve.conf (rev 0) +++ ACMServer/trunk/sharp tester/conf/svnserve.conf 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,30 @@ +### This file controls the configuration of the svnserve daemon, if you +### use it to allow access to this repository. (If you only allow +### access through http: and/or file: URLs, then this file is +### irrelevant.) + +### Visit http://subversion.tigris.org/ for more information. + +[general] +### These options control access to the repository for unauthenticated +### and authenticated users. Valid values are "write", "read", +### and "none". The sample settings below are the defaults. +# anon-access = read +# auth-access = write +### The password-db option controls the location of the password +### database file. Unless you specify a path starting with a /, +### the file's location is relative to the conf directory. +### Uncomment the line below to use the default password file. +# password-db = passwd +### The authz-db option controls the location of the authorization +### rules for path-based access control. Unless you specify a path +### starting with a /, the file's location is relative to the conf +### directory. If you don't specify an authz-db, no path-based access +### control is done. +### Uncomment the line below to use the default authorization file. +# authz-db = authz +### This option specifies the authentication realm of the repository. +### If two repositories have the same authentication realm, they should +### have the same password database, and vice versa. The default realm +### is repository's uuid. +# realm = My First Repository Added: ACMServer/trunk/sharp tester/db/current =================================================================== --- ACMServer/trunk/sharp tester/db/current (rev 0) +++ ACMServer/trunk/sharp tester/db/current 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1 @@ +0 1 1 Added: ACMServer/trunk/sharp tester/db/format =================================================================== --- ACMServer/trunk/sharp tester/db/format (rev 0) +++ ACMServer/trunk/sharp tester/db/format 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1 @@ +2 Added: ACMServer/trunk/sharp tester/db/fs-type =================================================================== --- ACMServer/trunk/sharp tester/db/fs-type (rev 0) +++ ACMServer/trunk/sharp tester/db/fs-type 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1 @@ +fsfs Added: ACMServer/trunk/sharp tester/db/revprops/0 =================================================================== --- ACMServer/trunk/sharp tester/db/revprops/0 (rev 0) +++ ACMServer/trunk/sharp tester/db/revprops/0 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,5 @@ +K 8 +svn:date +V 27 +2008-06-17T08:50:56.245210Z +END Added: ACMServer/trunk/sharp tester/db/revs/0 =================================================================== --- ACMServer/trunk/sharp tester/db/revs/0 (rev 0) +++ ACMServer/trunk/sharp tester/db/revs/0 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,11 @@ +PLAIN +END +ENDREP +id: 0.0.r0/17 +type: dir +count: 0 +text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e +cpath: / + + +17 107 Added: ACMServer/trunk/sharp tester/db/uuid =================================================================== --- ACMServer/trunk/sharp tester/db/uuid (rev 0) +++ ACMServer/trunk/sharp tester/db/uuid 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1 @@ +56c9e931-6168-524c-8140-b5feaaaad175 Added: ACMServer/trunk/sharp tester/db/write-lock =================================================================== Added: ACMServer/trunk/sharp tester/format =================================================================== --- ACMServer/trunk/sharp tester/format (rev 0) +++ ACMServer/trunk/sharp tester/format 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1 @@ +5 Added: ACMServer/trunk/sharp tester/hooks/post-commit.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/post-commit.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/post-commit.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,51 @@ +#!/bin/sh + +# POST-COMMIT HOOK +# +# The post-commit hook is invoked after a commit. Subversion runs +# this hook by invoking a program (script, executable, binary, etc.) +# named 'post-commit' (for which this file is a template) with the +# following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] REV (the number of the revision just committed) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# Because the commit has already completed and cannot be undone, +# the exit code of the hook program is ignored. The hook program +# can use the 'svnlook' utility to help it examine the +# newly-committed tree. +# +# On a Unix system, the normal procedure is to have 'post-commit' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'post-commit' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'post-commit.bat' or 'post-commit.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +REV="$2" + +commit-email.pl "$REPOS" "$REV" com...@ex... +log-commit.py --repository "$REPOS" --revision "$REV" Added: ACMServer/trunk/sharp tester/hooks/post-lock.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/post-lock.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/post-lock.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,44 @@ +#!/bin/sh + +# POST-LOCK HOOK +# +# The post-lock hook is run after a path is locked. Subversion runs +# this hook by invoking a program (script, executable, binary, etc.) +# named 'post-lock' (for which this file is a template) with the +# following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] USER (the user who created the lock) +# +# The paths that were just locked are passed to the hook via STDIN (as +# of Subversion 1.2, only one path is passed per invocation, but the +# plan is to pass all locked paths at once, so the hook program +# should be written accordingly). +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# Because the lock has already been created and cannot be undone, +# the exit code of the hook program is ignored. The hook program +# can use the 'svnlook' utility to help it examine the +# newly-created lock. +# +# On a Unix system, the normal procedure is to have 'post-lock' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'post-lock' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'post-lock.bat' or 'post-lock.exe', +# but the basic idea is the same. +# +# Here is an example hook script, for a Unix /bin/sh interpreter: + +REPOS="$1" +USER="$2" + +# Send email to interested parties, let them know a lock was created: +mailer.py lock "$REPOS" "$USER" /path/to/mailer.conf Added: ACMServer/trunk/sharp tester/hooks/post-revprop-change.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/post-revprop-change.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/post-revprop-change.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,56 @@ +#!/bin/sh + +# POST-REVPROP-CHANGE HOOK +# +# The post-revprop-change hook is invoked after a revision property +# has been added, modified or deleted. Subversion runs this hook by +# invoking a program (script, executable, binary, etc.) named +# 'post-revprop-change' (for which this file is a template), with the +# following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] REV (the revision that was tweaked) +# [3] USER (the username of the person tweaking the property) +# [4] PROPNAME (the property that was changed) +# [5] ACTION (the property was 'A'dded, 'M'odified, or 'D'eleted) +# +# [STDIN] PROPVAL ** the old property value is passed via STDIN. +# +# Because the propchange has already completed and cannot be undone, +# the exit code of the hook program is ignored. The hook program +# can use the 'svnlook' utility to help it examine the +# new property value. +# +# On a Unix system, the normal procedure is to have 'post-revprop-change' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'post-revprop-change' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'post-revprop-change.bat' or 'post-revprop-change.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +REV="$2" +USER="$3" +PROPNAME="$4" +ACTION="$5" + +propchange-email.pl "$REPOS" "$REV" "$USER" "$PROPNAME" wat...@ex... Added: ACMServer/trunk/sharp tester/hooks/post-unlock.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/post-unlock.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/post-unlock.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,42 @@ +#!/bin/sh + +# POST-UNLOCK HOOK +# +# The post-unlock hook runs after a path is unlocked. Subversion runs +# this hook by invoking a program (script, executable, binary, etc.) +# named 'post-unlock' (for which this file is a template) with the +# following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] USER (the user who destroyed the lock) +# +# The paths that were just unlocked are passed to the hook via STDIN +# (as of Subversion 1.2, only one path is passed per invocation, but +# the plan is to pass all unlocked paths at once, so the hook program +# should be written accordingly). +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# Because the lock has already been destroyed and cannot be undone, +# the exit code of the hook program is ignored. +# +# On a Unix system, the normal procedure is to have 'post-unlock' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'post-unlock' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'post-unlock.bat' or 'post-unlock.exe', +# but the basic idea is the same. +# +# Here is an example hook script, for a Unix /bin/sh interpreter: + +REPOS="$1" +USER="$2" + +# Send email to interested parties, let them know a lock was removed: +mailer.py unlock "$REPOS" "$USER" /path/to/mailer.conf Added: ACMServer/trunk/sharp tester/hooks/pre-commit.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/pre-commit.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/pre-commit.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,70 @@ +#!/bin/sh + +# PRE-COMMIT HOOK +# +# The pre-commit hook is invoked before a Subversion txn is +# committed. Subversion runs this hook by invoking a program +# (script, executable, binary, etc.) named 'pre-commit' (for which +# this file is a template), with the following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] TXN-NAME (the name of the txn about to be committed) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# If the hook program exits with success, the txn is committed; but +# if it exits with failure (non-zero), the txn is aborted, no commit +# takes place, and STDERR is returned to the client. The hook +# program can use the 'svnlook' utility to help it examine the txn. +# +# On a Unix system, the normal procedure is to have 'pre-commit' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT *** +# *** FOR REVISION PROPERTIES (like svn:log or svn:author). *** +# +# This is why we recommend using the read-only 'svnlook' utility. +# In the future, Subversion may enforce the rule that pre-commit +# hooks should not modify the versioned data in txns, or else come +# up with a mechanism to make it safe to do so (by informing the +# committing client of the changes). However, right now neither +# mechanism is implemented, so hook writers just have to be careful. +# +# Note that 'pre-commit' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'pre-commit.bat' or 'pre-commit.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +TXN="$2" + +# Make sure that the log message contains some text. +SVNLOOK=/usr/local/bin/svnlook +$SVNLOOK log -t "$TXN" "$REPOS" | \ + grep "[a-zA-Z0-9]" > /dev/null || exit 1 + +# Check that the author of this commit has the rights to perform +# the commit on the files and directories being modified. +commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1 + +# All checks passed, so allow the commit. +exit 0 Added: ACMServer/trunk/sharp tester/hooks/pre-lock.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/pre-lock.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/pre-lock.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,64 @@ +#!/bin/sh + +# PRE-LOCK HOOK +# +# The pre-lock hook is invoked before an exclusive lock is +# created. Subversion runs this hook by invoking a program +# (script, executable, binary, etc.) named 'pre-lock' (for which +# this file is a template), with the following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] PATH (the path in the repository about to be locked) +# [3] USER (the user creating the lock) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# If the hook program exits with success, the lock is created; but +# if it exits with failure (non-zero), the lock action is aborted +# and STDERR is returned to the client. + +# On a Unix system, the normal procedure is to have 'pre-lock' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'pre-lock' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'pre-lock.bat' or 'pre-lock.exe', +# but the basic idea is the same. +# +# Here is an example hook script, for a Unix /bin/sh interpreter: + +REPOS="$1" +PATH="$2" +USER="$3" + +# If a lock exists and is owned by a different person, don't allow it +# to be stolen (e.g., with 'svn lock --force ...'). + +# (Maybe this script could send email to the lock owner?) +SVNLOOK=/usr/local/bin/svnlook +GREP=/bin/grep +SED=/bin/sed + +LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \ + $GREP '^Owner: ' | $SED 's/Owner: //'` + +# If we get no result from svnlook, there's no lock, allow the lock to +# happen: +if [ "$LOCK_OWNER" = "" ]; then + exit 0 +fi + +# If the person locking matches the lock's owner, allow the lock to +# happen: +if [ "$LOCK_OWNER" = "$USER" ]; then + exit 0 +fi + +# Otherwise, we've got an owner mismatch, so return failure: +echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2 +exit 1 Added: ACMServer/trunk/sharp tester/hooks/pre-revprop-change.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/pre-revprop-change.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/pre-revprop-change.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,66 @@ +#!/bin/sh + +# PRE-REVPROP-CHANGE HOOK +# +# The pre-revprop-change hook is invoked before a revision property +# is added, modified or deleted. Subversion runs this hook by invoking +# a program (script, executable, binary, etc.) named 'pre-revprop-change' +# (for which this file is a template), with the following ordered +# arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] REVISION (the revision being tweaked) +# [3] USER (the username of the person tweaking the property) +# [4] PROPNAME (the property being set on the revision) +# [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted) +# +# [STDIN] PROPVAL ** the new property value is passed via STDIN. +# +# If the hook program exits with success, the propchange happens; but +# if it exits with failure (non-zero), the propchange doesn't happen. +# The hook program can use the 'svnlook' utility to examine the +# existing value of the revision property. +# +# WARNING: unlike other hooks, this hook MUST exist for revision +# properties to be changed. If the hook does not exist, Subversion +# will behave as if the hook were present, but failed. The reason +# for this is that revision properties are UNVERSIONED, meaning that +# a successful propchange is destructive; the old value is gone +# forever. We recommend the hook back up the old value somewhere. +# +# On a Unix system, the normal procedure is to have 'pre-revprop-change' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'pre-revprop-change' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'pre-revprop-change.bat' or 'pre-revprop-change.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +REV="$2" +USER="$3" +PROPNAME="$4" +ACTION="$5" + +if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi + +echo "Changing revision properties other than svn:log is prohibited" >&2 +exit 1 Added: ACMServer/trunk/sharp tester/hooks/pre-unlock.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/pre-unlock.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/pre-unlock.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,60 @@ +#!/bin/sh + +# PRE-UNLOCK HOOK +# +# The pre-unlock hook is invoked before an exclusive lock is +# destroyed. Subversion runs this hook by invoking a program +# (script, executable, binary, etc.) named 'pre-unlock' (for which +# this file is a template), with the following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] PATH (the path in the repository about to be unlocked) +# [3] USER (the user destroying the lock) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# If the hook program exits with success, the lock is destroyed; but +# if it exits with failure (non-zero), the unlock action is aborted +# and STDERR is returned to the client. + +# On a Unix system, the normal procedure is to have 'pre-unlock' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'pre-unlock' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'pre-unlock.bat' or 'pre-unlock.exe', +# but the basic idea is the same. +# +# Here is an example hook script, for a Unix /bin/sh interpreter: + +REPOS="$1" +PATH="$2" +USER="$3" + +# If a lock is owned by a different person, don't allow it be broken. +# (Maybe this script could send email to the lock owner?) + +SVNLOOK=/usr/local/bin/svnlook +GREP=/bin/grep +SED=/bin/sed + +LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \ + $GREP '^Owner: ' | $SED 's/Owner: //'` + +# If we get no result from svnlook, there's no lock, return success: +if [ "$LOCK_OWNER" = "" ]; then + exit 0 +fi +# If the person unlocking matches the lock's owner, return success: +if [ "$LOCK_OWNER" = "$USER" ]; then + exit 0 +fi + +# Otherwise, we've got an owner mismatch, so return failure: +echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2 +exit 1 Added: ACMServer/trunk/sharp tester/hooks/start-commit.tmpl =================================================================== --- ACMServer/trunk/sharp tester/hooks/start-commit.tmpl (rev 0) +++ ACMServer/trunk/sharp tester/hooks/start-commit.tmpl 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,54 @@ +#!/bin/sh + +# START-COMMIT HOOK +# +# The start-commit hook is invoked before a Subversion txn is created +# in the process of doing a commit. Subversion runs this hook +# by invoking a program (script, executable, binary, etc.) named +# 'start-commit' (for which this file is a template) +# with the following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] USER (the authenticated user attempting to commit) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# If the hook program exits with success, the commit continues; but +# if it exits with failure (non-zero), the commit is stopped before +# a Subversion txn is created, and STDERR is returned to the client. +# +# On a Unix system, the normal procedure is to have 'start-commit' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'start-commit' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'start-commit.bat' or 'start-commit.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +USER="$2" + +commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1 +special-auth-check.py --user "$USER" --auth-level 3 || exit 1 + +# All checks passed, so allow the commit. +exit 0 Added: ACMServer/trunk/sharp tester/locks/db-logs.lock =================================================================== --- ACMServer/trunk/sharp tester/locks/db-logs.lock (rev 0) +++ ACMServer/trunk/sharp tester/locks/db-logs.lock 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,3 @@ +This file is not used by Subversion 1.3.x or later. +However, its existence is required for compatibility with +Subversion 1.2.x or earlier. Added: ACMServer/trunk/sharp tester/locks/db.lock =================================================================== --- ACMServer/trunk/sharp tester/locks/db.lock (rev 0) +++ ACMServer/trunk/sharp tester/locks/db.lock 2008-06-17 08:54:04 UTC (rev 259) @@ -0,0 +1,3 @@ +This file is not used by Subversion 1.3.x or later. +However, its existence is required for compatibility with +Subversion 1.2.x or earlier. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-17 09:00:23
|
Revision: 260 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=260&view=rev Author: Oracle_ Date: 2008-06-17 02:00:16 -0700 (Tue, 17 Jun 2008) Log Message: ----------- ?\208?\163?\208?\180?\208?\176?\208?\187?\208?\181?\208?\189(?\208?\176) ?\209?\132?\208?\176?\208?\185?\208?\187/?\208?\191?\208?\176?\208?\191?\208?\186?\208?\176 Removed Paths: ------------- ACMServer/trunk/sharp tester/conf/ ACMServer/trunk/sharp tester/dav/ ACMServer/trunk/sharp tester/db/ ACMServer/trunk/sharp tester/hooks/ ACMServer/trunk/sharp tester/locks/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-17 09:02:16
|
Revision: 261 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=261&view=rev Author: Oracle_ Date: 2008-06-17 02:02:14 -0700 (Tue, 17 Jun 2008) Log Message: ----------- ?\208?\163?\208?\180?\208?\176?\208?\187?\208?\181?\208?\189(?\208?\176) ?\209?\132?\208?\176?\208?\185?\208?\187/?\208?\191?\208?\176?\208?\191?\208?\186?\208?\176 Removed Paths: ------------- ACMServer/trunk/sharp tester/README.txt ACMServer/trunk/sharp tester/format Deleted: ACMServer/trunk/sharp tester/README.txt =================================================================== --- ACMServer/trunk/sharp tester/README.txt 2008-06-17 09:00:16 UTC (rev 260) +++ ACMServer/trunk/sharp tester/README.txt 2008-06-17 09:02:14 UTC (rev 261) @@ -1,5 +0,0 @@ -This is a Subversion repository; use the 'svnadmin' tool to examine -it. Do not add, delete, or modify files here unless you know how -to avoid corrupting the repository. - -Visit http://subversion.tigris.org/ for more information. Deleted: ACMServer/trunk/sharp tester/format =================================================================== --- ACMServer/trunk/sharp tester/format 2008-06-17 09:00:16 UTC (rev 260) +++ ACMServer/trunk/sharp tester/format 2008-06-17 09:02:14 UTC (rev 261) @@ -1 +0,0 @@ -5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-17 15:38:16
|
Revision: 262 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=262&view=rev Author: Oracle_ Date: 2008-06-17 08:36:50 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Fixed bug with RealTime limit. Modified Paths: -------------- ACMServer/trunk/sharp tester/ReadMe.txt ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp Modified: ACMServer/trunk/sharp tester/ReadMe.txt =================================================================== --- ACMServer/trunk/sharp tester/ReadMe.txt 2008-06-17 09:02:14 UTC (rev 261) +++ ACMServer/trunk/sharp tester/ReadMe.txt 2008-06-17 15:36:50 UTC (rev 262) @@ -12,7 +12,9 @@ 3. \xD3 \xEF\xE0\xEF\xEA\xF3 SAMPLE \xE4\xEE\xE4\xE0\xF2\xE8 \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF2\xEE\xF0 Delphi, \xE0 \xF3 \xEF\xE0\xEF\xEA\xF3 includeD7 \xE4\xEE\xE4\xE0\xF2\xE8 \xED\xE5\xEE\xE1\xF5\xB3\xE4\xED\xB3 \xE4\xEB\xFF \xF0\xEE\xE1\xEE\xF2\xE8 \xEC\xEE\xE4\xF3\xEB\xB3. 4. \xC4\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xF2\xF0\xB3\xE1\xE5\xED .NET Framework 2.0 \xE0\xE1\xEE \xE2\xE8\xF9\xE5. -5. ϳ\xF1\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xEC\xB3\xF1\xF2\xB3\xF2\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xF3 tester.exe \xF4\xE0\xE9\xEB TestLibrary.dll i +5. \xC4\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF TestLibrary \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE4\xEE \xEF\xF0\xEE\xE5\xEA\xF2\xF3 \xE4\xEE\xE4\xE0\xF2\xE8 *.def \xF4\xE0\xE9\xEB \xB3 + \xE2\xE2\xE5\xF1\xF2\xE8 \xE9\xEE\xE3\xEE \xE2 \xEE\xEF\xF6\xB3\xFF\xF5 \xEF\xF0\xEE\xE5\xEA\xF2\xF3. +6. ϳ\xF1\xEB\xFF \xEA\xEE\xEC\xEF\xB3\xEB\xFF\xF6\xB3\xBF \xEF\xEE\xEC\xB3\xF1\xF2\xB3\xF2\xFC \xE4\xEE \xF4\xE0\xE9\xEB\xF3 tester.exe \xF4\xE0\xE9\xEB TestLibrary.dll i SourceTest.dll //////////////////////////////////////////////////////////////////////// ///////////////////////\xC7\xC0\xCF\xD3\xD1\xCA \xB2 \xC2\xC8\xCA\xCE\xCD\xC0\xCD\xCD\xDF/////////////////////////////// Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-17 09:02:14 UTC (rev 261) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-17 15:36:50 UTC (rev 262) @@ -1,7 +1,6 @@ // This is the main DLL file. #include "stdafx.h" -//#define _WIN32_WINNT 0x0500 #include <stdio.h> #include "SourceTest.h" #include <LM.h> @@ -349,23 +348,6 @@ } } -BOOL DelPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //deletes privilege from process token -{ -TOKEN_PRIVILEGES tp; -LUID luid; -if (!LookupPrivilegeValue( NULL,lpszPrivilege,&luid)) - return FALSE; -tp.PrivilegeCount = 1; -tp.Privileges[0].Luid = luid; -tp.Privileges[0].Attributes = SE_PRIVILEGE_REMOVED; - -if ( !AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),(PTOKEN_PRIVILEGES) NULL,(PDWORD) NULL) ) - return FALSE; -if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) - return FALSE; -return TRUE; -} - BOOL AddPrivilege(HANDLE hToken,LPCTSTR lpszPrivilege) //adds privilege to process token { TOKEN_PRIVILEGES tp; @@ -383,53 +365,6 @@ return TRUE; } -void DeletePrivileges(HANDLE proc) //deletes all privileges from process token -{ - HANDLE hToken; - try - { - OpenProcessToken(proc,TOKEN_ALL_ACCESS,&hToken); - DelPrivilege(hToken,SE_ASSIGNPRIMARYTOKEN_NAME); - DelPrivilege(hToken,SE_AUDIT_NAME); - DelPrivilege(hToken,SE_BACKUP_NAME); - DelPrivilege(hToken,SE_CHANGE_NOTIFY_NAME); - DelPrivilege(hToken,SE_CREATE_GLOBAL_NAME); - DelPrivilege(hToken,SE_CREATE_PAGEFILE_NAME); - DelPrivilege(hToken,SE_CREATE_PERMANENT_NAME); - DelPrivilege(hToken,SE_CREATE_SYMBOLIC_LINK_NAME); - DelPrivilege(hToken,SE_CREATE_TOKEN_NAME); - DelPrivilege(hToken,SE_DEBUG_NAME); - DelPrivilege(hToken,SE_ENABLE_DELEGATION_NAME); - DelPrivilege(hToken,SE_IMPERSONATE_NAME); - DelPrivilege(hToken,SE_INC_BASE_PRIORITY_NAME); - DelPrivilege(hToken,SE_INCREASE_QUOTA_NAME); - DelPrivilege(hToken,SE_INC_WORKING_SET_NAME); - DelPrivilege(hToken,SE_LOAD_DRIVER_NAME); - DelPrivilege(hToken,SE_LOCK_MEMORY_NAME); - DelPrivilege(hToken,SE_MACHINE_ACCOUNT_NAME); - DelPrivilege(hToken,SE_MANAGE_VOLUME_NAME); - DelPrivilege(hToken,SE_PROF_SINGLE_PROCESS_NAME); - DelPrivilege(hToken,SE_RELABEL_NAME); - DelPrivilege(hToken,SE_REMOTE_SHUTDOWN_NAME); - DelPrivilege(hToken,SE_RESTORE_NAME); - DelPrivilege(hToken,SE_SECURITY_NAME); - DelPrivilege(hToken,SE_SHUTDOWN_NAME); - DelPrivilege(hToken,SE_SYNC_AGENT_NAME); - DelPrivilege(hToken,SE_SYSTEM_ENVIRONMENT_NAME); - DelPrivilege(hToken,SE_SYSTEM_PROFILE_NAME); - DelPrivilege(hToken,SE_SYSTEMTIME_NAME); - DelPrivilege(hToken,SE_TAKE_OWNERSHIP_NAME); - DelPrivilege(hToken,SE_TCB_NAME); - DelPrivilege(hToken,SE_TIME_ZONE_NAME); - DelPrivilege(hToken,SE_TRUSTED_CREDMAN_ACCESS_NAME); - DelPrivilege(hToken,SE_UNDOCK_NAME); - DelPrivilege(hToken,SE_UNSOLICITED_INPUT_NAME); - }__finally - { - CloseHandle(hToken); - } -} - void TSource::RunTest(int index) //runs one test { PROCESS_INFORMATION pi;ZeroMemory(&pi,sizeof(pi)); @@ -496,20 +431,17 @@ mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; mem.ProcessMemoryLimit=FLim.MemoryLimit; SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); - port.CompletionKey=(void*)123; port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); - SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); uilim.UIRestrictionsClass=JOB_OBJECT_UILIMIT_ALL; SetInformationJobObject(job,JobObjectBasicUIRestrictions,&uilim,sizeof(uilim)); - - DeletePrivileges(pi.hProcess); + AssignProcessToJobObject(job,pi.hProcess); + ResumeThread(pi.hThread); DWORD start=GetTickCount(); - while (true) { if ((int)GetFileSize(si.hStdOutput,NULL)>FLim.OutputLimit) @@ -558,10 +490,11 @@ unsigned long len,key; HANDLE proc; - if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&key == 123) + if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)) { DWORD code=0; bool needbreak=false; + if (key==123) switch(len) { case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: @@ -604,7 +537,6 @@ break; } } - Sleep(1); } CloseHandle(si.hStdOutput); @@ -664,13 +596,13 @@ }__finally { - CloseHandle(job); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(si.hStdInput); CloseHandle(si.hStdOutput); CloseHandle(si.hStdError); CloseHandle(port.CompletionPort); + CloseHandle(job); FState=ssTestComplete; if (FTestHandler) FTestHandler(index,(TResult^)FRes[index-1]); @@ -863,6 +795,7 @@ { if (CreateEnvironmentBlock((LPVOID*)&env,token,FALSE)) { + //DeletePrivileges(token); if (CreateProcessAsUser(token,NULL,buflpCommandLine,NULL,NULL,bInheritHandles,dwCreationFlags|CREATE_UNICODE_ENVIRONMENT,env,NULL,lpStartupInfo,lpProcessInformation)) { DestroyEnvironmentBlock(env); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-22 10:53:07
|
Revision: 270 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=270&view=rev Author: Oracle_ Date: 2008-06-20 11:17:38 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Added multithreading Modified Paths: -------------- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp ACMServer/trunk/sharp tester/SourceTest/SourceTest.h ACMServer/trunk/sharp tester/SourceTest.sln ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp ACMServer/trunk/sharp tester/tester/Program.cs ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt ACMServer/trunk/sharp tester/tester/SAMPLE/source.txt Added Paths: ----------- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/out.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/in.txt ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/out.txt Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-20 18:17:38 UTC (rev 270) @@ -10,6 +10,8 @@ const wchar_t USER_NAME[]={L"TestingUser"}; //username for testing const wchar_t USER_PASSW[]={L"USER12345"}; //password of user for testing +const int CONST_SLEEP=100; //constant used for waiting for files to be created/flushed on disk +const int MAX_THREAD=2; //maximum parallel threads namespace SourceTest { @@ -24,7 +26,6 @@ return (wchar_t*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(str).ToPointer(); } - void FreeArr(char* buf) //destroys C++ string { System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); @@ -42,7 +43,6 @@ return %String(intg); } - bool FileExists(String^ path) //checks whether file exists or not { char* buf=StrToArr(path); @@ -54,6 +54,44 @@ return res; } +String^ ReadFullFile(String^ filename) +{ + HANDLE h; + wchar_t* bufW=StrToArrW(filename); + int cycle=0; + do + { + h=CreateFile(bufW,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); + Sleep(1); + ++cycle; + } while (h==INVALID_HANDLE_VALUE&&cycle<100); + if (h==INVALID_HANDLE_VALUE) + return ""; + FreeArr(bufW); + DWORD size=GetFileSize(h,NULL); + char* res=new char[size+20];ZeroMemory(res,(size+2)*sizeof(char)); + char* buf=new char[size+20]; + DWORD curlen=0; + cycle=0; + do + { + ZeroMemory(buf, (size+20)*sizeof(char)); + DWORD rlen=0; + ReadFile(h,buf,size,&rlen,NULL); + curlen+=rlen; + strcat_s(res,size+10,buf); + Sleep(1); + ++cycle; + } while (curlen<size&&cycle<100); + CloseHandle(h); + String^ r=gcnew String(res); + delete[] res; + delete[] buf; + if (curlen<size) + return ""; + return r; +} + TSource::TSource() { FSrc=gcnew String(""); @@ -80,59 +118,47 @@ if (lib!=NULL) FreeLibrary(lib); delete FSecurity; +FRes.Clear(); +FThreads.Clear(); final(); } void TSource::CheckCL() //checking size of source { - try + if (lib==NULL) //no library was found { - lock(); - if (lib==NULL) //no library was found - { - if (FSrc->Length>FLim.CodeLimit) - FCompResult.res=crCL; - FCompResult.Details+="Used std checker for Code Limit\n"; - } else - { - TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckCL"); - char* buf,*bufA; - if (prc(bufA=StrToArr(FSrc),FLim.CodeLimit,buf)) FCompResult.res=crCL; - FreeArr(bufA); - FCompResult.Details+=gcnew String(buf); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - prc2(buf); - } - FState=ssCheckedCL; - }__finally + if (FSrc->Length>FLim.CodeLimit) + FCompResult.res=crCL; + FCompResult.Details+="Used std checker for Code Limit\n"; + } else { - unlock(); + TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckCL"); + char* buf,*bufA; + if (prc(bufA=StrToArr(FSrc),FLim.CodeLimit,buf)) FCompResult.res=crCL; + FreeArr(bufA); + FCompResult.Details+=gcnew String(buf); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + prc2(buf); } + FState=ssCheckedCL; } void TSource::CheckDF() //checking for DF in source { - try + if (lib==NULL) //no library was found { - lock(); - if (lib==NULL) //no library was found - { - FCompResult.Details+="No checker for DF\n"; - } else - { - TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckDF"); - char* buf,*bufA; - if (prc(bufA=StrToArr(FSrc),(int)FLang,buf)) FCompResult.res=crDF; - FreeArr(bufA); - FCompResult.Details+=gcnew String(buf); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - prc2(buf); - } - FState=ssCheckedDF; - }__finally + FCompResult.Details+="No checker for DF\n"; + } else { - unlock(); + TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckDF"); + char* buf,*bufA; + if (prc(bufA=StrToArr(FSrc),(int)FLang,buf)) FCompResult.res=crDF; + FreeArr(bufA); + FCompResult.Details+=gcnew String(buf); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + prc2(buf); } + FState=ssCheckedDF; } void TSource::Compile() //compiles the source @@ -147,187 +173,210 @@ wchar_t* bufW; try { - lock(); - String^ srcpath=gcnew String(FTempPath+"source.txt"); - String^ outpath=gcnew String(FTempPath+"compoutput.txt"); - FExePath=FTempPath+"source.exe"; - - if (FileExists(FExePath)) //delete previsious source - { - DeleteFile((LPCTSTR)(bufW=StrToArrW(FExePath))); - FreeArr(bufW); - } - - si.cb=sizeof(si); - si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - si.wShowWindow=FALSE; - si.hStdOutput=CreateFile(bufW=StrToArrW(outpath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); + String^ srcpath=gcnew String(FTempPath+"source.txt"); + String^ outpath=gcnew String(FTempPath+"compoutput.txt"); + FExePath=FTempPath+"source.exe"; + + if (FileExists(FExePath)) //delete previsious source + { + DeleteFile((LPCTSTR)(bufW=StrToArrW(FExePath))); FreeArr(bufW); - HANDLE src=CreateFile(bufW=StrToArrW(srcpath),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - FreeArr(bufW); - DWORD len; - WriteFile(src,bufA=StrToArr(FSrc),FSrc->Length,&len,NULL); - FreeArr(bufA); - CloseHandle(src); - - Sleep(100); //waiting for file to flush on hard + Sleep(CONST_SLEEP); //waiting for file to destroy + } - DWORD start=GetTickCount(); - bufW=StrToArrW("\""+FCompPath+"\" \""+srcpath+"\" \""+FTempPath); - if (!CreateProcess(NULL,bufW,&sec,&sec,true,CREATE_NEW_CONSOLE|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) - { - FreeArr(bufW); - FCompResult.res=crIE; - FCompResult.Details+="Can not run the compiler\n"; - return; - } + si.cb=sizeof(si); + si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + si.wShowWindow=FALSE; + si.hStdOutput=CreateFile(bufW=StrToArrW(outpath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); + FreeArr(bufW); + HANDLE src=CreateFile(bufW=StrToArrW(srcpath),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); + FreeArr(bufW); + DWORD len; + WriteFile(src,bufA=StrToArr(FSrc),FSrc->Length,&len,NULL); + FreeArr(bufA); + CloseHandle(src); + + Sleep(CONST_SLEEP); //waiting for file to flush on hard + + DWORD start=GetTickCount(); + bufW=StrToArrW("\""+FCompPath+"\" \""+srcpath+"\" \""+FTempPath); + if (!CreateProcess(NULL,bufW,&sec,&sec,true,CREATE_NEW_CONSOLE|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) + { FreeArr(bufW); - if (WaitForSingleObject(pi.hProcess,FLim.CompilationTimeLimit)==WAIT_TIMEOUT) - { - TerminateProcess(pi.hProcess,0); - FCompResult.res=crCTL; - FCompResult.UsedTime=FLim.CompilationTimeLimit; - FCompResult.Details+="Time out during compilation\n"; - return; - } - FCompResult.UsedTime=GetTickCount()-start; + FCompResult.res=crIE; + FCompResult.Details+="Can not run the compiler\n"; + return; + } + FreeArr(bufW); + if (WaitForSingleObject(pi.hProcess,FLim.CompilationTimeLimit)==WAIT_TIMEOUT) + { + TerminateProcess(pi.hProcess,0); + FCompResult.res=crCTL; + FCompResult.UsedTime=FLim.CompilationTimeLimit; + FCompResult.Details+="Time out during compilation\n"; + return; + } + FCompResult.UsedTime=GetTickCount()-start; - Sleep(100); //waiting for creating the file - CloseHandle(si.hStdOutput); + Sleep(CONST_SLEEP); //waiting for creating the file + + CloseHandle(si.hStdOutput); si.hStdOutput=NULL; - HANDLE oup=CreateFile(bufW=StrToArrW(outpath),GENERIC_READ,0,&sec,OPEN_EXISTING,0,NULL); - FreeArr(bufW); - DWORD size=GetFileSize(oup,NULL); - char* compres=new char[size+2]; compres[size+1]='\0'; - ReadFile(oup,compres,size,&len,NULL); - CloseHandle(oup); + if (!FileExists(FExePath)) //compilation error + { + FCompResult.res=crCE; + FCompResult.Details+="EXE file not found\n"+ReadFullFile(outpath); + return; + } - if (!FileExists(FExePath)) //compilation error - { - FCompResult.res=crCE; - FCompResult.Details+=gcnew String("EXE file not found\n")+gcnew String(compres); - delete[] compres; - return; - } + FCompResult.Details+=ReadFullFile(outpath); - FCompResult.Details+=gcnew String(compres); - delete[] compres; - }__finally { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); + if (pi.hProcess!=NULL) + CloseHandle(pi.hProcess); + if (pi.hThread!=NULL) + CloseHandle(pi.hThread); + if (si.hStdOutput!=NULL) + CloseHandle(si.hStdOutput); FState=ssCompiled; - unlock(); } } -void TSource::RunTests() //runs all tests of problem +void TSource::AddThread() { -try + Threading::Thread^ t=gcnew Threading::Thread(gcnew System::Threading::ThreadStart(this,&TSource::ThreadProc)); + FThreads.Add(t); + t->Start(); +} + +void TSource::ThreadProc() { + while (true) + { + if (!NeedTest) break; lock(); - int n=1; - while (FileExists(FProblemPath+"test"+ToStr(n)+"\\in.txt")||FileExists(FProblemPath+"test"+ToStr(n)+"\\out.txt")||FileExists(FProblemPath+"test"+ToStr(n)+"\\points.txt")) + ++CurrentTest; + int n=CurrentTest; + unlock(); + if (n<TestCnt()) { RunTest(n); - FSummary.res->points+=((TResult^)FRes[n-1])->points; - FSummary.res->UsedMemory=max(((TResult^)FRes[n-1])->UsedMemory,FSummary.res->UsedMemory); - FSummary.res->UsedTime=max(((TResult^)FRes[n-1])->UsedTime,FSummary.res->UsedTime); - FSummary.res->UsedRealTime=max(((TResult^)FRes[n-1])->UsedRealTime,FSummary.res->UsedRealTime); - if (((TResult^)FRes[n-1])->res!=trAC) + Summary->res->points+=Results[n-1]->points; + Summary->res->UsedMemory=max(Results[n-1]->UsedMemory,Summary->res->UsedMemory); + Summary->res->UsedTime=max(Results[n-1]->UsedTime,Summary->res->UsedTime); + Summary->res->UsedRealTime=max(Results[n-1]->UsedRealTime,Summary->res->UsedRealTime); + if (Results[n-1]->res!=trAC) { - FSummary.res->res=((TResult^)FRes[n-1])->res; - if (!FRunAll) break; + Summary->res->res=Results[n-1]->res; + if (!RunAll) { NeedTest=false; break; } } - n++; + } else + { + NeedTest=false; + break; } -}__finally + } +} + +void TSource::RunTests() //runs all tests of problem { + FState=ssIsRunning; + CurrentTest=0; + NeedTest=true; + FTestCnt=1; + FRes.Clear(); + while (FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\in.txt")||FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\out.txt")||FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\points.txt")) + { + FRes.Add(%TResult()); + FTestCnt++; + } + + FThreads.Clear(); + for (int i=0;i<min(MAX_THREAD,FTestCnt-1);i++) + AddThread(); + for (int i=0;i<FThreads.Count;i++) + ((Threading::Thread^)FThreads[i])->Join(INFINITE); FState=ssFinish; - unlock(); } -} void TSource::LoadTest(int index,TTest% test) //loads test from file { -FILE* inp,*oup,*points; -char *bufA; try { lock(); - test.input=""; - test.output=""; - test.points=1; - - if (fopen_s(&inp,bufA=StrToArr(FProblemPath+"test"+ToStr(index)+"\\in.txt"),"rt")==0) - { - fseek(inp,0,SEEK_END); - int size=ftell(inp); - fseek(inp,0,SEEK_SET); - char* buf=new char[size+1];ZeroMemory(buf,(size+1)*sizeof(char)); - fread(buf,sizeof(char),size,inp); - test.input=gcnew String(buf); - } - FreeArr(bufA); - - if (fopen_s(&oup,bufA=StrToArr(FProblemPath+"\\test"+ToStr(index)+"\\out.txt"),"rt")==0) - { - fseek(oup,0,SEEK_END); - int size=ftell(inp); - fseek(oup,0,SEEK_SET); - char* buf=new char[size+1];ZeroMemory(buf,(size+1)*sizeof(char)); - fread(buf,sizeof(char),size,oup); - test.output=gcnew String(buf); - } - FreeArr(bufA); - - if (fopen_s(&points,bufA=StrToArr(FProblemPath+"\\test"+ToStr(index)+"\\points.txt"),"rt")==0) - { - fscanf_s(points,"%d",&test.points); - } - FreeArr(bufA); - + if (FileExists(FProblemPath+"test"+ToStr(index)+"\\in.txt")) + test.input=ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\in.txt"); else + test.input=""; + if (FileExists(FProblemPath+"test"+ToStr(index)+"\\out.txt")) + test.output=ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\out.txt"); else + test.output=""; + if (FileExists(FProblemPath+"test"+ToStr(index)+"\\points.txt")) + test.points.Parse(ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\points.txt")); else + test.points=1; }__finally { - if (inp!=NULL) - fclose(inp); - if (oup!=NULL) - fclose(oup); - if (points!=NULL) - fclose(points); unlock(); } } TCheckAnsRes TSource::CheckAnswer(int index,String^ output, String^% Details) //checks answer for test { - try +try +{ + TTest t; + LoadTest(index,t); + lock(); + if (lib==NULL) //lib was not found { - lock(); - TTest t; - LoadTest(index,t); - if (lib==NULL) //lib was not found - { - if (output!=t.output) - return carWA; - return carAC; - } else - { - char* buf1,*buf2,*buf3,*buf4=NULL; - TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); - TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output),buf4); - Details+=gcnew String(buf4); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - FreeArr(buf1);FreeArr(buf2);FreeArr(buf3);prc2(buf4); - return res; - } - }__finally + if (output!=t.output) + return carWA; + return carAC; + } else { - unlock(); + char* buf1,*buf2,*buf3,*buf4=NULL; + TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); + TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output),buf4); + Details+=gcnew String(buf4); + TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + FreeArr(buf1);FreeArr(buf2);FreeArr(buf3);prc2(buf4); + return res; } +} __finally +{ + unlock(); } +} +bool TSource::CheckTL(int usedtime, int timelimit) +{ +try +{ + lock(); + if (lib==NULL) + return usedtime>timelimit; + TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckTL"); + return prc(usedtime,timelimit); +}__finally +{ + unlock(); +} +} +bool TSource::CheckRTL(int usedrealtime, int realtimelimit) +{ +try +{ + lock(); + if (lib==NULL) + return usedrealtime>realtimelimit; + TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckRTL"); + return prc(usedrealtime,realtimelimit); +}__finally +{ + unlock(); +} +} + void TSource::ProcessAll() //executes all actions needed to get Summary result for all tests { try @@ -375,63 +424,57 @@ sec.lpSecurityDescriptor=NULL; JOBOBJECT_BASIC_ACCOUNTING_INFORMATION acc; JOBOBJECT_EXTENDED_LIMIT_INFORMATION mem; -HANDLE job; -JOBOBJECT_ASSOCIATE_COMPLETION_PORT port; +HANDLE job=NULL; +JOBOBJECT_ASSOCIATE_COMPLETION_PORT port; ZeroMemory(&port,sizeof(port)); JOBOBJECT_BASIC_UI_RESTRICTIONS uilim; DWORD len=0; wchar_t* bufW; -char* bufA; try { - lock(); - FRes.Add(%TResult()); - TResult^ it=(TResult^)FRes[FRes.Count-1]; - it->res=trAC; - it->points=0; - it->Details=""; - it->UsedMemory=-1; - it->UsedRealTime=-1; - it->UsedTime=-1; - String^ inpath=FProblemPath+"test"+ToStr(index)+"\\in.txt"; - String^ oupath=FTempPath+"out.txt"; - String^ erpath=FTempPath+"err.txt"; - String^ pointpath=FProblemPath+"test"+ToStr(index)+"\\points.txt"; + Results[index-1]->res=trAC; + Results[index-1]->points=0; + Results[index-1]->Details=""; + Results[index-1]->UsedMemory=-1; + Results[index-1]->UsedRealTime=-1; + Results[index-1]->UsedTime=-1; + String^ inpath=ProblemPath+"test"+ToStr(index)+"\\in.txt"; + String^ oupath=TempPath+"out"+ToStr(index)+".txt"; + String^ erpath=TempPath+"err"+ToStr(index)+".txt"; + String^ pointpath=ProblemPath+"test"+ToStr(index)+"\\points.txt"; - FState=ssIsRunning; - - TTest t; - LoadTest(index,t); si.cb=sizeof(si); si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.wShowWindow=FALSE; - si.hStdInput=CreateFile(bufW=StrToArrW(inpath),GENERIC_READ,0,&sec,OPEN_EXISTING,0,NULL); FreeArr(bufW); + si.hStdInput=CreateFile(bufW=StrToArrW(inpath),GENERIC_READ,FILE_SHARE_READ,&sec,OPEN_EXISTING,0,NULL); FreeArr(bufW); si.hStdOutput=CreateFile(bufW=StrToArrW(oupath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); FreeArr(bufW); - si.hStdError=CreateFile(bufW=StrToArrW(erpath),GENERIC_WRITE,0,&sec,CREATE_ALWAYS,0,NULL); FreeArr(bufW); + si.hStdError=CreateFile(bufW=StrToArrW(erpath),GENERIC_WRITE,FILE_SHARE_WRITE,&sec,CREATE_ALWAYS,0,NULL); FreeArr(bufW); SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); - - if (!FSecurity->RunProcess(bufW=StrToArrW(FExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW,&si,&pi,it->Details)) + lock(); + if (!FSecurity->RunProcess(bufW=StrToArrW(ExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|HIGH_PRIORITY_CLASS,&si,&pi,Results[index-1]->Details)) { FreeArr(bufW); - it->points=0; + Results[index-1]->points=0; int err=GetLastError(); if ((err==193)||(err==1455)) { - it->res=trRE; - it->Details+=gcnew String("Too large array"); + Results[index-1]->res=trRE; + Results[index-1]->Details+="Too large array"; } else { - it->res=trIE; - it->Details+=gcnew String("Can not start process"); + Results[index-1]->res=trIE; + Results[index-1]->Details+="Can not start process"; } + unlock(); return ; } FreeArr(bufW); + unlock(); job=CreateJobObject(NULL,NULL); mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; - mem.ProcessMemoryLimit=FLim.MemoryLimit; + mem.ProcessMemoryLimit=Lim->MemoryLimit; SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); - port.CompletionKey=(void*)123; + port.CompletionKey=(void*)index; port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); SetInformationJobObject(job,JobObjectAssociateCompletionPortInformation,&port,sizeof(port)); @@ -440,93 +483,74 @@ AssignProcessToJobObject(job,pi.hProcess); + SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL); + ResumeThread(pi.hThread); + DWORD start=GetTickCount(); while (true) { - if ((int)GetFileSize(si.hStdOutput,NULL)>FLim.OutputLimit) + if ((int)GetFileSize(si.hStdOutput,NULL)>Lim->OutputLimit) { TerminateJobObject(job,0); - it->res=trOL; - it->Details+=gcnew String("Size of output file excided OutputLimit"); + Results[index-1]->res=trOL; + Results[index-1]->Details+="Size of output file excided OutputLimit"; break; } QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); - if (lib==NULL) + if (CheckRTL((int)(GetTickCount()-start),Lim->RealTimeLimit)) { - if ((int)(GetTickCount()-start)>FLim.RealTimeLimit) - { TerminateJobObject(job,0); - it->res=trRTL; - it->Details+=gcnew String("Real time limit"); + Results[index-1]->res=trRTL; + Results[index-1]->Details+="Real time limit"; break; } - if ((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)>FLim.TimeLimit*10000) + if (CheckTL((int)(acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart),Lim->TimeLimit*10000)) { TerminateJobObject(job,0); - it->res=trTL; - it->Details+=gcnew String("Time Limit"); + Results[index-1]->res=trTL; + Results[index-1]->Details+="Time Limit"; break; } - } else - { - TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckTL"); - if (prc((int)(acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart),(int)(FLim.TimeLimit*10000))) - { - TerminateJobObject(job,0); - it->res=trTL; - it->Details+=gcnew String("Time Limit"); - break; - } - prc=(TCheckLim)GetProcAddress(lib,"CheckRTL"); - if (prc((int)(GetTickCount()-start),FLim.RealTimeLimit)) - { - TerminateJobObject(job,0); - it->res=trRTL; - it->Details+=gcnew String("Real time Limit"); - break; - } - } unsigned long len,key; HANDLE proc; - if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)) + if (GetQueuedCompletionStatus(port.CompletionPort, &len, &key, (LPOVERLAPPED*)&proc, 1)&&(key==index)) { DWORD code=0; bool needbreak=false; - if (key==123) switch(len) { case JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: GetExitCodeProcess(pi.hProcess,&code); if (code==5) { - it->res=trDF; - it->Details+=gcnew String("Access denied."); + Results[index-1]->res=trDF; + Results[index-1]->Details+="Access denied."; } else if (code!=0) { - it->res=trRE; - it->Details+=gcnew String("Runtime error #"+ToStr((int)code)); + Results[index-1]->res=trRE; + Results[index-1]->Details+="Runtime error #"+ToStr((int)code); } needbreak=true; break; case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: - it->res=trML; - it->Details+=gcnew String("Memory Limit"); + Results[index-1]->res=trML; + Results[index-1]->Details+="Memory Limit"; needbreak=true; break; case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: GetExitCodeProcess(pi.hProcess,&code); if (code==5) { - it->res=trDF; - it->Details+=gcnew String("Access denied."); + Results[index-1]->res=trDF; + Results[index-1]->Details+="Access denied."; } else if (code!=0) { - it->res=trRE; - it->Details+=gcnew String("Runtime error #"+ToStr((int)code)); + Results[index-1]->res=trRE; + Results[index-1]->Details+="Runtime error #"+ToStr((int)code); } needbreak=true; break; @@ -539,74 +563,74 @@ } Sleep(1); } - CloseHandle(si.hStdOutput); - CloseHandle(si.hStdInput); - Sleep(100); //waiting for file + SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL); + + CloseHandle(si.hStdOutput);si.hStdOutput=NULL; + CloseHandle(si.hStdInput);si.hStdInput=NULL; + Sleep(CONST_SLEEP); //waiting for file + QueryInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem),NULL); QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); - it->UsedMemory=mem.PeakProcessMemoryUsed; - it->UsedTime=(int)((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)/10000); - it->UsedRealTime=GetTickCount()-start; - if (it->res!=trAC) return; + Results[index-1]->UsedMemory=mem.PeakProcessMemoryUsed; + Results[index-1]->UsedTime=(int)((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)/10000); + Results[index-1]->UsedRealTime=GetTickCount()-start; + if (Results[index-1]->res!=trAC) return; if (!FileExists(oupath)) { - it->res=trWA; - it->Details+=gcnew String("No output file"); + Results[index-1]->res=trWA; + Results[index-1]->Details+="No output file"; return; } - HANDLE ouf=CreateFile(bufW=StrToArrW(oupath),GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); FreeArr(bufW); - DWORD size=GetFileSize(ouf,NULL); - char* buf=new char[size+1]; ZeroMemory(buf,(size+1)*sizeof(char)); - ReadFile(ouf,buf,size,&len,NULL); - CloseHandle(ouf); + //Sleep(CONST_SLEEP); //waiting for closing all handles to this file - TCheckAnsRes r=CheckAnswer(index,gcnew String(buf),it->Details); - delete[] buf; + TCheckAnsRes r=CheckAnswer(index,ReadFullFile(oupath),Results[index-1]->Details); + if (r==carAC) { if (FileExists(pointpath)) - { - FILE* point; - fopen_s(&point,bufA=StrToArr(pointpath),"rt"); FreeArr(bufA); - fscanf_s(point,"%d",&it->points); - fclose(point); - } else it->points=1; + Results[index-1]->points.Parse(ReadFullFile(pointpath)); else + Results[index-1]->points=1; return ; } switch (r) { case carOE: - it->res=trOE; + Results[index-1]->res=trOE; break; case carPE: - it->res=trPE; + Results[index-1]->res=trPE; break; case carWA: - it->res=trWA; + Results[index-1]->res=trWA; break; case carIE: - it->res=trIE; + Results[index-1]->res=trIE; break; }; }__finally { - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(si.hStdInput); - CloseHandle(si.hStdOutput); - CloseHandle(si.hStdError); - CloseHandle(port.CompletionPort); - CloseHandle(job); - FState=ssTestComplete; - if (FTestHandler) - FTestHandler(index,(TResult^)FRes[index-1]); - unlock(); + if (pi.hProcess!=NULL) + CloseHandle(pi.hProcess); + if (pi.hThread!=NULL) + CloseHandle(pi.hThread); + if (si.hStdInput!=NULL) + CloseHandle(si.hStdInput); + if (si.hStdOutput!=NULL) + CloseHandle(si.hStdOutput); + if (si.hStdError!=NULL) + CloseHandle(si.hStdError); + if (port.CompletionPort!=NULL) + CloseHandle(port.CompletionPort); + if (job!=NULL) + CloseHandle(job); + if (TestHandler) + TestHandler(index,Results[index-1]); } } @@ -639,7 +663,6 @@ FILE* f; try { - lock(); if (FState!=ssNone) { throw "Can not load limits if state is higher than ssNone"; @@ -652,7 +675,6 @@ { fclose(f); FreeArr(buf); - unlock(); } } Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-20 18:17:38 UTC (rev 270) @@ -202,6 +202,13 @@ (*compres)=(*value.compres); } + TSummary operator=(TSummary value) + { + (*res)=(*value.res); + (*compres)=(*value.compres); + return (value); + } + }; ///<summary> ///TTest holds information about one test @@ -262,18 +269,18 @@ private: String^ FSrc; //text of source String^ FExePath; //executable file - String^ FProblemPath; //path for problem + String^ FProblemPath; //path for problem *MT* String^ FCompPath; //path for compiler - String^ FTempPath; //this is the place where temporary files will be created - bool FRunAll; //if true then all tests will run (no matter on errors) - TSourceState FState; //state of source + String^ FTempPath; //this is the place where temporary files will be created + bool FRunAll; //if true then all tests will run (no matter on errors) + TSourceState FState; //state of source TCompResult FCompResult; //result of compilation - ArrayList FRes; //results of each test - TSummary FSummary; //summary results of all tests + ArrayList FRes; //results of each test *MT* + TSummary FSummary; //summary results of all tests *MT* TLimits FLim; //limits for testing - TTestHandler^ FTestHandler; //event, that occures when test is completed + TTestHandler^ FTestHandler; //event, that occures when test is completed *MT* TLang FLang; //language of source - TSecure *FSecurity; //security class + TSecure *FSecurity; //security class *MT* HMODULE lib; //library that must export: //bool CheckCL(char* src, int cl, char*& details) - must check codelimit //bool CheckDF(char* src, int lang, char*& details) - must check DF @@ -305,6 +312,82 @@ DeleteCriticalSection(cs); delete cs; } + + void AddThread(); + void ThreadProc(); + int FCurrentTest; //current test for testing *MT* + bool FNeedTest; //if found WA, or all test completed *MT* + int FTestCnt; + ArrayList FThreads; + property int CurrentTest + { + void set(int value) + { + try + { + lock(); + FCurrentTest=value; + }__finally + { + unlock(); + } + } + + int get() + { + try + { + lock(); + return FCurrentTest; + }__finally + { + unlock(); + } + } + } + + property bool NeedTest + { + void set(bool value) + { + try + { + lock(); + FNeedTest=value; + }__finally + { + unlock(); + } + } + + bool get() + { + try + { + lock(); + return FNeedTest; + }__finally + { + unlock(); + } + } + } + + int TestCnt() + { + try + { + lock(); + return FTestCnt; + } __finally + { + unlock(); + } + } + + + bool CheckRTL(int usedrealtime, int realtimelimit); + bool CheckTL(int usedtime, int timelimit); public: TSource(); ~TSource(); @@ -329,17 +412,23 @@ try { lock(); - if (FState>=ssIsRunning) - { - throw "Can not set limits if state is ssIsRunning or higher"; - return ; - } FLim=(*value); } __finally { unlock(); } } + TLimits^ get() + { + try + { + lock(); + return %FLim; + } + __finally { + unlock(); + } + } } property String^ Src @@ -360,11 +449,6 @@ try { lock(); - if (FState!=ssNone) - { - throw "Can not set source unless state is ssNone"; - return; - } FSrc=value; } __finally { unlock(); @@ -379,11 +463,6 @@ try { lock(); - if (FState<ssCompiled) - { - throw "Can not get exepath unless state is ssCompiled or higher"; - return ""; - } return FExePath; }__finally{ unlock(); @@ -402,15 +481,11 @@ unlock(); } } + void set(String^ value) { try{ lock(); - if (FState>ssCompiled) - { - throw "Can not set problempath if state is ssIsRunning or higher"; - return ; - } FProblemPath=value; }__finally { unlock(); @@ -425,11 +500,6 @@ try { lock(); - if (FState==ssNone) - { - throw "Can not get compresult if state is ssNone"; - return %FCompResult; - } return %FCompResult; }__finally { unlock(); @@ -467,11 +537,6 @@ try { lock(); - if (FState<ssIsRunning) - { - throw "Can not get test results if state is lower than ssIsRunning"; - return (%TResult()); - } if (index>=FRes.Count) { throw "The index is not accesible"; @@ -493,17 +558,24 @@ try { lock(); - if (FState!=ssFinish) - { - throw "Can not get summary unlest state is ssFinish"; - return (%TSummary()); - } return (%FSummary); }__finally { unlock(); } }; + + void set(TSummary^ value) + { + try + { + lock(); + FSummary=(*value); + } + __finally { + unlock(); + } + } } property TTestHandler^ TestHandler @@ -552,11 +624,6 @@ try { lock(); - if (FState>ssCheckedDF) - { - throw "Can not set compiler path if state is higher than ssCheckedDF"; - return ; - } FCompPath=value; }__finally { @@ -599,11 +666,6 @@ try { lock(); - if (FState>=ssIsRunning) - { - throw "Can not set RunAll if state is higher or equal ssIsRunning"; - return; - } FRunAll=value; } __finally { @@ -631,11 +693,6 @@ try { lock(); - if (FState>=ssCheckedDF) - { - throw "Can not set Language if state is higher or equal ssCheckedDF"; - return; - } FLang=value; } __finally { Modified: ACMServer/trunk/sharp tester/SourceTest.sln =================================================================== --- ACMServer/trunk/sharp tester/SourceTest.sln 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/SourceTest.sln 2008-06-20 18:17:38 UTC (rev 270) @@ -2,6 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SourceTest", "SourceTest\SourceTest.vcproj", "{FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}" + ProjectSection(ProjectDependencies) = postProject + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4} = {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tester", "tester\tester.csproj", "{2D663DAB-3573-4CB6-95A0-2425635CFEC3}" EndProject @@ -18,11 +21,13 @@ EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Any CPU.Build.0 = Debug|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Win32.ActiveCfg = Debug|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Debug|Win32.Build.0 = Debug|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Any CPU.ActiveCfg = Release|Win32 + {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Any CPU.Build.0 = Release|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Mixed Platforms.Build.0 = Release|Win32 {FD28B5FF-FCE2-417C-998C-DA3B1B9D9315}.Release|Win32.ActiveCfg = Release|Win32 @@ -32,17 +37,21 @@ {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Win32.ActiveCfg = Debug|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Debug|Win32.Build.0 = Debug|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Any CPU.Build.0 = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Win32.ActiveCfg = Release|Any CPU + {2D663DAB-3573-4CB6-95A0-2425635CFEC3}.Release|Win32.Build.0 = Release|Any CPU {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Any CPU.Build.0 = Debug|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Win32.ActiveCfg = Debug|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Debug|Win32.Build.0 = Debug|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Any CPU.ActiveCfg = Release|Win32 + {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Any CPU.Build.0 = Release|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Mixed Platforms.Build.0 = Release|Win32 {2009FCA0-9B13-4D3D-8C89-DDCD3C40E4B4}.Release|Win32.ActiveCfg = Release|Win32 Modified: ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp =================================================================== --- ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-20 18:17:38 UTC (rev 270) @@ -35,10 +35,13 @@ TESTLIBRARY_API int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) { - Details=new char[30]; - strcpy(Details,"CheckAnswer from DLL\n"); if (strcmp(output,rightoutput)==0) return 0; + Details=new char[30]; + strcpy(Details,output); + strcat(Details," RIGHT: "); + strcat(Details,rightoutput); + strcat(Details,"\n"); int curo=0; for (int i=0;;i++,curo++) { Modified: ACMServer/trunk/sharp tester/tester/Program.cs =================================================================== --- ACMServer/trunk/sharp tester/tester/Program.cs 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/tester/Program.cs 2008-06-20 18:17:38 UTC (rev 270) @@ -6,6 +6,26 @@ namespace tester { + class MiniMax + { + public int min; + public int max; + public MiniMax() + { + min = 1000000000; + max = -1000000000; + } + public void update(int x) + { + min = Math.Min(min, x); + max = Math.Max(max, x); + } + public int diff() + { + return max - min; + } + }; + class Program { static void func(int x,TResult res) @@ -13,32 +33,52 @@ Console.WriteLine("test number {0}, result: {1}, details: {2}",x,TSource.TestResultToString(res.res),res.Details); } + const int INF = 1000000000; static void Main(string[] args) { - TSource c = new TSource(); - StreamReader s = new StreamReader("InData.txt",Encoding.Default); - String compiler = s.ReadLine(); - String problem = s.ReadLine(); - String temp = s.ReadLine(); - String source = s.ReadLine(); - s.Close(); - s=File.OpenText(source); - c.CompPath = compiler; - c.ProblemPath = problem; - c.LoadLimits(); - c.Src = s.ReadToEnd(); - s.Close(); - c.TempPath = temp; - c.TestHandler += new TTestHandler(func); - c.Language = (TLang)1; - c.ProcessAll(); - c.State = (TSourceState)6; - Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); - Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); - Console.WriteLine("Points: {0}", c.Summary.res.points); - Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); - Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); - Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); + DateTime start=DateTime.Now; + MiniMax rt=new MiniMax(),t=new MiniMax(),mem=new MiniMax(),ct=new MiniMax(); + //for (int i = 0; i < 10000; i++) + { + TSource c = new TSource(); + StreamReader s = new StreamReader("InData.txt", Encoding.Default); + String compiler = s.ReadLine(); + String problem = s.ReadLine(); + String temp = s.ReadLine(); + String source = s.ReadLine(); + s.Close(); + s = File.OpenText(source); + c.CompPath = compiler; + c.ProblemPath = problem; + c.LoadLimits(); + c.Src = s.ReadToEnd(); + s.Close(); + c.TempPath = temp; + c.TestHandler += new TTestHandler(func); + c.Language = (TLang)1; + c.ProcessAll(); + c.State = (TSourceState)6; + Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); + Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); + Console.WriteLine("Points: {0}", c.Summary.res.points); + Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); + Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); + Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); + //Console.ReadKey(); + Console.WriteLine(" CompRes: {0}, TestRes: {1}", TSource.CompileResultToString(c.Summary.compres.res), TSource.TestResultToString(c.Summary.res.res)); + rt.update(c.Summary.res.UsedRealTime); + t.update(c.Summary.res.UsedTime); + ct.update(c.Summary.compres.UsedTime); + mem.update(c.Summary.res.UsedMemory); + /*if (c.Summary.res.res != 0) + { + System.Media.SystemSounds.Beep.Play(); + Console.ReadKey(); + }*/ + } + Console.WriteLine("Used Time: {0} ms", (System.DateTime.Now.Ticks - start.Ticks)/10000); + Console.WriteLine("MAX: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte", ct.max, t.max, rt.max, mem.max); + Console.WriteLine("Diff: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte",ct.diff(),t.diff(),rt.diff(),mem.diff()); Console.ReadKey(); } } Modified: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -2,5 +2,5 @@ CompilationTimeLimit: 10000 MemoryLimit: 10000000 OutputLimit: 1024 -RealTimeLimit: 10000 -TimeLimit: 1000 +RealTimeLimit: 100000 +TimeLimit: 500 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test10/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test11/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test12/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test13/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test14/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test15/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test3/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test4/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test5/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test6/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test7/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test8/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/in.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/in.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/in.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1334 15 Added: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/out.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/out.txt (rev 0) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/test9/out.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -0,0 +1 @@ +1349 \ No newline at end of file Modified: ACMServer/trunk/sharp tester/tester/SAMPLE/source.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/source.txt 2008-06-20 14:07:46 UTC (rev 269) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/source.txt 2008-06-20 18:17:38 UTC (rev 270) @@ -1,8 +1,18 @@ -program hello; -uses windows; -var a,b:integer; -begin -read(a,b); -while true do; -write(a+b); -end. \ No newline at end of file +uses Windows; var f:Thandle; begin f:=CreateFile('Hello.txt',GENERIC_WRITE,0,nil,CREATE_ALWAYS,0,0); if (f=INVALID_HANDLE_VALUE) then while true do; CloseHandle(f); end. +var a,b:Extended; +i:Integer; +x:array of Integer; +begin + read(a,b); + for i:=1 to 5700000 do + a:=sqrt(a)*sqrt(a)+((sqrt(a)*sqrt(a))/sqrt(a))/sqrt(a)-1; + for i:=1 to 180000000 do ; + for i:=1 to 20 do + begin + SetLength(x,5000000); + x[1237]:=2178; + x[5237]:=2174; + SetLength(x,0); + end; + write(a+b:0:0); +end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-22 18:43:19
|
Revision: 276 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=276&view=rev Author: Oracle_ Date: 2008-06-22 11:43:23 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Modified Paths: -------------- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp ACMServer/trunk/sharp tester/SourceTest/SourceTest.h ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-22 08:35:12 UTC (rev 275) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-22 18:43:23 UTC (rev 276) @@ -12,7 +12,6 @@ const wchar_t USER_NAME[]={L"TestingUser"}; //username for testing const wchar_t USER_PASSW[]={L"USER12345"}; //password of user for testing const int CONST_SLEEP=100; //constant used for waiting for files to be created/flushed on disk -const int MAX_THREAD=2; //maximum parallel threads namespace SourceTest { @@ -294,7 +293,7 @@ } FThreads.Clear(); - for (int i=0;i<min(MAX_THREAD,FTestCnt-1);i++) + for (int i=0;i<min(FLim.MaxThreads-1,FTestCnt-1);i++) AddThread(); for (int i=0;i<FThreads.Count;i++) ((Threading::Thread^)FThreads[i])->Join(INFINITE); @@ -671,7 +670,8 @@ } fopen_s(&f,buf=StrToArr(path),"rt"); fscanf_s(f,"CodeLimit: %d\nCompilationTimeLimit: %d\nMemoryLimit: %d\n",&FLim.CodeLimit,&FLim.CompilationTimeLimit,&FLim.MemoryLimit); - fscanf_s(f,"OutputLimit: %d\nRealTimeLimit: %d\nTimeLimit: %d",&FLim.OutputLimit,&FLim.RealTimeLimit,&FLim.TimeLimit); + fscanf_s(f,"OutputLimit: %d\nRealTimeLimit: %d\nTimeLimit: %d\n",&FLim.OutputLimit,&FLim.RealTimeLimit,&FLim.TimeLimit); + fscanf_s(f,"MaxThreads: %d",&FLim.MaxThreads); }__finally { fclose(f); Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-22 08:35:12 UTC (rev 275) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-22 18:43:23 UTC (rev 276) @@ -27,6 +27,7 @@ int RealTimeLimit; //maximum real time int CompilationTimeLimit; //maximum time for compilation int CodeLimit; //maximum source size + int MaxThreads; //maximum paralle threads TLimits() { @@ -294,7 +295,7 @@ void init() { cs=new CRITICAL_SECTION; - InitializeCriticalSection(cs); + InitializeCriticalSectionAndSpinCount(cs,100); } void lock() @@ -652,6 +653,7 @@ { lock(); FTempPath=value; + System::IO::Directory::CreateDirectory(FTempPath); }__finally { unlock(); Modified: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-22 08:35:12 UTC (rev 275) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-22 18:43:23 UTC (rev 276) @@ -4,3 +4,4 @@ OutputLimit: 1024 RealTimeLimit: 100000 TimeLimit: 500 +MaxThreads: 4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-06-29 17:37:49
|
Revision: 287 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=287&view=rev Author: Oracle_ Date: 2008-06-29 10:37:55 -0700 (Sun, 29 Jun 2008) Log Message: ----------- Fixed bug with big outputs, updated source. Modified Paths: -------------- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp ACMServer/trunk/sharp tester/SourceTest/SourceTest.h ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp ACMServer/trunk/sharp tester/TestLibrary/dllmain.cpp ACMServer/trunk/sharp tester/tester/Program.cs ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-06-29 17:37:55 UTC (rev 287) @@ -2,7 +2,6 @@ #include "stdafx.h" //#define _WIN32_WINNT 0x0500 //need for easy compiling on different machine -#include <stdio.h> #include "SourceTest.h" #include <LM.h> #include <Aclapi.h> @@ -36,74 +35,58 @@ System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(buf)); } -String^ ToStr(int x) //fast convert integer to Managed String +String^ ReadFullFile(String^ filename) { - char intg[15]; - _itoa_s(x,intg,10); - return %String(intg); -} - -bool FileExists(String^ path) //checks whether file exists or not -{ - char* buf=StrToArr(path); - OFSTRUCT of; - ZeroMemory(&of,sizeof(of)); - of.cBytes=sizeof(of); - bool res=(OpenFile(buf,&of,OF_EXIST)!=HFILE_ERROR); - FreeArr(buf); + StreamReader^ r; + int cycle=0; + while (cycle<1000) + { + ++cycle; + try + { + r=File::OpenText(filename); + } catch (...) + { + Sleep(1); + continue; + } + break; + } + if (r->Equals(StreamReader::Null)) + return ""; + String^ res=r->ReadToEnd(); + delete (IDisposable^)r; return res; } -String^ ReadFullFile(String^ filename) -{ - HANDLE h; - wchar_t* bufW=StrToArrW(filename); - int cycle=0; - do - { - h=CreateFile(bufW,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); - Sleep(1); - ++cycle; - } while (h==INVALID_HANDLE_VALUE&&cycle<100); - if (h==INVALID_HANDLE_VALUE) - return ""; - FreeArr(bufW); - DWORD size=GetFileSize(h,NULL); - char* res=new char[size+20];ZeroMemory(res,(size+2)*sizeof(char)); - char* buf=new char[size+20]; - DWORD curlen=0; - cycle=0; - do - { - ZeroMemory(buf, (size+20)*sizeof(char)); - DWORD rlen=0; - ReadFile(h,buf,size,&rlen,NULL); - curlen+=rlen; - strcat_s(res,size+10,buf); - Sleep(1); - ++cycle; - } while (curlen<size&&cycle<100); - CloseHandle(h); - String^ r=gcnew String(res); - delete[] res; - delete[] buf; - if (curlen<size) - return ""; - return r; -} - TSource::TSource() { -FSrc=gcnew String(""); -FExePath=gcnew String(""); -FProblemPath=gcnew String(""); -FState=ssNone; -FCompPath=gcnew String(""); +FSrc=""; +FExePath=""; +FProblemPath=""; +FState=TSourceState::ssNone; +FCompPath=""; FRunAll=true; -lib=LoadLibraryA("TestLibrary.dll"); +FLim=gcnew TLimits(); +FRes=gcnew ArrayList(); +FLang=TLang::lPascal; +FSummary=gcnew TSummary(); +FThreads=gcnew ArrayList(); +FCompResult=gcnew TCompResult(); + +if ((lib=LoadLibrary(L"TestLibrary.dll"))!=NULL) +{ + DLLFreeChar=(TFreeFunc)GetProcAddress(lib,"FreeChar"); + DLLCheckCL=(TCheckSrc)GetProcAddress(lib,"CheckCL"); + DLLCheckDF=(TCheckSrc)GetProcAddress(lib,"CheckDF"); + DLLCheckAnswer=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); + DLLCheckTL=(TCheckLim)GetProcAddress(lib,"CheckTL"); + DLLCheckRTL=(TCheckLim)GetProcAddress(lib,"CheckRTL"); +} FSecurity=NULL; InitSecure(false); init(); //initializing of critical section +SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); } void TSource::InitSecure(bool SetPrivAnyway) @@ -118,47 +101,44 @@ if (lib!=NULL) FreeLibrary(lib); delete FSecurity; -FRes.Clear(); -FThreads.Clear(); +FRes->Clear(); +FThreads->Clear(); final(); +SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS); } void TSource::CheckCL() //checking size of source { if (lib==NULL) //no library was found { - if (FSrc->Length>FLim.CodeLimit) - FCompResult.res=crCL; - FCompResult.Details+="Used std checker for Code Limit\n"; + if (FSrc->Length>FLim->CodeLimit) + FCompResult->res=TCompRes::crCL; + FCompResult->Details+="Used std checker for Code Limit\n"; } else { - TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckCL"); char* buf,*bufA; - if (prc(bufA=StrToArr(FSrc),FLim.CodeLimit,buf)) FCompResult.res=crCL; + if (DLLCheckCL(bufA=StrToArr(FSrc),FLim->CodeLimit,buf)) FCompResult->res=TCompRes::crCL; FreeArr(bufA); - FCompResult.Details+=gcnew String(buf); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - prc2(buf); + FCompResult->Details+=gcnew String(buf); + DLLFreeChar(buf); } - FState=ssCheckedCL; + FState=TSourceState::ssCheckedCL; } void TSource::CheckDF() //checking for DF in source { if (lib==NULL) //no library was found { - FCompResult.Details+="No checker for DF\n"; + FCompResult->Details+="No checker for DF\n"; } else { - TCheckSrc prc=(TCheckSrc)GetProcAddress(lib,"CheckDF"); char* buf,*bufA; - if (prc(bufA=StrToArr(FSrc),(int)FLang,buf)) FCompResult.res=crDF; + if (DLLCheckDF(bufA=StrToArr(FSrc),(int)FLang,buf)) FCompResult->res=TCompRes::crDF; FreeArr(bufA); - FCompResult.Details+=gcnew String(buf); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - prc2(buf); + FCompResult->Details+=gcnew String(buf); + DLLFreeChar(buf); } - FState=ssCheckedDF; + FState=TSourceState::ssCheckedDF; } void TSource::Compile() //compiles the source @@ -177,7 +157,7 @@ String^ outpath=gcnew String(FTempPath+"compoutput.txt"); FExePath=FTempPath+"source.exe"; - if (FileExists(FExePath)) //delete previsious source + if (File::Exists(FExePath)) //delete previsious source { DeleteFile((LPCTSTR)(bufW=StrToArrW(FExePath))); FreeArr(bufW); @@ -203,35 +183,35 @@ if (!CreateProcess(NULL,bufW,&sec,&sec,true,CREATE_NEW_CONSOLE|CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) { FreeArr(bufW); - FCompResult.res=crIE; - FCompResult.Details+="Can not run the compiler\n"; + FCompResult->res=TCompRes::crIE; + FCompResult->Details+="Can not run the compiler\n"; return; } FreeArr(bufW); - if (WaitForSingleObject(pi.hProcess,FLim.CompilationTimeLimit)==WAIT_TIMEOUT) + if (WaitForSingleObject(pi.hProcess,FLim->CompilationTimeLimit)==WAIT_TIMEOUT) { TerminateProcess(pi.hProcess,0); - FCompResult.res=crCTL; - FCompResult.UsedTime=FLim.CompilationTimeLimit; - FCompResult.Details+="Time out during compilation\n"; + FCompResult->res=TCompRes::crCTL; + FCompResult->UsedTime=FLim->CompilationTimeLimit; + FCompResult->Details+="Time out during compilation\n"; return; } - FCompResult.UsedTime=GetTickCount()-start; + FCompResult->UsedTime=GetTickCount()-start; Sleep(CONST_SLEEP); //waiting for creating the file CloseHandle(si.hStdOutput); si.hStdOutput=NULL; - if (!FileExists(FExePath)) //compilation error + if (!File::Exists(FExePath)) //compilation error { - FCompResult.res=crCE; - FCompResult.Details+="EXE file not found\n"+ReadFullFile(outpath); + FCompResult->res=TCompRes::crCE; + FCompResult->Details+="EXE file not found\n"+ReadFullFile(outpath); return; } - FCompResult.Details+=ReadFullFile(outpath); + FCompResult->Details+=ReadFullFile(outpath); - }__finally + }finally { if (pi.hProcess!=NULL) CloseHandle(pi.hProcess); @@ -239,14 +219,14 @@ CloseHandle(pi.hThread); if (si.hStdOutput!=NULL) CloseHandle(si.hStdOutput); - FState=ssCompiled; + FState=TSourceState::ssCompiled; } } void TSource::AddThread() { Threading::Thread^ t=gcnew Threading::Thread(gcnew System::Threading::ThreadStart(this,&TSource::ThreadProc)); - FThreads.Add(t); + FThreads->Add(t); t->Start(); } @@ -266,7 +246,7 @@ Summary->res->UsedMemory=max(Results[n-1]->UsedMemory,Summary->res->UsedMemory); Summary->res->UsedTime=max(Results[n-1]->UsedTime,Summary->res->UsedTime); Summary->res->UsedRealTime=max(Results[n-1]->UsedRealTime,Summary->res->UsedRealTime); - if (Results[n-1]->res!=trAC) + if (Results[n-1]->res!=TRes::trAC) { Summary->res->res=Results[n-1]->res; if (!RunAll) { NeedTest=false; break; } @@ -281,40 +261,40 @@ void TSource::RunTests() //runs all tests of problem { - FState=ssIsRunning; + FState=TSourceState::ssIsRunning; CurrentTest=0; NeedTest=true; FTestCnt=1; - FRes.Clear(); - while (FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\in.txt")||FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\out.txt")||FileExists(FProblemPath+"test"+ToStr(FTestCnt)+"\\points.txt")) + FRes->Clear(); + while (File::Exists(FProblemPath+"test"+FTestCnt.ToString()+"\\in.txt")||File::Exists(FProblemPath+"test"+FTestCnt.ToString()+"\\out.txt")||File::Exists(FProblemPath+"test"+FTestCnt.ToString()+"\\points.txt")) { - FRes.Add(%TResult()); + FRes->Add(%TResult()); FTestCnt++; } - FThreads.Clear(); - for (int i=0;i<min(FLim.MaxThreads-1,FTestCnt-1);i++) + FThreads->Clear(); + for (int i=0;i<min(FLim->MaxThreads,FTestCnt-1);i++) AddThread(); - for (int i=0;i<FThreads.Count;i++) + for (int i=0;i<FThreads->Count;i++) ((Threading::Thread^)FThreads[i])->Join(INFINITE); - FState=ssFinish; + FState=TSourceState::ssFinish; } -void TSource::LoadTest(int index,TTest% test) //loads test from file +void TSource::LoadTest(int index,TTest^ test) //loads test from file { try { lock(); - if (FileExists(FProblemPath+"test"+ToStr(index)+"\\in.txt")) - test.input=ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\in.txt"); else - test.input=""; - if (FileExists(FProblemPath+"test"+ToStr(index)+"\\out.txt")) - test.output=ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\out.txt"); else - test.output=""; - if (FileExists(FProblemPath+"test"+ToStr(index)+"\\points.txt")) - test.points.Parse(ReadFullFile(FProblemPath+"test"+ToStr(index)+"\\points.txt")); else - test.points=1; -}__finally + if (File::Exists(FProblemPath+"test"+index.ToString()+"\\in.txt")) + test->input=ReadFullFile(FProblemPath+"test"+index.ToString()+"\\in.txt"); else + test->input=""; + if (File::Exists(FProblemPath+"test"+index.ToString()+"\\out.txt")) + test->output=ReadFullFile(FProblemPath+"test"+index.ToString()+"\\out.txt"); else + test->output=""; + if (File::Exists(FProblemPath+"test"+index.ToString()+"\\points.txt")) + test->points=int::Parse(ReadFullFile(FProblemPath+"test"+index.ToString()+"\\points.txt")); else + test->points=1; +}finally { unlock(); } @@ -324,25 +304,23 @@ { try { - TTest t; + TTest^ t=gcnew TTest(); LoadTest(index,t); lock(); if (lib==NULL) //lib was not found { - if (output!=t.output) + if (output!=t->output) return carWA; return carAC; } else { char* buf1,*buf2,*buf3,*buf4=NULL; - TCheckAnswer prc=(TCheckAnswer)GetProcAddress(lib,"CheckAnswer"); - TCheckAnsRes res=(TCheckAnsRes)prc(buf1=StrToArr(t.input),buf2=StrToArr(output),buf3=StrToArr(t.output),buf4); + TCheckAnsRes res=(TCheckAnsRes)DLLCheckAnswer(buf1=StrToArr(t->input),buf2=StrToArr(output),buf3=StrToArr(t->output),buf4); Details+=gcnew String(buf4); - TFreeFunc prc2=(TFreeFunc)GetProcAddress(lib,"FreeChar"); - FreeArr(buf1);FreeArr(buf2);FreeArr(buf3);prc2(buf4); + FreeArr(buf1);FreeArr(buf2);FreeArr(buf3);DLLFreeChar(buf4); return res; } -} __finally +} finally { unlock(); } @@ -355,9 +333,8 @@ lock(); if (lib==NULL) return usedtime>timelimit; - TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckTL"); - return prc(usedtime,timelimit); -}__finally + return DLLCheckTL(usedtime,timelimit); +}finally { unlock(); } @@ -369,9 +346,8 @@ lock(); if (lib==NULL) return usedrealtime>realtimelimit; - TCheckLim prc=(TCheckLim)GetProcAddress(lib,"CheckRTL"); - return prc(usedrealtime,realtimelimit); -}__finally + return DLLCheckRTL(usedrealtime,realtimelimit); +}finally { unlock(); } @@ -382,18 +358,18 @@ try { CheckCL(); - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) CheckDF(); else return ; - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) Compile(); else return ; - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) RunTests(); else return ; -} __finally +} finally { - (*FSummary.compres)=FCompResult; + FSummary->compres=FCompResult; } } @@ -431,16 +407,16 @@ wchar_t* bufW; try { - Results[index-1]->res=trAC; + Results[index-1]->res=TRes::trAC; Results[index-1]->points=0; Results[index-1]->Details=""; Results[index-1]->UsedMemory=-1; Results[index-1]->UsedRealTime=-1; Results[index-1]->UsedTime=-1; - String^ inpath=ProblemPath+"test"+ToStr(index)+"\\in.txt"; - String^ oupath=TempPath+"out"+ToStr(index)+".txt"; - String^ erpath=TempPath+"err"+ToStr(index)+".txt"; - String^ pointpath=ProblemPath+"test"+ToStr(index)+"\\points.txt"; + String^ inpath=ProblemPath+"test"+index.ToString()+"\\in.txt"; + String^ oupath=TempPath+"out"+index.ToString()+".txt"; + String^ erpath=TempPath+"err"+index.ToString()+".txt"; + String^ pointpath=ProblemPath+"test"+index.ToString()+"\\points.txt"; si.cb=sizeof(si); si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; @@ -451,18 +427,18 @@ SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); lock(); - if (!FSecurity->RunProcess(bufW=StrToArrW(ExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|HIGH_PRIORITY_CLASS,&si,&pi,Results[index-1]->Details)) + if (!FSecurity->RunProcess(bufW=StrToArrW(ExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS,&si,&pi,Results[index-1]->Details)) { FreeArr(bufW); Results[index-1]->points=0; int err=GetLastError(); if ((err==193)||(err==1455)) { - Results[index-1]->res=trRE; + Results[index-1]->res=TRes::trRE; Results[index-1]->Details+="Too large array"; } else { - Results[index-1]->res=trIE; + Results[index-1]->res=TRes::trIE; Results[index-1]->Details+="Can not start process"; } unlock(); @@ -483,8 +459,6 @@ AssignProcessToJobObject(job,pi.hProcess); - SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL); - ResumeThread(pi.hThread); DWORD start=GetTickCount(); @@ -493,7 +467,7 @@ if ((int)GetFileSize(si.hStdOutput,NULL)>Lim->OutputLimit) { TerminateJobObject(job,0); - Results[index-1]->res=trOL; + Results[index-1]->res=TRes::trOL; Results[index-1]->Details+="Size of output file excided OutputLimit"; break; } @@ -501,14 +475,14 @@ if (CheckRTL((int)(GetTickCount()-start),Lim->RealTimeLimit)) { TerminateJobObject(job,0); - Results[index-1]->res=trRTL; + Results[index-1]->res=TRes::trRTL; Results[index-1]->Details+="Real time limit"; break; } if (CheckTL((int)(acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart),Lim->TimeLimit*10000)) { TerminateJobObject(job,0); - Results[index-1]->res=trTL; + Results[index-1]->res=TRes::trTL; Results[index-1]->Details+="Time Limit"; break; } @@ -525,18 +499,18 @@ GetExitCodeProcess(pi.hProcess,&code); if (code==5) { - Results[index-1]->res=trDF; + Results[index-1]->res=TRes::trDF; Results[index-1]->Details+="Access denied."; } else if (code!=0) { - Results[index-1]->res=trRE; - Results[index-1]->Details+="Runtime error #"+ToStr((int)code); + Results[index-1]->res=TRes::trRE; + Results[index-1]->Details+="Runtime error #"+code.ToString(); } needbreak=true; break; case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: - Results[index-1]->res=trML; + Results[index-1]->res=TRes::trML; Results[index-1]->Details+="Memory Limit"; needbreak=true; break; @@ -544,13 +518,13 @@ GetExitCodeProcess(pi.hProcess,&code); if (code==5) { - Results[index-1]->res=trDF; + Results[index-1]->res=TRes::trDF; Results[index-1]->Details+="Access denied."; } else if (code!=0) { - Results[index-1]->res=trRE; - Results[index-1]->Details+="Runtime error #"+ToStr((int)code); + Results[index-1]->res=TRes::trRE; + Results[index-1]->Details+="Runtime error #"+code.ToString(); } needbreak=true; break; @@ -563,8 +537,6 @@ } Sleep(1); } - - SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL); CloseHandle(si.hStdOutput);si.hStdOutput=NULL; CloseHandle(si.hStdInput);si.hStdInput=NULL; @@ -576,11 +548,11 @@ Results[index-1]->UsedMemory=mem.PeakProcessMemoryUsed; Results[index-1]->UsedTime=(int)((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)/10000); Results[index-1]->UsedRealTime=GetTickCount()-start; - if (Results[index-1]->res!=trAC) return; + if (Results[index-1]->res!=TRes::trAC) return; - if (!FileExists(oupath)) + if (!File::Exists(oupath)) { - Results[index-1]->res=trWA; + Results[index-1]->res=TRes::trWA; Results[index-1]->Details+="No output file"; return; } @@ -591,7 +563,7 @@ if (r==carAC) { - if (FileExists(pointpath)) + if (File::Exists(pointpath)) Results[index-1]->points.Parse(ReadFullFile(pointpath)); else Results[index-1]->points=1; return ; @@ -600,20 +572,20 @@ switch (r) { case carOE: - Results[index-1]->res=trOE; + Results[index-1]->res=TRes::trOE; break; case carPE: - Results[index-1]->res=trPE; + Results[index-1]->res=TRes::trPE; break; case carWA: - Results[index-1]->res=trWA; + Results[index-1]->res=TRes::trWA; break; case carIE: - Results[index-1]->res=trIE; + Results[index-1]->res=TRes::trIE; break; }; -}__finally +}finally { if (pi.hProcess!=NULL) CloseHandle(pi.hProcess); @@ -639,62 +611,79 @@ try { CheckCL(); - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) CheckDF(); else return ; - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) Compile(); else return ; - if (FCompResult.res==crOK) + if (FCompResult->res==TCompRes::crOK) RunTest(index); else return ; -} __finally +} finally { - (*FSummary.compres)=FCompResult; + FSummary->compres=FCompResult; } } void TSource::LoadLimits() { String^ path=FProblemPath+"Limits.txt"; - if (!FileExists(path)) + if (!File::Exists(path)) return; - char* buf; - FILE* f; - try + if (FState!=TSourceState::ssNone) { - if (FState!=ssNone) - { - throw "Can not load limits if state is higher than ssNone"; - return; - } - fopen_s(&f,buf=StrToArr(path),"rt"); - fscanf_s(f,"CodeLimit: %d\nCompilationTimeLimit: %d\nMemoryLimit: %d\n",&FLim.CodeLimit,&FLim.CompilationTimeLimit,&FLim.MemoryLimit); - fscanf_s(f,"OutputLimit: %d\nRealTimeLimit: %d\nTimeLimit: %d\n",&FLim.OutputLimit,&FLim.RealTimeLimit,&FLim.TimeLimit); - fscanf_s(f,"MaxThreads: %d",&FLim.MaxThreads); - }__finally - { - fclose(f); - FreeArr(buf); + throw "Can not load limits if state is higher than ssNone"; + return; } + StreamReader^ r=File::OpenText(path); + String^ buf=r->ReadLine(); + int i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->CodeLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->CompilationTimeLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->MemoryLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->OutputLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->RealTimeLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->TimeLimit=int::Parse(buf->Substring(i,buf->Length-i)); + + buf=r->ReadLine();i=0; + while (!((buf[i]>='0')&&(buf[i]<='9'))) i++; + FLim->MaxThreads=int::Parse(buf->Substring(i,buf->Length-i)); + r->Close(); } String^ TSource::TestResultToString(TRes res) { switch (res) { - case trAC:return "Accepted"; - case trWA:return "Wrong Answer"; - case trTL:return "Time Limit"; - case trML:return "Memory Limit"; - case trRTL:return "Real Time Limit"; - case trRE:return "Runtime Error"; - case trDF:return "Destricted Function"; - case trIE:return "Internal Error"; - case trOL:return "Output Limit"; - case trPE:return "Presentation Error"; - case trOE:return "Output Error"; + case TRes::trAC:return "Accepted"; + case TRes::trWA:return "Wrong Answer"; + case TRes::trTL:return "Time Limit"; + case TRes::trML:return "Memory Limit"; + case TRes::trRTL:return "Real Time Limit"; + case TRes::trRE:return "Runtime Error"; + case TRes::trDF:return "Destricted Function"; + case TRes::trIE:return "Internal Error"; + case TRes::trOL:return "Output Limit"; + case TRes::trPE:return "Presentation Error"; + case TRes::trOE:return "Output Error"; default:return "Unknown Error"; } } @@ -703,12 +692,12 @@ { switch (res) { - case crOK:return "No Error"; - case crCE:return "Compilation Error"; - case crCL:return "Code Limit"; - case crCTL:return "Compilation Time Limit"; - case crDF:return "Destricted Function"; - case crIE:return "Internal Error"; + case TCompRes::crOK:return "No Error"; + case TCompRes::crCE:return "Compilation Error"; + case TCompRes::crCL:return "Code Limit"; + case TCompRes::crCTL:return "Compilation Time Limit"; + case TCompRes::crDF:return "Destricted Function"; + case TCompRes::crIE:return "Internal Error"; default:return "Unknown Error"; } } Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.h =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.h 2008-06-29 17:37:55 UTC (rev 287) @@ -64,7 +64,7 @@ ///TCompRes is all possible results of compilation ///</summary> - public enum TCompRes //result of compilation + public enum class TCompRes //result of compilation { crOK, //all ok crCE, //compilation error @@ -78,7 +78,7 @@ ///TRes is all possible results of running the source ///</summary> - public enum TRes + public enum class TRes { trAC, //accepted trWA, //wrong answer @@ -108,7 +108,7 @@ TResult() { - res=trAC; + res=TRes::trAC; points=0; UsedMemory=0; UsedTime=0; @@ -156,7 +156,7 @@ TCompResult() { - res=crOK; + res=TCompRes::crOK; UsedTime=0; Details=""; } @@ -173,7 +173,7 @@ ///TSourceState is all possible states of source during its testing ///</summary> - public enum TSourceState + public enum class TSourceState { ssNone=0, //no actions were taken ssCheckedCL=1, //CodeLimit checked @@ -236,7 +236,7 @@ ///TLang is all possible languages of source (needed for CheckDF) ///</summary> - public enum TLang + public enum class TLang { lCpp=0, lPascal=1 @@ -275,10 +275,10 @@ String^ FTempPath; //this is the place where temporary files will be created bool FRunAll; //if true then all tests will run (no matter on errors) TSourceState FState; //state of source - TCompResult FCompResult; //result of compilation - ArrayList FRes; //results of each test *MT* - TSummary FSummary; //summary results of all tests *MT* - TLimits FLim; //limits for testing + TCompResult^ FCompResult; //result of compilation + ArrayList^ FRes; //results of each test *MT* + TSummary^ FSummary; //summary results of all tests *MT* + TLimits^ FLim; //limits for testing TTestHandler^ FTestHandler; //event, that occures when test is completed *MT* TLang FLang; //language of source TSecure *FSecurity; //security class *MT* @@ -290,12 +290,18 @@ //int CheckAnswer(char* input, char* output, char* rightoutput, char*& Details) - checks WA,OE,PE //void FreeChar(char* buf); - must free memory used by buf //if there is no library called TestLibrary.dll then standart check is performed + TFreeFunc DLLFreeChar; + TCheckSrc DLLCheckCL; + TCheckSrc DLLCheckDF; + TCheckAnswer DLLCheckAnswer; + TCheckLim DLLCheckTL; + TCheckLim DLLCheckRTL; CRITICAL_SECTION* cs; //for multithreading void init() { cs=new CRITICAL_SECTION; - InitializeCriticalSectionAndSpinCount(cs,100); + InitializeCriticalSectionAndSpinCount(cs,5); } void lock() @@ -319,7 +325,7 @@ int FCurrentTest; //current test for testing *MT* bool FNeedTest; //if found WA, or all test completed *MT* int FTestCnt; - ArrayList FThreads; + ArrayList^ FThreads; property int CurrentTest { void set(int value) @@ -328,7 +334,7 @@ { lock(); FCurrentTest=value; - }__finally + }finally { unlock(); } @@ -340,7 +346,7 @@ { lock(); return FCurrentTest; - }__finally + }finally { unlock(); } @@ -355,7 +361,7 @@ { lock(); FNeedTest=value; - }__finally + }finally { unlock(); } @@ -367,7 +373,7 @@ { lock(); return FNeedTest; - }__finally + }finally { unlock(); } @@ -380,7 +386,7 @@ { lock(); return FTestCnt; - } __finally + } finally { unlock(); } @@ -401,7 +407,7 @@ TCheckAnsRes CheckAnswer(int index,String^ output, String^% Details); void ProcessAll(); //gets result for all tests void ProcessTest(int index); //gets result for only 1 test - void LoadTest(int index,TTest% test); //load test from file + void LoadTest(int index,TTest^ test); //load test from file void LoadLimits(); //loads limits from a file Limits.txt static String^ TestResultToString(TRes res); static String^ CompileResultToString(TCompRes res); @@ -413,9 +419,9 @@ try { lock(); - FLim=(*value); + FLim=value; } - __finally { + finally { unlock(); } } @@ -424,9 +430,9 @@ try { lock(); - return %FLim; + return FLim; } - __finally { + finally { unlock(); } } @@ -440,7 +446,7 @@ { lock(); return FSrc; - }__finally { + }finally { unlock(); } } @@ -451,7 +457,7 @@ { lock(); FSrc=value; - } __finally { + } finally { unlock(); } } @@ -465,7 +471,7 @@ { lock(); return FExePath; - }__finally{ + }finally{ unlock(); } } @@ -478,7 +484,7 @@ { lock(); return FProblemPath; - }__finally { + }finally { unlock(); } } @@ -488,7 +494,7 @@ try{ lock(); FProblemPath=value; - }__finally { + }finally { unlock(); } } @@ -501,8 +507,8 @@ try { lock(); - return %FCompResult; - }__finally { + return FCompResult; + }finally { unlock(); } } @@ -514,8 +520,8 @@ try { lock(); - return (FState); - }__finally { + return FState; + }finally { unlock(); } }; @@ -525,7 +531,7 @@ { lock(); FState=(value); - }__finally { + }finally { unlock(); } }; @@ -538,14 +544,14 @@ try { lock(); - if (index>=FRes.Count) + if (index>=FRes->Count) { throw "The index is not accesible"; return (%TResult()); } return (TResult^)FRes[index]; } - __finally + finally { unlock(); } @@ -559,8 +565,8 @@ try { lock(); - return (%FSummary); - }__finally + return FSummary; + }finally { unlock(); } @@ -571,9 +577,9 @@ try { lock(); - FSummary=(*value); + FSummary=value; } - __finally { + finally { unlock(); } } @@ -587,7 +593,7 @@ { lock(); return FTestHandler; - }__finally + }finally { unlock(); } @@ -599,7 +605,7 @@ { lock(); FTestHandler=value; - }__finally + }finally { unlock(); } @@ -614,7 +620,7 @@ { lock(); return (FCompPath); - }__finally + }finally { unlock(); } @@ -626,7 +632,7 @@ { lock(); FCompPath=value; - }__finally + }finally { unlock(); } @@ -641,7 +647,7 @@ { lock(); return FTempPath; - }__finally + }finally { unlock(); } @@ -654,7 +660,7 @@ lock(); FTempPath=value; System::IO::Directory::CreateDirectory(FTempPath); - }__finally + }finally { unlock(); } @@ -669,7 +675,7 @@ { lock(); FRunAll=value; - } __finally + } finally { unlock(); } @@ -681,7 +687,7 @@ { lock(); return FRunAll; - }__finally + }finally { unlock(); } @@ -696,7 +702,7 @@ { lock(); FLang=value; - } __finally + } finally { unlock(); } @@ -708,7 +714,7 @@ { lock(); return FLang; - }__finally + }finally { unlock(); } Modified: ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp =================================================================== --- ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/TestLibrary/TestLibrary.cpp 2008-06-29 17:37:55 UTC (rev 287) @@ -7,14 +7,14 @@ TESTLIBRARY_API bool CheckCL(char* src, int cl, char*& details) { details=new char[20]; - strcpy_s(details,20,"CheckCL from DLL\n"); + strcpy_s(details,20,"DLLCheckCL"); return ((int)strlen(src)>cl); } TESTLIBRARY_API bool CheckDF(char* src, int lang, char*& details) { details=new char[20]; - strcpy_s(details,20,"CheckDF from DLL\n"); + strcpy_s(details,20,"DLLCheckDF"); return false; } @@ -38,10 +38,7 @@ if (strcmp(output,rightoutput)==0) return 0; Details=new char[30]; - strcpy(Details,output); - strcat(Details," RIGHT: "); - strcat(Details,rightoutput); - strcat(Details,"\n"); + strcpy_s(Details,30,"DLLCheckAns"); int curo=0; for (int i=0;;i++,curo++) { Modified: ACMServer/trunk/sharp tester/TestLibrary/dllmain.cpp =================================================================== --- ACMServer/trunk/sharp tester/TestLibrary/dllmain.cpp 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/TestLibrary/dllmain.cpp 2008-06-29 17:37:55 UTC (rev 287) @@ -1,7 +1,7 @@ // dllmain.cpp : Defines the entry point for the DLL application. #pragma once #include "stdafx.h" -#include <stdio.h> +#include <fstream> extern double TLx,TLk; BOOL APIENTRY DllMain( HMODULE hModule, @@ -12,18 +12,18 @@ switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - FILE* f; + { TLx=0;TLk=1; - if (fopen_s(&f,"Times.txt","rt")==0) + std::ifstream f("Times.txt"); + if (!f.bad()) { - fscanf_s(f,"%Lf %Lf",&TLk,&TLx); - fclose(f); + f>>TLk>>TLx; + f.close(); } - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; + } + case DLL_THREAD_ATTACH:; + case DLL_THREAD_DETACH:; + case DLL_PROCESS_DETACH:; } return TRUE; } \ No newline at end of file Modified: ACMServer/trunk/sharp tester/tester/Program.cs =================================================================== --- ACMServer/trunk/sharp tester/tester/Program.cs 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/tester/Program.cs 2008-06-29 17:37:55 UTC (rev 287) @@ -38,47 +38,52 @@ { DateTime start=DateTime.Now; MiniMax rt=new MiniMax(),t=new MiniMax(),mem=new MiniMax(),ct=new MiniMax(); - //for (int i = 0; i < 10000; i++) + for (int i = 0; i < 1; i++) { - TSource c = new TSource(); StreamReader s = new StreamReader("InData.txt", Encoding.Default); String compiler = s.ReadLine(); String problem = s.ReadLine(); String temp = s.ReadLine(); String source = s.ReadLine(); s.Close(); - s = File.OpenText(source); - c.CompPath = compiler; - c.ProblemPath = problem; - c.LoadLimits(); - c.Src = s.ReadToEnd(); - s.Close(); - c.TempPath = temp; - c.TestHandler += new TTestHandler(func); - c.Language = (TLang)1; - c.ProcessAll(); - c.State = (TSourceState)6; - Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res),c.Summary.compres.Details,c.Summary.compres.UsedTime); - Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); - Console.WriteLine("Points: {0}", c.Summary.res.points); - Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); - Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); - Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); - //Console.ReadKey(); - Console.WriteLine(" CompRes: {0}, TestRes: {1}", TSource.CompileResultToString(c.Summary.compres.res), TSource.TestResultToString(c.Summary.res.res)); + int index=1; + while (File.Exists(Path.GetDirectoryName(source) + "\\" + Path.GetFileNameWithoutExtension(source) + index.ToString() + Path.GetExtension(source))) + { + Console.WriteLine("----------------------------------------------------------------"); + Console.WriteLine("------------------------Test Number {0}-------------------------", index); + Console.WriteLine("----------------------------------------------------------------"); + s = File.OpenText(Path.GetDirectoryName(source) + "\\" + Path.GetFileNameWithoutExtension(source) + index.ToString() + Path.GetExtension(source)); + TSource c = new TSource(); + c.CompPath = compiler; + c.ProblemPath = problem; + c.LoadLimits(); + c.Src = s.ReadToEnd(); + s.Close(); + c.TempPath = temp; + c.TestHandler += new TTestHandler(func); + c.Language = TLang.lPascal; + c.ProcessAll(); + c.State = TSourceState.ssFinish; + Console.WriteLine("Compile result: {0}\nCompilation details: {1}\nUsed Time for compile: {2}", TSource.CompileResultToString(c.Summary.compres.res), c.Summary.compres.Details, c.Summary.compres.UsedTime); + Console.WriteLine("Test result: {0}", TSource.TestResultToString(c.Summary.res.res)); + Console.WriteLine("Points: {0}", c.Summary.res.points); + Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); + Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); + Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); + //Console.ReadKey(); + index++; + c.Dispose(); + } + /*Console.WriteLine(" CompRes: {0}, TestRes: {1}", TSource.CompileResultToString(c.Summary.compres.res), TSource.TestResultToString(c.Summary.res.res)); rt.update(c.Summary.res.UsedRealTime); t.update(c.Summary.res.UsedTime); ct.update(c.Summary.compres.UsedTime); - mem.update(c.Summary.res.UsedMemory); - /*if (c.Summary.res.res != 0) - { - System.Media.SystemSounds.Beep.Play(); - Console.ReadKey(); - }*/ + mem.update(c.Summary.res.UsedMemory);*/ + } - Console.WriteLine("Used Time: {0} ms", (System.DateTime.Now.Ticks - start.Ticks)/10000); + /*Console.WriteLine("Used Time: {0} ms", (System.DateTime.Now.Ticks - start.Ticks)/10000); Console.WriteLine("MAX: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte", ct.max, t.max, rt.max, mem.max); - Console.WriteLine("Diff: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte",ct.diff(),t.diff(),rt.diff(),mem.diff()); + Console.WriteLine("Diff: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte",ct.diff(),t.diff(),rt.diff(),mem.diff());*/ Console.ReadKey(); } } Modified: ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt =================================================================== --- ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-28 12:23:27 UTC (rev 286) +++ ACMServer/trunk/sharp tester/tester/SAMPLE/Test/limits.txt 2008-06-29 17:37:55 UTC (rev 287) @@ -1,7 +1,7 @@ CodeLimit: 1024 CompilationTimeLimit: 10000 -MemoryLimit: 10000000 +MemoryLimit: 21000000 OutputLimit: 1024 RealTimeLimit: 100000 -TimeLimit: 500 +TimeLimit: 1000 MaxThreads: 4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Or...@us...> - 2008-07-08 18:41:28
|
Revision: 292 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=292&view=rev Author: Oracle_ Date: 2008-07-08 11:41:35 -0700 (Tue, 08 Jul 2008) Log Message: ----------- Source became more elegant. Modified Paths: -------------- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp ACMServer/trunk/sharp tester/tester/Program.cs Modified: ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp =================================================================== --- ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-07-06 20:49:54 UTC (rev 291) +++ ACMServer/trunk/sharp tester/SourceTest/SourceTest.cpp 2008-07-08 18:41:35 UTC (rev 292) @@ -427,7 +427,7 @@ SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); lock(); - if (!FSecurity->RunProcess(bufW=StrToArrW(ExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS,&si,&pi,Results[index-1]->Details)) + if (!FSecurity->RunProcess(bufW=StrToArrW(ExePath),TRUE,CREATE_SUSPENDED|CREATE_NO_WINDOW|ABOVE_NORMAL_PRIORITY_CLASS,&si,&pi,Results[index-1]->Details)) { FreeArr(bufW); Results[index-1]->points=0; @@ -447,8 +447,8 @@ FreeArr(bufW); unlock(); job=CreateJobObject(NULL,NULL); - mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_PROCESS_MEMORY; - mem.ProcessMemoryLimit=Lim->MemoryLimit; + mem.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_JOB_MEMORY; + mem.JobMemoryLimit=Lim->MemoryLimit; SetInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem)); port.CompletionKey=(void*)index; port.CompletionPort=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); @@ -468,7 +468,7 @@ { TerminateJobObject(job,0); Results[index-1]->res=TRes::trOL; - Results[index-1]->Details+="Size of output file excided OutputLimit"; + Results[index-1]->Details+="OutputLimit"; break; } QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); @@ -509,7 +509,7 @@ } needbreak=true; break; - case JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: + case JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: Results[index-1]->res=TRes::trML; Results[index-1]->Details+="Memory Limit"; needbreak=true; @@ -537,19 +537,40 @@ } Sleep(1); } - - CloseHandle(si.hStdOutput);si.hStdOutput=NULL; - CloseHandle(si.hStdInput);si.hStdInput=NULL; - Sleep(CONST_SLEEP); //waiting for file - + Results[index-1]->UsedRealTime=GetTickCount()-start; QueryInformationJobObject(job,JobObjectExtendedLimitInformation,&mem,sizeof(mem),NULL); QueryInformationJobObject(job,JobObjectBasicAccountingInformation,&acc,sizeof(acc),NULL); - Results[index-1]->UsedMemory=mem.PeakProcessMemoryUsed; + Results[index-1]->UsedMemory=mem.PeakJobMemoryUsed; Results[index-1]->UsedTime=(int)((acc.ThisPeriodTotalKernelTime.QuadPart+acc.ThisPeriodTotalUserTime.QuadPart)/10000); - Results[index-1]->UsedRealTime=GetTickCount()-start; + if (Results[index-1]->res!=TRes::trAC) return; + if ((int)GetFileSize(si.hStdOutput,NULL)>Lim->OutputLimit) + { + Results[index-1]->res=TRes::trOL; + Results[index-1]->Details+="OutputLimit"; + return; + } + if (CheckTL(Results[index-1]->UsedTime,Lim->TimeLimit)) + { + Results[index-1]->res=TRes::trTL; + Results[index-1]->Details+="Time Limit"; + return; + } + + if (CheckRTL(Results[index-1]->UsedRealTime,Lim->RealTimeLimit)) + { + Results[index-1]->res=TRes::trRTL; + Results[index-1]->Details+="Real time limit"; + return; + } + + CloseHandle(si.hStdOutput);si.hStdOutput=NULL; + CloseHandle(si.hStdInput);si.hStdInput=NULL; + + Sleep(CONST_SLEEP); //waiting for file + if (!File::Exists(oupath)) { Results[index-1]->res=TRes::trWA; @@ -557,7 +578,7 @@ return; } - //Sleep(CONST_SLEEP); //waiting for closing all handles to this file + Sleep(CONST_SLEEP); //waiting for closing all handles to this file TCheckAnsRes r=CheckAnswer(index,ReadFullFile(oupath),Results[index-1]->Details); Modified: ACMServer/trunk/sharp tester/tester/Program.cs =================================================================== --- ACMServer/trunk/sharp tester/tester/Program.cs 2008-07-06 20:49:54 UTC (rev 291) +++ ACMServer/trunk/sharp tester/tester/Program.cs 2008-07-08 18:41:35 UTC (rev 292) @@ -70,7 +70,7 @@ Console.WriteLine("Used Time: {0}", c.Summary.res.UsedTime); Console.WriteLine("Used Memory: {0}", c.Summary.res.UsedMemory); Console.WriteLine("Used Real Time: {0}", c.Summary.res.UsedRealTime); - //Console.ReadKey(); + Console.ReadKey(); index++; c.Dispose(); } @@ -84,6 +84,7 @@ /*Console.WriteLine("Used Time: {0} ms", (System.DateTime.Now.Ticks - start.Ticks)/10000); Console.WriteLine("MAX: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte", ct.max, t.max, rt.max, mem.max); Console.WriteLine("Diff: CompTime {0} ms, Time {1} ms, RealTime {2} ms, Memory {3} byte",ct.diff(),t.diff(),rt.diff(),mem.diff());*/ + Console.WriteLine("------------FINISH----------------"); Console.ReadKey(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |