Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TestServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
YAPEX
TestServer
Commits
a9ab492d
Commit
a9ab492d
authored
11 months ago
by
Janis Daniel Dähne
Browse files
Options
Downloads
Patches
Plain Diff
- removed ols/unused external checker test type
parent
b9636505
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api.php
+3
-25
3 additions, 25 deletions
api.php
constants.php
+1
-2
1 addition, 2 deletions
constants.php
do_externalCheckerTest_func.php
+0
-207
0 additions, 207 deletions
do_externalCheckerTest_func.php
with
4 additions
and
234 deletions
api.php
+
3
−
25
View file @
a9ab492d
...
...
@@ -671,31 +671,6 @@ foreach ($testCases as $test) {
addToDebugTimings
(
"after compare files test"
);
}
else
if
(
$arg_command
===
$s_command_externalCheckerTest
)
{
require_once
'./do_externalCheckerTest_func.php'
;
addToDebugTimings
(
"before external checker test"
);
try
{
$_result
=
do_externalCheckerTest
(
$conn
,
$traceString
,
$allUserSourceCode
,
$arg_mainFileNameWithExtension
,
$test
,
$fullWorkingDirPath
,
$min_timeout
,
$min_compileTimeout
,
$min_memoryLimit
,
$min_diskSpaceLimit
,
$compileCmd
,
$execCmd
,
$sourceFileExtensions
,
$needCompilation
,
(
$arg_command
===
$s_command_justRunTest
),
$requestDistinctionString
,
$showTestRunnerDebugOutput
,
$compilerOptions
,
$arg_characterLimitProtocol
,
$arg_maxPoints
);
}
catch
(
Exception
$e
)
{
//critical error, abort execution (all other tests are likely to fail)
output
(
$status_code_InternalServerError
,
"error executing external checker test: "
.
$e
->
getMessage
());
goto
handleCleanup
;
}
addToDebugTimings
(
"after external checker test"
);
}
else
if
(
$arg_command
===
$s_command_externalCheckerStructuralInductionTest
)
{
require_once
'./do_externalCheckerStructuralInductionTest_func.php'
;
...
...
@@ -778,5 +753,8 @@ handleCleanupWithoutDir:
addToDebugTimings
(
"after cleanup"
);
# debug(json_encode($testResults));
# debug($body[$s_arg_pLang]);
output
(
$status_code_Ok
,
''
,
$testResults
);
This diff is collapsed.
Click to expand it.
constants.php
+
1
−
2
View file @
a9ab492d
...
...
@@ -100,12 +100,11 @@ $s_arg_maxNumberOfTestsWithOneRequest = 'maxNumberOfTestsWithOneRequest';
# the supported test types
$s_command_compile
=
'compileTest'
;
$s_command_blackBoxTest
=
'blackBoxTest'
;
$s_command_externalCheckerTest
=
'externalCheckerTest'
;
$s_command_externalCheckerStructuralInductionTest
=
'externalCheckerStructuralInductionTest'
;
$s_command_compareFilesTest
=
'compareFilesTest'
;
$s_command_regexTest
=
'regexTest'
;
$s_command_justRunTest
=
'justRunTest'
;
$s_supportedCommands
=
[
$s_command_compile
,
$s_command_blackBoxTest
,
$s_command_externalCheckerTest
,
$s_command_externalCheckerStructuralInductionTest
,
$s_command_compareFilesTest
,
$s_command_regexTest
,
$s_command_justRunTest
];
$s_supportedCommands
=
[
$s_command_compile
,
$s_command_blackBoxTest
,
$s_command_externalCheckerStructuralInductionTest
,
$s_command_compareFilesTest
,
$s_command_regexTest
,
$s_command_justRunTest
];
# db table columns
...
...
This diff is collapsed.
Click to expand it.
do_externalCheckerTest_func.php
deleted
100644 → 0
+
0
−
207
View file @
b9636505
<?php
require_once
__DIR__
.
'/protocolHeaderPartParser.php'
;
/**
* runs the given black box test against the given files
* @param $conn PDO
* @param $traceString string
* @param $sourceCode string the user program source code as one string
* @param string $mainFileNameWithExtension the main file to compile (with extension)
* @param $test
* @param $fullWorkingDirPath
* @param int|string $timeout the timeout in MS (can be string from db or int from default values)
* @param int|string $compileTimeout the compile timeout in MS (can be string from db or int from default values)
* @param int|string $memoryLimit the memory limit in kb (can be string from db or int from default values)
* @param int|string $diskSpaceLimit the max disk space the program can write to (can be string from db or int from default values)
* @param string $compileCmd the command to execute to compile the file(s)
* @param string $execCmd the command to execute to run the test
* @param $sourceFileExtensions array the list with the file extensions from the source files for the p language
* @param $needCompilation bool true: should compile sources, false: not (this assumes the sources are already compiled)
* @param $justRun true: just run test, false: normal back box test
* @param $uniqueSessionId string the unique session id for the test runner to handle sandbox file system management
* @param $showTestRunnerDebugOutput 1: show internal debug output from the test runner (included in the test response)
* @param $compilerOptions string the options for the compiler
* @param $arg_characterLimitProtocol
* @param $maxPoints int
* @return array the result
* @internal param array $allFiles all files to copy in teh dir to use
* Format: array[int] => {fileName: string, fileContent: string}
*/
function
do_externalCheckerTest
(
$conn
,
$traceString
,
$sourceCode
,
$mainFileNameWithExtension
,
$test
,
$fullWorkingDirPath
,
$timeout
,
$compileTimeout
,
$memoryLimit
,
$diskSpaceLimit
,
$compileCmd
,
$execCmd
,
$sourceFileExtensions
,
$needCompilation
,
$justRun
,
$uniqueSessionId
,
$showTestRunnerDebugOutput
,
$compilerOptions
,
$arg_characterLimitProtocol
,
$arg_maxPoints
)
{
global
$isDebug
;
global
$config
;
global
$s_command_externalCheckerTest
;
global
$s_test_content
;
global
$s_test_allAssets
;
global
$s_return_val
;
global
$s_output
;
global
$s_user_program_exit_code
;
global
$s_runnerVersion
;
global
$s_timeForCompiling
;
global
$s_timeForUserProgram
;
global
$s_timeoutInMsUsed
;
global
$s_compileTimeoutInMsUsed
;
global
$s_output_without_header_part
;
global
$s_characterLimitExceeded
;
global
$s_points
;
$command_to_execute_string
=
$s_command_externalCheckerTest
;
# compile is done in the runner
$commandToExecute
=
$execCmd
;
$output
=
[];
$return_var
=
-
1
;
$testContent
=
$test
[
$s_test_content
];
$allAssets
=
$test
[
$s_test_allAssets
];
addToDebugTimings
(
"before creating test assets"
);
# create the assets for the current test
if
(
createTestAssets
(
$allAssets
,
$fullWorkingDirPath
)
===
FALSE
)
{
//error message is in createFiles function
return
array
(
$s_return_val
=>
100
,
$s_output
=>
'could not create asset(s)'
,
$s_user_program_exit_code
=>
NULL
,
$s_runnerVersion
=>
NULL
,
$s_timeForCompiling
=>
NULL
,
$s_timeForUserProgram
=>
NULL
,
);
}
addToDebugTimings
(
"after creating test assets"
);
$longCmd
=
$config
[
'runner'
]
.
' '
.
escapeshellarg
(
$command_to_execute_string
)
# arg[0] the test method
.
' '
.
escapeshellarg
(
$fullWorkingDirPath
)
# arg[1] dir path
.
' '
.
escapeshellarg
(
$mainFileNameWithExtension
)
# arg[2] file path
.
' '
.
escapeshellarg
(
$compileCmd
)
# arg[3] compile command
.
' '
.
escapeshellarg
(
$commandToExecute
)
# arg[4] command to execute the test
.
' '
.
escapeshellarg
(
$timeout
)
# arg[5] the timeout in ms
.
' '
.
escapeshellarg
(
$compileTimeout
)
# arg[6] the compile timeout in ms
.
' '
.
escapeshellarg
(
$memoryLimit
)
# arg[7] the memory limit
.
' '
.
escapeshellarg
(
$diskSpaceLimit
)
# arg[8] the disk limit
.
' '
.
escapeshellarg
(
implode
(
','
,
$sourceFileExtensions
))
# arg[9] the source file extensions
.
' '
.
escapeshellarg
(
$needCompilation
?
'true'
:
'false'
)
# arg[10] true: compile program new, false: not
.
' '
.
escapeshellarg
(
$uniqueSessionId
)
# arg[11] a unique session id
.
' '
.
escapeshellarg
((
$showTestRunnerDebugOutput
===
TRUE
?
1
:
0
))
# arg[12] showTestRunnerDebugOutput
.
' '
.
escapeshellarg
(
$compilerOptions
)
# arg[13] options for the compiler
.
' '
.
escapeshellarg
(
$arg_characterLimitProtocol
)
# arg[14] character limit for the test protocol, output cut after the limit
.
' '
.
escapeshellarg
(
$arg_maxPoints
)
# arg[15] (int) the max points we expect (but checker can give mor or less than that)
;
require_once
'./transactionHelper.php'
;
addTraceLogToDb
(
$conn
,
$config
,
$traceString
,
$longCmd
,
$sourceCode
);
if
(
$isDebug
)
{
debug
(
"using runner: "
.
$config
[
'runner'
]);
debug
(
"full command: "
.
$longCmd
);
}
# the test content is passed in as stdin (because might be too long for a console argument
# e.g. windows its 32bit ca. 2.000 kb...
$pipesDescriptor
=
array
(
0
=>
array
(
'pipe'
,
'r'
),
# stdin is a pipe that the child will read from
1
=>
array
(
'pipe'
,
'w'
),
# stdout is a pipe that the child will write to
2
=>
array
(
"pipe"
,
"w"
)
# stderr
);
if
(
$isDebug
)
{
$time_pre
=
microtime
(
true
);
}
$env
=
$config
[
'environmentVarsParsed'
];
addToDebugTimings
(
"starting runner"
);
# without bypass_shell it won't work on windows
$process
=
proc_open
(
$longCmd
,
$pipesDescriptor
,
$pipes
,
$fullWorkingDirPath
,
$env
,
array
(
'bypass_shell'
=>
TRUE
));
// $state = proc_get_status($process);
// warn('open pid: ' . $state['pid']);
if
(
is_resource
(
$process
))
{
fwrite
(
$pipes
[
0
],
$testContent
);
fclose
(
$pipes
[
0
]);
$output
=
stream_get_contents
(
$pipes
[
1
]);
fclose
(
$pipes
[
1
]);
$errorOutput
=
stream_get_contents
(
$pipes
[
2
]);
fclose
(
$pipes
[
2
]);
$return_var
=
proc_close
(
$process
);
}
# we cannot use exec because this does no let us write to the stdin of the process
#exec($longCmd, $output, $return_var);
if
(
$isDebug
)
{
$time_post
=
microtime
(
true
);
$exec_time
=
(
$time_post
-
$time_pre
)
*
1000
;
//in ms
debug
(
"time to run the black-box-tests: "
.
$exec_time
);
}
if
(
$isDebug
&&
(
isset
(
$errorOutput
)
&&
trim
(
$errorOutput
)
!==
''
))
{
debug
(
"error during execution of the (blackbox) test runner: "
.
$errorOutput
);
}
addToDebugTimings
(
"finished runner"
);
# the test assets are removed when the dir gets removed
# also the test runner could renamed/added/deleted some files
$headerPart
=
parseHeaderPart
(
$output
);
//$output
#file_put_contents($fullWorkingDirPath . 'xyz.txt', $output);
# in case the test runner didn't even run we may need to cast (vals from db)
if
(
gettype
(
$timeout
)
===
'string'
)
{
$timeout
=
intval
(
$timeout
,
10
);
}
if
(
gettype
(
$compileTimeout
)
===
'string'
)
{
$compileTimeout
=
intval
(
$compileTimeout
,
10
);
}
addToDebugTimings
(
"finished parsing runner header"
);
return
array
(
$s_return_val
=>
$return_var
,
$s_output
=>
$headerPart
[
$s_output_without_header_part
],
$s_user_program_exit_code
=>
$headerPart
[
$s_user_program_exit_code
],
$s_runnerVersion
=>
$headerPart
[
$s_runnerVersion
],
$s_timeForCompiling
=>
$headerPart
[
$s_timeForCompiling
],
$s_timeForUserProgram
=>
$headerPart
[
$s_timeForUserProgram
],
$s_timeoutInMsUsed
=>
$timeout
,
$s_compileTimeoutInMsUsed
=>
$compileTimeout
,
$s_characterLimitExceeded
=>
$headerPart
[
$s_characterLimitExceeded
],
$s_points
=>
$headerPart
[
$s_points
]
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment