diff --git a/api.php b/api.php index 5023ab09069bb738a547cd000190a0f211147399..047e5287ad2140b9ba0c53f528a5116858ca9295 100644 --- a/api.php +++ b/api.php @@ -145,6 +145,8 @@ if (!isset($body[$s_requestTraceString])) { $traceString = $body[$s_requestTraceString]; +//debug("BODY: " . print_r($body, true)); + $requestDistinctionString = NULL; # try to get the request distinction key/number if (!isset($body[$s_requestDistinctionNumber])) { diff --git a/do_blackBoxTest_func.php b/do_blackBoxTest_func.php index a231dfedef23833f489388fea9b78798f185f512..681397c6b1b674bb1516954ace4099ee4049e761 100644 --- a/do_blackBoxTest_func.php +++ b/do_blackBoxTest_func.php @@ -172,6 +172,7 @@ function do_blackBoxTest($conn, $traceString, $sourceCode, $mainFileNameWithExt } addToDebugTimings("finished runner"); + //debug($output); # the test assets are removed when the dir gets removed diff --git a/readme.md b/readme.md index 5c18c9a5d2af8dab5f0f13c0c829d7a315e643d1..7dea95bbef4cd02d85584b5a2505f7db817cf059 100644 --- a/readme.md +++ b/readme.md @@ -54,9 +54,9 @@ Because there are some specific paths (depending on your setup) you need to adju The database needs to contain a table to store this commands (for config see section config.json file, you can specify the table name there but the table needs to exists already). The table needs to have the following scheme -internalName (primary key) | compile | exec | extensions ---- | --- | --- | --- -(string) | (string) | (string) | (json Array) +| internalName (primary key) | compile | exec | extensions | +|----------------------------|----------|----------|--------------| +| (string) | (string) | (string) | (json Array) | * **internalName** - the internal name of the programming language (**this is the primary key**) * **compile** - the command (shell/cmd) to execute the compiler (or do a syntax check for most interpreted languages) @@ -105,19 +105,20 @@ The commands will probably require the users files (code). This files can be acc - keep in mind that the `#X` can be expanded to paths and paths with whitespace need to be enclosed in `"..."` so better always put `"` around these #### Example (windows) -internalName (primary key) | compile | exec | extensions ---- | --- | --- | --- -csharp | C:\Program Files (x86)\Mono\bin\mcs.bat "#5" | C:\Program Files (x86)\Mono\bin\mono "#4.exe" | ["cs"] -java | C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.4\jdk1.8.0_65\bin\javac -encoding UTF8 "#5" | C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.4\jdk1.8.0_65\bin\java -cp "#1" "#2" | ["java"] -python | python -m py_compile "#5" | python "#5" | ["py"] -php | C:\xampp\php3\php.exe -l "#5" | C:\xampp\php3\php.exe "#5" | ["php"] +| internalName (primary key) | compile | exec | extensions | +|----------------------------|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|--------------------------| +| csharp | C:\Program Files (x86)\Mono\bin\mcs.bat "#5" | C:\Program Files (x86)\Mono\bin\mono "#4.exe" | ["cs"] | +| java | C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.4\jdk1.8.0_65\bin\javac -encoding UTF8 "#5" | C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.4\jdk1.8.0_65\bin\java -cp "#1" "#2" | ["java"] | +| python | python -m py_compile "#5" | python "#5" | ["py"] | +| php | C:\xampp\php3\php.exe -l "#5" | C:\xampp\php3\php.exe "#5" | ["php"] | +| adt_induction | | "/opt/dotnet-sdk-5.0.408-linux-x64/dotnet" [Path to .dll] | ["adt", "proof", "task"] | -#### Example (linux) -internalName (primary key) | compile | exec | extensions ---- | --- | --- | --- -java | javac -encoding UTF8 "#5" | java -Dfile.encoding=UTF8 -cp "#1" "#2" | ["java"] -python | python -m py_compile "#5" | python "#5" | ["py"] +#### Example (linux) +| internalName (primary key) | compile | exec | extensions | +|----------------------------|----------------------------|-----------------------------------------|------------| +| java | javac -encoding UTF8 "#5" | java -Dfile.encoding=UTF8 -cp "#1" "#2" | ["java"] | +| python | python -m py_compile "#5" | python "#5" | ["py"] | **All arguments passed to the shell are wrapped by php `escapeshellarg`, Paths (and maybe other arguments) could contain spaces, wrap them inside double quotes `"a name"`** @@ -136,10 +137,9 @@ Columns - as this can get longer... for mysql mediumtext is recommended #### Example -id | dateTime | traceString | processString | sourceCode ---- | --- | --- | --- | --- -2 | 2019-11-17 19:54:58 | justRunProgram_executingUser:1_solution::userId:1_releaseId:261_plangId:1_mainFileId:84762 | cmd to execute | ... - +| id | dateTime | traceString | processString | sourceCode | +|----|---------------------|--------------------------------------------------------------------------------------------|----------------|------------| +| 2 | 2019-11-17 19:54:58 | justRunProgram_executingUser:1_solution::userId:1_releaseId:261_plangId:1_mainFileId:84762 | cmd to execute | ... | ## Config Table @@ -159,10 +159,9 @@ Columns (the same as in the local config except the db specific settings) #### Example -id | workingDirFullPath | hardTimeoutInMs | hardCompileTimeoutInMs | hardMemoryLimitInKb | hardMaxDiskSpaceLimitInKb | maxNumberOfTestsWithOneRequest |runner | showTestRunnerDebugOutput | environmentVars ---- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- -1 | /Users/janis/Documents/Test/ | 4000 | 2000 | 2000 | 2000 | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/yapexAll/yapex_DefaultTestRunnerFullThreaded/out" Main | 0 USER=yapextester\nHOME=/home/yapextester\nPWD=\nLANG=de_DE.UTF-8\nPATH=/usr/local/bin:/usr/bin:/bin:/ - +| id | workingDirFullPath | hardTimeoutInMs | hardCompileTimeoutInMs | hardMemoryLimitInKb | hardMaxDiskSpaceLimitInKb | maxNumberOfTestsWithOneRequest | runner | showTestRunnerDebugOutput | environmentVars | +|----|------------------------------|-----------------|------------------------|---------------------|---------------------------|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|-----------------| +| 1 | /Users/janis/Documents/Test/ | 4000 | 2000 | 2000 | 2000 | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/yapexAll/yapex_DefaultTestRunnerFullThreaded/out" Main | 0 USER=yapextester\nHOME=/home/yapextester\nPWD=\nLANG=de_DE.UTF-8\nPATH=/usr/local/bin:/usr/bin:/bin:/ | | **Note** that the db config overwrites values in the config file! @@ -269,14 +268,14 @@ If the config table has more than 1 row, the first row is taken! ### syntax The request is a json object so the request should be from mime type application/json. -- **plang**: (string) the programming language to use (depends on the database table see database scheme / table / commands) +- **plang**: (string) the programming language to use (internal name) (depends on the database table see database scheme / table / commands) - **allFiles**: (array) the files to use - **fileName**: (string) the file name with extension - **fileContent**: (string) the file content - **mainFileNameWithExtension**: (string) the file with the main class / entry point - **tests**: (array) the tests to execute - - **testId**: (int) is the id of the test to identify the test (and the related result) - - **testContent** (string/multi line string) the test content to use (depends on the used command) [MUST NO BE EMPTY (design decision)] + - **testId**: (int) is the id of the test to identify the test (and the related result) [any int is ok] + - **testContent** (string/multi line string) the test content to use (depends on the used command) [can be the empty string] - **command**: (string) the command to call/execute (the test type e.g. blackBoxTest), see `constants.php > $s_supportedCommands` for supported test types - **timeoutInMs**: (int) the timeout in ms for execution to wait before terminating the users program - **compileTimeoutInMs** (int) the timeout in ms for compilation to wait before terminating the compiling @@ -387,7 +386,7 @@ other fields * **runnerVersion**: (string | null) the test-runner version or null if the test-runner was not executed -* **protocol**: (string) a string representing the output (could contain the error message. New line chars are encoded with **\\\r\\\n** (because json encode automaticall encodes \r\n to \\\n\\\n) +* **protocol**: (string) a string representing the output (could contain the error message. New line chars are encoded with **\\\r\\\n** (because json encode automatically encodes \r\n to \\\n\\\n) * **testServerVersion**: (string) the test-server version @@ -405,7 +404,7 @@ other fields ## Protocols -The Test-Runner uses `\n` new lines +The Test-Runner uses `\r\n` new lines All protocols consists out of 2 parts @@ -413,10 +412,10 @@ the first part is the header part and contains some misc data about the test run the seconds part is the real conversion protocol between the test-runner and the user program -the two parts are separated by a `---\n` line +the two parts are separated by a `---\r\n` line -**the header part including the `---\n`** must be removed from the protocol! +**the header part including the `---\r\n`** must be removed from the protocol! ### Protocol Header part @@ -494,7 +493,7 @@ but only if the user program actually ran and finished * '**e**' is the expected user program exit code followed by a number (e.g. `e0`) all other lines -* '**$**' are the arguments passed to the users program, starting with a $ sign (only if arguments were present) +* '**\$**' are the arguments passed to the users program, starting with a $ sign (only if arguments were present) all other lines (meaning different by the first character): * '**<**' indicating a line that was inputted to the users program * '**>**' indicating a line that was read from the users program