From 3cb17322066decd2ab2d0b47457915c2fcb61e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?= <janis.daehne2@student.uni-halle.de> Date: Fri, 22 Feb 2019 17:51:38 +0100 Subject: [PATCH] - added new option to show test runenr debug output --- api.php | 23 ++++++++++++++++++++--- bootstrap.php | 1 + do_blackBoxTest_func.php | 6 +++++- do_compileTest_func.php | 5 ++++- do_regexTest_func.php | 3 ++- readme.md | 30 +++++++++++++++++++++++------- 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/api.php b/api.php index b2ac31c..6b4083b 100644 --- a/api.php +++ b/api.php @@ -319,7 +319,12 @@ foreach ($testCases as $test) { require_once './do_compileTest_func.php'; - $_result = do_compile($arg_mainFileNameWithExtension, $fullWorkingDirPath, $compileCmd, $sourceFileExtensions, $requestDistinctionString); + $showTestRunnerDebugOutput = FALSE; + if (isset($config['maxLinesToRead'])) { + $showTestRunnerDebugOutput = $config['showTestRunnerDebugOutput']; + } + + $_result = do_compile($arg_mainFileNameWithExtension, $fullWorkingDirPath, $compileCmd, $sourceFileExtensions, $requestDistinctionString, $showTestRunnerDebugOutput); $result = array( $s_testServerCode => $status_code_Ok, @@ -341,9 +346,14 @@ foreach ($testCases as $test) { require_once './do_regexTest_func.php'; + $showTestRunnerDebugOutput = FALSE; + if (isset($config['maxLinesToRead'])) { + $showTestRunnerDebugOutput = $config['showTestRunnerDebugOutput']; + } + //no need to write any files ... can all be handled in memory //$_result = do_regexTest_json($arg_allFiles, $testContent); - $_result = do_regexTest_format2($arg_allFiles, $testContent); + $_result = do_regexTest_format2($arg_allFiles, $testContent, $showTestRunnerDebugOutput); $result = array( $s_testServerCode => $status_code_Ok, @@ -493,12 +503,19 @@ foreach ($testCases as $test) { $_result = $compileRawResult; } else { + + $showTestRunnerDebugOutput = FALSE; + if (isset($config['maxLinesToRead'])) { + $showTestRunnerDebugOutput = $config['showTestRunnerDebugOutput']; + } + $_result = do_blackBoxTest($arg_mainFileNameWithExtension, $test, $fullWorkingDirPath, $min_timeout, $min_memoryLimit, $min_diskSpaceLimit, $compileCmd, $execCmd, $sourceFileExtensions, $needCompilation, $maxLinesToRead, $maxErrLinesToRead, $maxLinesToWrite, ($arg_command === $s_command_justRunTest), - $requestDistinctionString + $requestDistinctionString, + $showTestRunnerDebugOutput ); } diff --git a/bootstrap.php b/bootstrap.php index e5e37da..db89437 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -68,5 +68,6 @@ $config['maxLinesToRead'] = $row['maxLinesToRead']; $config['maxErrLinesToRead'] = $row['maxErrLinesToRead']; $config['maxLinesToWrite'] = $row['maxLinesToWrite']; +$config['showTestRunnerDebugOutput'] = $row['showTestRunnerDebugOutput'] === 1; return $config; \ No newline at end of file diff --git a/do_blackBoxTest_func.php b/do_blackBoxTest_func.php index 47b040e..08e127c 100644 --- a/do_blackBoxTest_func.php +++ b/do_blackBoxTest_func.php @@ -18,6 +18,7 @@ * @param $maxLinesToWrite int the max lines to write the user program (passed to the runner) * @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) * @return array the result * @internal param array $allFiles all files to copy in teh dir to use * Format: array[int] => {fileName: string, fileContent: string} @@ -27,7 +28,8 @@ function do_blackBoxTest($mainFileNameWithExtension, $test, $fullWorkingDirPath, $compileCmd, $execCmd, $sourceFileExtensions, $needCompilation, $maxLinesToRead, $maxErrLinesToRead, $maxLinesToWrite, $justRun, - $uniqueSessionId + $uniqueSessionId, + $showTestRunnerDebugOutput ) @@ -95,6 +97,8 @@ function do_blackBoxTest($mainFileNameWithExtension, $test, $fullWorkingDirPath, . ' "' . $maxErrLinesToRead . '"' # arg[11] max lines to read from the user program stderr (inclusive) . ' "' . $maxLinesToWrite . '"' # arg[12] max lines to write to the user program (inclusive) . ' "' . $uniqueSessionId . '"' # arg[13] a unique session id + . ' "' . $showTestRunnerDebugOutput . '"' # arg[14] showTestRunnerDebugOutput + ; if ($isDebug) { diff --git a/do_compileTest_func.php b/do_compileTest_func.php index e3e15cd..62adc33 100644 --- a/do_compileTest_func.php +++ b/do_compileTest_func.php @@ -9,13 +9,15 @@ include_once './constants.php'; * @param string $compileCmd the compile command to execute * @param $sourceFileExtensions array the list with the file extensions from the source files for the p language * @param $uniqueSessionId string the unique session id for the test runner to handle sandbox file system management + * @param $showTestRunnerDebugOutput true: show internal debug output from the test runner (included in the test response) * @return array * Format: return_var: process exit value, output the output of the process * @internal param array $allFiles all files to copy in teh dir to use * Format: array[int] => {fileName: string, fileContent: string} */ function do_compile($mainFileNameWithExtension, $fullWorkingDirPath, $compileCmd, $sourceFileExtensions, - $uniqueSessionId + $uniqueSessionId, + $showTestRunnerDebugOutput ) { @@ -36,6 +38,7 @@ function do_compile($mainFileNameWithExtension, $fullWorkingDirPath, $compileCmd . ' "' . $compileCmd . '"' # arg[3] command to execute . ' "' . implode(',', $sourceFileExtensions) . '"'# arg[4] the source file extensions . ' "' . $uniqueSessionId . '"' # arg[5] a unique session id + . ' "' . $showTestRunnerDebugOutput . '"' # arg[6] showTestRunnerDebugOutput ; exec($longCmd, $output, $return_var); diff --git a/do_regexTest_func.php b/do_regexTest_func.php index c88513f..143c839 100644 --- a/do_regexTest_func.php +++ b/do_regexTest_func.php @@ -8,9 +8,10 @@ * @param $allFiles array the files * Format: array[int] => {fileName: string, fileContent: string} * @param $testContent string the test content + * @param $showTestRunnerDebugOutput true: show internal debug output from the test runner (included in the test response) * @return array */ -function do_regexTest_json($allFiles, $testContent) +function do_regexTest_json($allFiles, $testContent, $showTestRunnerDebugOutput) { global $availableRegexModes; diff --git a/readme.md b/readme.md index 6d52422..7494727 100644 --- a/readme.md +++ b/readme.md @@ -220,6 +220,13 @@ when a compile error occurred then the output of the compiler For the test input protocol see the section "Test Runner Interface" +## Adding a new programming language + +To add a new programming language (plang) you need to add the appropriate commands for the plang in the plang table. +The plang is then known to the test server and can be used (if you use e.g. syndrom client-server then that server needs to be configured separately to handle/know the new plang). + + +TODO yapex in system setting unter plangs ergänzen ## database scheme / table /commands The Server needs a table where the commands are stored. @@ -320,21 +327,17 @@ Columns (the same as in the local config except the db specific settings) * maxParallelTests * maxNumberOfTestsWithOneRequest * runner (in the db the `"` don't need to be escaped) +* showTestRunnerDebugOutput (0/1) * maxLinesToRead * maxErrLinesToRead * maxLinesToWrite #### Example -id | workingDirFullPath | hardGlobalTimeoutInMs | maxParallelTests | maxNumberOfTestsWithOneRequest |runner | maxLinesToRead | maxErrLinesToRead | maxLinesToWrite +id | workingDirFullPath | hardGlobalTimeoutInMs | maxParallelTests | maxNumberOfTestsWithOneRequest |runner | showTestRunnerDebugOutput | maxLinesToRead | maxErrLinesToRead | maxLinesToWrite --- | --- | --- | --- | --- | --- | --- | --- | --- -1 | /Users/janis/Documents/Test/ | 2000 | 10 | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/SyndromAll/Syndrom_DefaultTestRunnerFullThreaded/out" Main | 500 | 500 | 500 - - -# Adding a new programming language +1 | /Users/janis/Documents/Test/ | 2000 | 10 | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/SyndromAll/Syndrom_DefaultTestRunnerFullThreaded/out" Main | 0 | 500 | 500 | 500 -To add a new programming language (plang) you need to add the appropriate commands for the plang in the plang table. -The plang is then known to the test server and can be used (if you use e.g. syndrom client-server then that server needs to be configured separately to handle/know the new plang). ## config.json file @@ -364,6 +367,7 @@ A json object with the following properties (order does not matter) after the java executable (else the user program would be called with utf8 encoding but the test runner cannot handle UTF8) **also do not forget to correctly set the compile and exec commands in the PLang Table (add the -Dfile.encoding=UTF8 there too)!!!** +* **showTestRunnerDebugOutput**: 0/1, 1: show some internal debug output from the test runner for debugging (sent back as a part of the test response) * **maxLinesToRead**: (int) the total (inclusive) number of lines to read from the user program (-x or 0 for unlimited) * **maxErrLinesToRead**: (int) the total (inclusive) number of lines to read from the user program error stream (stderr) (-x or 0 for unlimited) * **maxLinesToWrite**: (int) the total (inclusive) number of lines to write to the user program (-x or 0 for unlimited) @@ -440,6 +444,9 @@ negative or 0 is treated as unlimited arg[13] = a unique session id (e.g. used with firejail to manage overlay fs names) +arg[14] = "true" to enable debug output (this will leak internal paths!!) or "false" to disable debug output. +The debug output will be normal lines starting with " [Test-Runner]" + ## Compile Test or Syntaxtest method name: **compileTest** @@ -454,6 +461,9 @@ e.g. "cpp, h" arg[5] = a unique session id +arg[6] = "true" to enable debug output (this will leak internal paths!!) or "false" to disable debug output. +The debug output will be normal lines starting with " [Test-Runner]" + ## Regex Test method name: **regexTest** @@ -461,6 +471,12 @@ arg[1] = the directory containing all files (the main file) arg[2] = the main file name to use +arg[3] = "true" to enable debug output (this will leak internal paths!!) or "false" to disable debug output. +The debug output will be normal lines starting with " [Test-Runner]" + + +## For all tests + The actual test content is passed in via stdin because it might be too long for a console argument. -- GitLab