nit: Make the CTU test have a valid finding with defualt configuration

This commit is contained in:
Whisperity
2021-11-28 15:59:18 +01:00
parent 23bc2df6a7
commit 88af3af3c9
7 changed files with 26 additions and 14 deletions

View File

@@ -82,9 +82,12 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: test/fix_compile_json_paths.sh - run: test/fix_compile_json_paths.sh
- uses: ./ - uses: ./
id: codechecker
with: with:
logfile: 'test/ctu/compile_commands.json' logfile: 'test/ctu/compile_commands.json'
ctu: true ctu: true
- name: "Reject test if previous step did not produce CTU finding"
run: cat ${{ steps.codechecker.outputs.result-log }} | grep "Dereference of null pointer"
fail-on-error: fail-on-error:
name: "Parse: Fail the build on error" name: "Parse: Fail the build on error"

View File

@@ -147,8 +147,9 @@ runs:
The action exposes the following outputs which may be used in a workflow's steps succeeding the analysis. The action exposes the following outputs which may be used in a workflow's steps succeeding the analysis.
| Variable | Value | Description | | Variable | Value | Description |
|-------------------|-------------------------------------------|-------------------------------------------------------------------------------| |-------------------|-------------------------------------------|-----------------------------------------------------------------------------------|
| `analyze-output` | Auto-generated, or `analyze-output` input | The directory where the **raw** analysis output files are available. | | `analyze-output` | Auto-generated, or `analyze-output` input | The directory where the **raw** analysis output files are available. |
| `logfile` | Auto-generated, or `logfile` input | The JSON Compilation Database of the analysis that was executed. | | `logfile` | Auto-generated, or `logfile` input | The JSON Compilation Database of the analysis that was executed. |
| `result-html-dir` | Auto-generated. | The directory where the **user-friendly HTML** bug reports were generated to. | | `result-html-dir` | Auto-generated. | The directory where the **user-friendly HTML** bug reports were generated to. |
| `result-log` | Auto-generated. | `CodeChecker parse`'s output log file which contains the findings dumped into it. |
| `warnings` | `true` or `false` | Whether the static analysers reported any findings. | | `warnings` | `true` or `false` | Whether the static analysers reported any findings. |

View File

@@ -56,6 +56,9 @@ outputs:
warnings: warnings:
description: 'Whether the static analyser(s) reported any findings.' description: 'Whether the static analyser(s) reported any findings.'
value: ${{ steps.parse.outputs.HAS_FINDINGS }} value: ${{ steps.parse.outputs.HAS_FINDINGS }}
result-log:
description: 'The file where the output of CodeChecker parse is written to verbatim.'
value: ${{ steps.parse.outputs.OUTPUT_LOG }}
result-html-dir: result-html-dir:
description: 'The output directory where the user-friendly HTML reports were stored to.' description: 'The output directory where the user-friendly HTML reports were stored to.'
value: ${{ steps.parse.outputs.HTML_DIR }} value: ${{ steps.parse.outputs.HTML_DIR }}

View File

@@ -19,9 +19,8 @@ if [[ ! -z "$IN_CONFIGFILE" ]]; then
echo "Using configuration file \"$IN_CONFIGFILE\"!" echo "Using configuration file \"$IN_CONFIGFILE\"!"
fi fi
CTU_FLAG=$([[ "$IN_CTU" == "true" ]] && echo "--ctu --ctu-ast-mode load-from-pch" || echo "")
if [[ "$IN_CTU" == "true" ]]; then if [[ "$IN_CTU" == "true" ]]; then
CTU_FLAG="--ctu --ctu-ast-mode load-from-pch" CTU_FLAGS="--ctu --ctu-ast-mode load-from-pch"
echo "::notice title=Cross Translation Unit analyis::CTU has been enabled, the analysis might take a long time!" echo "::notice title=Cross Translation Unit analyis::CTU has been enabled, the analysis might take a long time!"
fi fi

View File

@@ -15,9 +15,10 @@ OUTPUT_DIR="$IN_OUTPUT_DIR"
if [[ -z "$OUTPUT_DIR" ]]; then if [[ -z "$OUTPUT_DIR" ]]; then
OUTPUT_DIR=~/"$ACTION_NAME"_Results-HTML OUTPUT_DIR=~/"$ACTION_NAME"_Results-HTML
fi fi
mkdir -pv "$(dirname $"OUTPUT_DIR")" mkdir -pv "$(dirname $"OUTPUT_DIR")"
OUTPUT_LOG="$(dirname "$IN_OUTPUT_DIR")"/"$(basename "$IN_OUTPUT_DIR")_Parse.log"
if [[ ! -z "$IN_CONFIGFILE" ]]; then if [[ ! -z "$IN_CONFIGFILE" ]]; then
CONFIG_FLAG_1="--config" CONFIG_FLAG_1="--config"
CONFIG_FLAG_2=$IN_CONFIGFILE CONFIG_FLAG_2=$IN_CONFIGFILE
@@ -34,8 +35,11 @@ echo "::set-output name=HTML_DIR::$OUTPUT_DIR"
"$CODECHECKER_PATH"/CodeChecker parse \ "$CODECHECKER_PATH"/CodeChecker parse \
"$RAW_RESULT_DIR" \ "$RAW_RESULT_DIR" \
--trim-path-prefix "$PROJECT_PATH" --trim-path-prefix "$PROJECT_PATH" \
> "$OUTPUT_LOG"
EXIT_CODE=$? EXIT_CODE=$?
echo "::set-output name=OUTPUT_LOG::$OUTPUT_LOG"
if [[ "$EXIT_CODE" == "2" ]]; then if [[ "$EXIT_CODE" == "2" ]]; then
echo "::set-output name=HAS_FINDINGS::true" echo "::set-output name=HAS_FINDINGS::true"

View File

@@ -1,3 +1,4 @@
int zero() { int broken(int* iptr) {
return 0; *iptr = 42;
return *iptr;
} }

View File

@@ -1,5 +1,6 @@
int zero(); int broken(int* iptr);
int main(int argc, char** argv) { int main(int argc, char** argv) {
return argc / zero(); int* ptr = nullptr;
return broken(ptr);
} }