diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 90ad9a7..c4230d0 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -22,9 +22,9 @@ on: # Variables to configure the workflow env: - DOCKERFILE_PATH: '.' - DOCKERFILE_FILENAME: 'Dockerfile' - DOCKER_IMAGE_NAME: 'lequal/sonar-scanner' + DOCKERFILE_PATH: "." + DOCKERFILE_FILENAME: "Dockerfile" + DOCKER_IMAGE_NAME: "lequal/sonar-scanner" jobs: # Job to test if a new version is ready to be released diff --git a/Dockerfile b/Dockerfile index ba108f3..7729865 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,25 +13,9 @@ RUN echo 'deb http://ftp.fr.debian.org/debian/ bullseye main contrib non-free' > libpcre3-dev=2:8.39-* \ unzip=6.0-* \ xz-utils=5.2.5-* \ - # for Frama-C - opam=2.0.8-* \ - m4=1.4.18-* \ - ocaml-findlib=1.8.1-* \ - libfindlib-ocaml-dev=1.8.1-* \ - libocamlgraph-ocaml-dev=1.8.8-* \ - menhir=20201216-* \ - ca-certificates - -# Configure Opam for Frama-C -RUN opam init -y --disable-sandboxing \ - && eval $(opam env) -RUN opam install -y depext \ - && opam depext -y frama-c \ - && opam install -y --deps-only frama-c -ENV PATH="/root/.opam/default/bin:$PATH" - -# sonar-scanner -RUN curl -ksSLO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip \ + + # sonar-scanner + RUN curl -ksSLO https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip \ && unzip sonar-scanner-cli-4.8.0.2856-linux.zip \ && mv /sonar-scanner-4.8.0.2856-linux /sonar-scanner @@ -44,31 +28,6 @@ RUN curl -ksSLO https://github.com/danmar/cppcheck/archive/refs/tags/2.10.tar.gz HAVE_RULES="yes" \ CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -Wno-deprecated-declarations" -# RATS (and expat) -RUN curl -ksSLO https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/rough-auditing-tool-for-security/rats-2.4.tgz -RUN curl -ksSLO https://github.com/libexpat/libexpat/releases/download/R_2_0_1/expat-2.0.1.tar.gz \ - && tar -xvzf expat-2.0.1.tar.gz \ - && cd expat-2.0.1 \ - && ./configure \ - && make \ - && make install \ - && cd .. \ - && tar -xzvf rats-2.4.tgz \ - && cd rats-2.4 \ - && ./configure --with-expat-lib=/usr/local/lib \ - && make \ - && make install \ - && ./rats \ - && cd .. - -# Frama-C -RUN curl -ksSLO https://frama-c.com/download/frama-c-26.1-Iron.tar.gz \ - && tar -zxvf frama-c-26.1-Iron.tar.gz \ - && cd frama-c-26.1-Iron \ - && opam exec -- make RELEASE=yes \ - && make install \ - && cd .. - # Infer RUN curl -ksSLO https://github.com/facebook/infer/releases/download/v1.1.0/infer-linux64-v1.1.0.tar.xz \ && tar -C /opt -Jxvf infer-linux64-v1.1.0.tar.xz @@ -124,9 +83,6 @@ COPY --from=builder /usr/share/cppcheck /usr/share/cppcheck COPY --from=builder /usr/bin/cppcheck /usr/bin COPY --from=builder /usr/bin/cppcheck-htmlreport /usr/bin -# Add RATS and Frama-C from builder stage -COPY --from=builder /usr/local /usr/local - # Add Infer from builder stage COPY --from=builder /opt/infer-linux64-v1.1.0/bin /opt/infer-linux64-v1.1.0/bin COPY --from=builder /opt/infer-linux64-v1.1.0/lib /opt/infer-linux64-v1.1.0/lib @@ -150,11 +106,6 @@ RUN echo 'deb http://ftp.fr.debian.org/debian/ bullseye main contrib non-free' > python3-pip=20.3.4-* \ # Shellcheck shellcheck=0.7.1-* \ - # Needed by Frama-C - ocaml-findlib=1.8.1-* \ - libocamlgraph-ocaml-dev=1.8.8-* \ - libzarith-ocaml=1.11-* \ - libyojson-ocaml=1.7.0-* \ # Needed by Infer libsqlite3-0=3.34.1-* \ libtinfo5=6.2* \ diff --git a/README.md b/README.md index 6ef42f4..4ba5b7f 100644 --- a/README.md +++ b/README.md @@ -241,8 +241,6 @@ sonar-scanning: | [pylint](http://pylint.pycqa.org/en/latest/user_guide/index.html) | 2.17.2 | pylint-report.txt | | [CNES pylint extension](https://github.com/cnescatlab/cnes-pylint-extension) | 6.0.0 | | | [CppCheck](https://github.com/danmar/cppcheck) | 2.10 | cppcheck-report.xml | -| [RATS](https://code.google.com/archive/p/rough-auditing-tool-for-security/) | 2.4 | rats-report.xml | -| [Frama-C](https://frama-c.com/index.html) | 26.1-Iron | | | [Infer](https://fbinfer.com/) | 1.1.0 | | ## Developer's guide diff --git a/tests/README.md b/tests/README.md index 71d4568..17c399e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -5,56 +5,38 @@ The `tests/` folder contains both tests and some dummy projects to analyze. ## List of integration tests 1. Java - * function: test_language_java - * purpose: Check that the Java language is supported and that the right plugins are executed. + - function: test_language_java + - purpose: Check that the Java language is supported and that the right plugins are executed. 1. Shell - * function: test_language_shell - * purpose: Check that the Shell language is supported and that the right plugins are executed. + - function: test_language_shell + - purpose: Check that the Shell language is supported and that the right plugins are executed. 1. ShellCheck - * function: test_tool_shellcheck - * purpose: Check that ShellCheck can be launched from within the container to analyze scripts in the project. + - function: test_tool_shellcheck + - purpose: Check that ShellCheck can be launched from within the container to analyze scripts in the project. 1. Fortran - * functions: test_language_fortran_77 and test_language_fortran_90 - * purpose: Check that the Fortran 77 and 90 languages are supported and that the right plugins are executed. + - functions: test_language_fortran_77 and test_language_fortran_90 + - purpose: Check that the Fortran 77 and 90 languages are supported and that the right plugins are executed. 1. Python - * function: test_language_python - * purpose: Check that the Python language is supported and that CNES Quality Profiles are usable. + - function: test_language_python + - purpose: Check that the Python language is supported and that CNES Quality Profiles are usable. 1. Pylint - * function: test_tool_pylint - * purpose: Check that Pylint can be launched from within the container to analyze Python projects. + - function: test_tool_pylint + - purpose: Check that Pylint can be launched from within the container to analyze Python projects. 1. Import pylint results in SonarQube - * function: test_import_pylint_results - * purpose: Check that issues revealed by a pylint analysis can be imported in SonarQube. + - function: test_import_pylint_results + - purpose: Check that issues revealed by a pylint analysis can be imported in SonarQube. 1. C/C++ - * function: test_language_c_cpp - * purpose: Check that the C and C++ languages are supported and that CNES Quality Profiles are usable. + - function: test_language_c_cpp + - purpose: Check that the C and C++ languages are supported and that CNES Quality Profiles are usable. 1. CppCheck - * function: test_tool_cppcheck - * purpose: Check that cppcheck can be launched from within the container to analyze C/C++ projects. + - function: test_tool_cppcheck + - purpose: Check that cppcheck can be launched from within the container to analyze C/C++ projects. 1. Import CppCheck results - * function: test_import_cppcheck_results - * purpose: Check that issues revealed by a cppcheck analysis can be imported in SonarQube. -1. Vera++ - * function: test_tool_vera - * purpose: Check that vera++ can be launched from within the container to analyze C/C++ projects. -1. Import Vera++ results - * function: test_import_vera_results - * purpose: Check that issues revealed by vera++ and activated in the Quality Profile can be imported in SonarQube. -1. RATS - * function: test_tool_rats - * purpose: Check that RATS can be launched from within the container to analyze C/C++ projects. -1. Import RATS results - * function: test_import_rats_results - * purpose: Check that issues revealed by RATS and activated in the Quality Profile can be imported in SonarQube. -1. Frama-C - * function: test_tool_framac - * purpose: Check that Frama-C can be launched from within the container to analyze C/C++ projects. -1. Import Frama-C results - * function: test_import_framac_results - * purpose: Check that issues revealed by Frama-C and activated in the Quality Profile can be imported in SonarQube. + - function: test_import_cppcheck_results + - purpose: Check that issues revealed by a cppcheck analysis can be imported in SonarQube. 1. Infer - * function: test_tool_infer - * purpose: Check that Infer can be launched from within the container to analyze C/C++ projects. + - function: test_tool_infer + - purpose: Check that Infer can be launched from within the container to analyze C/C++ projects. ### How to run all the tests @@ -80,36 +62,38 @@ $ pip install -r requirements.txt 1. Activate the virtual environment (if any) 1. Create a docker bridge - * ```sh - $ docker network create sonarbridge - ``` + - ```sh + $ docker network create sonarbridge + ``` 1. Run a container of the SonarQube server - * ```sh - $ docker run --name lequalsonarqube \ - -d --rm \ - -p 9000:9000 \ - -e SONARQUBE_ADMIN_PASSWORD=adminpassword \ - --net sonarbridge \ - lequal/sonarqube:latest - ``` -* Wait until it is configured - * The message `[INFO] CNES SonarQube: ready!` is logged. - * To see the logs of a container running in background - ```sh - $ docker container logs -f lequalsonarqube - Ctrl-C # once the container is ready - ``` -1. Run a specific test with `pytest` and specify some environment variables + - ```sh + $ docker run --name lequalsonarqube \ + -d --rm \ + -p 9000:9000 \ + -e SONARQUBE_ADMIN_PASSWORD=adminpassword \ + --net sonarbridge \ + lequal/sonarqube:latest + ``` + +- Wait until it is configured + - The message `[INFO] CNES SonarQube: ready!` is logged. + - To see the logs of a container running in background ```sh - $ RUN=no SONARQUBE_ADMIN_PASSWORD="adminpassword" pytest -k "" + $ docker container logs -f lequalsonarqube + Ctrl-C # once the container is ready + ``` -## List of environment variables used by the tests +1. Run a specific test with `pytest` and specify some environment variables + ```sh + $ RUN=no SONARQUBE_ADMIN_PASSWORD="adminpassword" pytest -k "" + ``` +## List of environment variables used by the tests -* `RUN`: whether or not to run a lequal/sonarqube container and create a bridge network, default "yes", if you already have a running container, set it to "no" and provide information through the other variables. -* `SONARQUBE_CONTAINER_NAME`: the name to give to the container running the lequal/sonarqube image. -* `SONARQUBE_ADMIN_PASSWORD`: the password of the admin account on the server. -* `SONARQUBE_URL`: URL of lequal/sonarqube container if already running without trailing / from the scanner container. e.g. http://mycontainer:9000 Use it only if no container name was given. -* `SONARQUBE_LOCAL_URL`: URL of lequal/sonarqube container if already running without trailing / from the host. e.g. http://localhost:9000 -* `SONARQUBE_TAG`: the tag of the lequal/sonarqube image to use. e.g. latest -* `SONARQUBE_NETWORK`: the name of the docker bridge used. +- `RUN`: whether or not to run a lequal/sonarqube container and create a bridge network, default "yes", if you already have a running container, set it to "no" and provide information through the other variables. +- `SONARQUBE_CONTAINER_NAME`: the name to give to the container running the lequal/sonarqube image. +- `SONARQUBE_ADMIN_PASSWORD`: the password of the admin account on the server. +- `SONARQUBE_URL`: URL of lequal/sonarqube container if already running without trailing / from the scanner container. e.g. http://mycontainer:9000 Use it only if no container name was given. +- `SONARQUBE_LOCAL_URL`: URL of lequal/sonarqube container if already running without trailing / from the host. e.g. http://localhost:9000 +- `SONARQUBE_TAG`: the tag of the lequal/sonarqube image to use. e.g. latest +- `SONARQUBE_NETWORK`: the name of the docker bridge used. diff --git a/tests/c_cpp/frama-c.csv b/tests/c_cpp/frama-c.csv deleted file mode 100644 index c94b6c7..0000000 --- a/tests/c_cpp/frama-c.csv +++ /dev/null @@ -1 +0,0 @@ -directory file line function property kind status property diff --git a/tests/c_cpp/framac-results.out b/tests/c_cpp/framac-results.out deleted file mode 100644 index a2c4891..0000000 --- a/tests/c_cpp/framac-results.out +++ /dev/null @@ -1,61 +0,0 @@ -[kernel] Parsing framac/CruiseControl.c (with preprocessing) -[kernel:parser:decimal-float] framac/CruiseControl.c:577: Warning: - Floating-point constant 8.113 is not represented exactly. Will use 0x1.039db22d0e560p3. - (warn-once: no further messages from category 'parser:decimal-float' will be emitted) -[kernel] Parsing framac/CruiseControl_const.c (with preprocessing) -[rte] annotating function CruiseControl -[rte] annotating function CruiseControl_init -[rte] annotating function CruiseSpeedMgt -[rte] annotating function CruiseSpeedMgt_init -[rte] annotating function CruiseStateMgt -[rte] annotating function CruiseStateMgt_init -[rte] annotating function DetectPedalsPressed -[rte] annotating function DetectPedalsPressed_init -[rte] annotating function DetectSpeedLimits -[rte] annotating function DetectSpeedLimits_init -[rte] annotating function SaturateThrottle -[rte] annotating function SaturateThrottle_init -[rte] annotating function ThrottleCmd -[rte] annotating function ThrottleCmd_init -[rte] annotating function ThrottleRegulation -[rte] annotating function ThrottleRegulation_init -[rte] annotating function main -[metrics] Defined functions (17) - ====================== - CruiseControl (1 call); CruiseControl_init (1 call); - CruiseSpeedMgt (1 call); CruiseSpeedMgt_init (1 call); - CruiseStateMgt (1 call); CruiseStateMgt_init (1 call); - DetectPedalsPressed (1 call); DetectPedalsPressed_init (1 call); - DetectSpeedLimits (1 call); DetectSpeedLimits_init (1 call); - SaturateThrottle (1 call); SaturateThrottle_init (1 call); - ThrottleCmd (1 call); ThrottleCmd_init (1 call); - ThrottleRegulation (1 call); ThrottleRegulation_init (1 call); - main (0 call); - - Undefined functions (0) - ======================= - - - 'Extern' global variables (0) - ============================= - - - Potential entry points (1) - ========================== - main; - - Global metrics - ============== - Sloc = 305 - Decision point = 28 - Global variables = 8 - If = 28 - Loop = 1 - Goto = 7 - Assignment = 235 - Exit point = 17 - Function = 17 - Function call = 16 - Pointer dereferencing = 493 - Cyclomatic complexity = 45 -[report] Dumping properties in 'frama-c.csv' diff --git a/tests/c_cpp/framac/CruiseControl.c b/tests/c_cpp/framac/CruiseControl.c deleted file mode 100644 index eb8c3ac..0000000 --- a/tests/c_cpp/framac/CruiseControl.c +++ /dev/null @@ -1,588 +0,0 @@ -/* run.config* - GCC: - STDOPT: #"-float-normal tests/value/CruiseControl_const.c -lib-entry -main CruiseControl -context-depth 10 -context-valid-pointers" - -*/ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -#include "CruiseControl.h" -#include "CruiseControl_extern.h" - -/* ============== */ -/* INITIALISATION */ -/* ============== */ - -void CruiseSpeedMgt_init(_C_CruiseSpeedMgt * _C_) -{ - (_C_->_M_init_0_CruiseControl) = true; -} - - -void SaturateThrottle_init(_C_SaturateThrottle * _C_) -{ -} - - -void ThrottleRegulation_init(_C_ThrottleRegulation * _C_) -{ - (_C_->_M_init_0_CruiseControl) = true; - SaturateThrottle_init(&(_C_->_C0_SaturateThrottle)); -} - - -void ThrottleCmd_init(_C_ThrottleCmd * _C_) -{ - (_C_->_M_init_0_CruiseControl) = true; - ThrottleRegulation_init(&(_C_->_C0_ThrottleRegulation)); - (_C_->_M_condact_2_CruiseControl) = true; -} - - -void CruiseStateMgt_init(_C_CruiseStateMgt * _C_) -{ - (_C_->_M_init_0_CruiseControl) = true; -} - - -void DetectPedalsPressed_init(_C_DetectPedalsPressed * _C_) -{ -} - - -void DetectSpeedLimits_init(_C_DetectSpeedLimits * _C_) -{ -} - - -void CruiseControl_init(_C_CruiseControl * _C_) -{ - CruiseSpeedMgt_init(&(_C_->_C0_CruiseSpeedMgt)); - DetectPedalsPressed_init(&(_C_->_C1_DetectPedalsPressed)); - DetectSpeedLimits_init(&(_C_->_C2_DetectSpeedLimits)); - CruiseStateMgt_init(&(_C_->_C3_CruiseStateMgt)); - (_C_->_M_condact_0_CruiseControl) = true; - ThrottleCmd_init(&(_C_->_C4_ThrottleCmd)); - (_C_->_M_init_CruiseControl) = true; -} - -/* ================================*/ -/* MAIN NODE (AND UNEXPANDED NODES) */ -/* ================================ */ - -bool CruiseSpeedMgt(_C_CruiseSpeedMgt * _C_) -{ -/*#code for node CruiseSpeedMgt */ - (_C_->_L1_CruiseControl) = (_C_->_I4_Speed); - (_C_->_L2_CruiseControl) = (_C_->_I1_Set); - (_C_->_L3_CruiseControl) = (_C_->_I0_On); - (_C_->_L6_CruiseControl) = - ((_C_->_L2_CruiseControl) | (_C_->_L3_CruiseControl)); - (_C_->_L21_CruiseControl) = ZeroSpeed; - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_L10_CruiseControl) = (_C_->_L21_CruiseControl); - } else { - (_C_->_L10_CruiseControl) = (_C_->_L7_CruiseControl); - } - (_C_->_L12_CruiseControl) = SpeedInc; - (_C_->_L13_CruiseControl) = - ((_C_->_L10_CruiseControl) + (_C_->_L12_CruiseControl)); - (_C_->_L15_CruiseControl) = SpeedMax; - (_C_->_L16_CruiseControl) = - ((_C_->_L13_CruiseControl) <= (_C_->_L15_CruiseControl)); - (_C_->_L4_CruiseControl) = (_C_->_I2_QuickAccel); - (_C_->_L17_CruiseControl) = - ((_C_->_L16_CruiseControl) & (_C_->_L4_CruiseControl)); - (_C_->_L11_CruiseControl) = SpeedInc; - (_C_->_L14_CruiseControl) = - ((_C_->_L10_CruiseControl) - (_C_->_L11_CruiseControl)); - (_C_->_L19_CruiseControl) = SpeedMin; - (_C_->_L18_CruiseControl) = - ((_C_->_L14_CruiseControl) >= (_C_->_L19_CruiseControl)); - (_C_->_L5_CruiseControl) = (_C_->_I3_QuickDecel); - (_C_->_L20_CruiseControl) = - ((_C_->_L18_CruiseControl) & (_C_->_L5_CruiseControl)); - if ((_C_->_L20_CruiseControl)) { - (_C_->_L9_CruiseControl) = (_C_->_L14_CruiseControl); - } else { - (_C_->_L9_CruiseControl) = (_C_->_L10_CruiseControl); - } - if ((_C_->_L17_CruiseControl)) { - (_C_->_L8_CruiseControl) = (_C_->_L13_CruiseControl); - } else { - (_C_->_L8_CruiseControl) = (_C_->_L9_CruiseControl); - } - if ((_C_->_L6_CruiseControl)) { - (_C_->_L7_CruiseControl) = (_C_->_L1_CruiseControl); - } else { - (_C_->_L7_CruiseControl) = (_C_->_L8_CruiseControl); - } - (_C_->_O0_CruiseSpeed) = (_C_->_L7_CruiseControl); - (_C_->_M_init_0_CruiseControl) = false; -/*#end code for node CruiseSpeedMgt */ - return (true); -} - -bool SaturateThrottle(_C_SaturateThrottle * _C_) -{ -/*#code for node SaturateThrottle */ - (_C_->_L18_CruiseControl) = RegThrottleMax; - (_C_->_L12_CruiseControl) = (_C_->_I0_ThrottleIn); - (_C_->_L7_CruiseControl) = - ((_C_->_L12_CruiseControl) > (_C_->_L18_CruiseControl)); - (_C_->_L17_CruiseControl) = ZeroPercent; - (_C_->_L9_CruiseControl) = - ((_C_->_L12_CruiseControl) < (_C_->_L17_CruiseControl)); - if ((_C_->_L9_CruiseControl)) { - (_C_->_L6_CruiseControl) = (_C_->_L17_CruiseControl); - } else { - (_C_->_L6_CruiseControl) = (_C_->_L12_CruiseControl); - } - if ((_C_->_L7_CruiseControl)) { - (_C_->_L8_CruiseControl) = (_C_->_L18_CruiseControl); - } else { - (_C_->_L8_CruiseControl) = (_C_->_L6_CruiseControl); - } - (_C_->_O0_ThrottleOut) = (_C_->_L8_CruiseControl); - (_C_->_L13_CruiseControl) = - ((_C_->_L9_CruiseControl) | (_C_->_L7_CruiseControl)); - (_C_->_O1_Saturate) = (_C_->_L13_CruiseControl); -/*#end code for node SaturateThrottle */ - //@ assert (_C_->_O1_Saturate == 1) ==> (_C_->_O0_ThrottleOut == ZeroPercent || _C_->_O0_ThrottleOut == RegThrottleMax ); - return (true); -} - -bool ThrottleRegulation(_C_ThrottleRegulation * _C_) -{ -/*#code for node ThrottleRegulation */ - (_C_->_L1_CruiseControl) = (_C_->_I1_CruiseSpeed); - (_C_->_L2_CruiseControl) = (_C_->_I2_VehiculeSpeed); - (_C_->_L3_CruiseControl) = - ((_C_->_L1_CruiseControl) - (_C_->_L2_CruiseControl)); - (_C_->_L6_CruiseControl) = Kp; - (_C_->ProportionnalAction) = - ((_C_->_L3_CruiseControl) * (_C_->_L6_CruiseControl)); - (_C_->_L22_CruiseControl) = ZeroSpeed; - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->HoldIntegralAction) = true; - } else { - (_C_->HoldIntegralAction) = (_C_->_L14_CruiseControl); - } - if ((_C_->HoldIntegralAction)) { - (_C_->_L16_CruiseControl) = (_C_->_L22_CruiseControl); - } else { - (_C_->_L16_CruiseControl) = (_C_->_L3_CruiseControl); - } - (_C_->_L23_CruiseControl) = ZeroSpeed; - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_L18_CruiseControl) = (_C_->_L23_CruiseControl); - } else { - (_C_->_L18_CruiseControl) = (_C_->_L21_CruiseControl); - } - (_C_->_L10_CruiseControl) = - ((_C_->_L16_CruiseControl) + (_C_->_L18_CruiseControl)); - (_C_->_L8_CruiseControl) = Ki; - (_C_->IntegralAction) = - ((_C_->_L10_CruiseControl) * (_C_->_L8_CruiseControl)); - (_C_->_L4_CruiseControl) = - ((_C_->ProportionnalAction) + (_C_->IntegralAction)); -/* call to node not expanded SaturateThrottle */ - (_C_->_C0_SaturateThrottle._I0_ThrottleIn) = (_C_->_L4_CruiseControl); - if (!SaturateThrottle(&(_C_->_C0_SaturateThrottle))) - return (false); - (_C_->_L13_CruiseControl) = - (_C_->_C0_SaturateThrottle._O0_ThrottleOut); - (_C_->_L14_CruiseControl) = (_C_->_C0_SaturateThrottle._O1_Saturate); - (_C_->_O0_Throttle) = (_C_->_L13_CruiseControl); - (_C_->_L19_CruiseControl) = (_C_->_I0_Reset); - if ((_C_->_L19_CruiseControl)) { - (_C_->_L21_CruiseControl) = (_C_->_L22_CruiseControl); - } else { - (_C_->_L21_CruiseControl) = (_C_->_L10_CruiseControl); - } - (_C_->_M_init_0_CruiseControl) = false; -/*#end code for node ThrottleRegulation */ - return (true); -} - -bool ThrottleCmd(_C_ThrottleCmd * _C_) -{ -/*#code for node ThrottleCmd */ - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_L21_CruiseControl) = false; - } else { - (_C_->_L21_CruiseControl) = (_C_->_L20_CruiseControl); - } - (_C_->_L20_CruiseControl) = (_C_->_I0_Regul_ON); - (_C_->_L22_CruiseControl) = ((_C_->_L21_CruiseControl) ^ true); - (_C_->ONRisingEdge) = - ((_C_->_L20_CruiseControl) & (_C_->_L22_CruiseControl)); - (_C_->_L26_CruiseControl) = ZeroPercent; - (_C_->_L1_CruiseControl) = (_C_->_I1_CruiseSpeed); - (_C_->_L2_CruiseControl) = (_C_->_I2_VehiculeSpeed); -/* begin condact */ - if ((_C_->_L20_CruiseControl)) { -/* call to node not expanded ThrottleRegulation */ - (_C_->_C0_ThrottleRegulation._I0_Reset) = (_C_->ONRisingEdge); - (_C_->_C0_ThrottleRegulation._I1_CruiseSpeed) = - (_C_->_L1_CruiseControl); - (_C_->_C0_ThrottleRegulation._I2_VehiculeSpeed) = - (_C_->_L2_CruiseControl); - if (!ThrottleRegulation(&(_C_->_C0_ThrottleRegulation))) - return (false); - (_C_->_L19_CruiseControl) = - (_C_->_C0_ThrottleRegulation._O0_Throttle); - (_C_->_M_condact_2_CruiseControl) = false; - } else { - if (_C_->_M_init_0_CruiseControl) { - (_C_->_L19_CruiseControl) = (_C_->_L26_CruiseControl); - } - } -/* end condact */ - (_C_->_L25_CruiseControl) = (_C_->_I3_Accelerator); - if ((_C_->_L20_CruiseControl)) { - (_C_->_L24_CruiseControl) = (_C_->_L19_CruiseControl); - } else { - (_C_->_L24_CruiseControl) = (_C_->_L25_CruiseControl); - } - (_C_->_O0_Throttle) = (_C_->_L24_CruiseControl); - (_C_->_M_init_0_CruiseControl) = false; -/*#end code for node ThrottleCmd */ - return (true); -} - -bool CruiseStateMgt(_C_CruiseStateMgt * _C_) -{ -/*#code for node CruiseStateMgt */ - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_LE24_CruiseControl) = false; - } else { - (_C_->_LE24_CruiseControl) = (_C_->_LE23_CruiseControl); - } - (_C_->_LE0_CruiseControl) = (_C_->_I0_BrakePressed); - (_C_->_LE4_CruiseControl) = (_C_->_I4_Off); - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_LE40_CruiseControl) = false; - (_C_->_LE26_CruiseControl) = false; - (_C_->_LE28_CruiseControl) = false; - } else { - (_C_->_LE40_CruiseControl) = (_C_->_LE39_CruiseControl); - (_C_->_LE26_CruiseControl) = (_C_->_LE25_CruiseControl); - (_C_->_LE28_CruiseControl) = (_C_->_LE27_CruiseControl); - } - (_C_->_LE9_CruiseControl) = - ((_C_->_LE26_CruiseControl) | (_C_->_LE28_CruiseControl)); - (_C_->_LE10_CruiseControl) = - ((_C_->_LE24_CruiseControl) | (_C_->_LE9_CruiseControl)); - (_C_->_LE11_CruiseControl) = - ((_C_->_LE40_CruiseControl) | (_C_->_LE10_CruiseControl)); - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_LE33_CruiseControl) = false; - (_C_->_LE35_CruiseControl) = false; - (_C_->_LE38_CruiseControl) = false; - } else { - (_C_->_LE33_CruiseControl) = (_C_->_LE32_CruiseControl); - (_C_->_LE35_CruiseControl) = (_C_->_LE34_CruiseControl); - (_C_->_LE38_CruiseControl) = (_C_->_LE37_CruiseControl); - } - (_C_->_LE12_CruiseControl) = - ((_C_->_LE35_CruiseControl) | (_C_->_LE38_CruiseControl)); - (_C_->_LE13_CruiseControl) = - ((_C_->_LE33_CruiseControl) | (_C_->_LE12_CruiseControl)); - (_C_->_LE14_CruiseControl) = - ((_C_->_LE11_CruiseControl) | (_C_->_LE13_CruiseControl)); - (_C_->_LE17_CruiseControl) = - (((_C_->_LE4_CruiseControl) ^ true) & (_C_->_LE14_CruiseControl)); - (_C_->_LE18_CruiseControl) = - ((((_C_->_LE0_CruiseControl) ^ true) & (_C_-> - _LE17_CruiseControl)) & - (_C_->_LE10_CruiseControl)); - (_C_->_LE3_CruiseControl) = (_C_->_I3_On); - if ((_C_->_M_init_0_CruiseControl)) { - (_C_->_LE16_CruiseControl) = false; - (_C_->_LE41_CruiseControl) = true; - } else { - (_C_->_LE16_CruiseControl) = (_C_->_LE15_CruiseControl); - (_C_->_LE41_CruiseControl) = (_C_->_LE19_CruiseControl); - } - (_C_->_LE19_CruiseControl) = - ((_C_->_LE41_CruiseControl) & ((_C_->_LE3_CruiseControl) ^ true)); - (_C_->_LE20_CruiseControl) = - (((_C_->_LE3_CruiseControl) & (_C_-> - _LE16_CruiseControl)) | (((_C_-> - _LE19_CruiseControl) - ^ true) & - (_C_-> - _LE41_CruiseControl))); - (_C_->_LE21_CruiseControl) = - (((_C_->_LE24_CruiseControl) & (_C_-> - _LE18_CruiseControl)) | (((_C_-> - _LE0_CruiseControl) - ^ true) & - (_C_-> - _LE20_CruiseControl))); - (_C_->_LE1_CruiseControl) = (_C_->_I1_AcceleratorPressed); - (_C_->_LE5_CruiseControl) = (_C_->_I5_SpeedOutOffLimits); - (_C_->_LE22_CruiseControl) = - (((_C_->_LE1_CruiseControl) ^ true) & ((_C_-> - _LE5_CruiseControl) ^ - true)); - (_C_->_LE23_CruiseControl) = - ((_C_->_LE21_CruiseControl) & (_C_->_LE22_CruiseControl)); - (_C_->_LE25_CruiseControl) = - (((_C_->_LE18_CruiseControl) & (_C_->_LE9_CruiseControl)) & (_C_-> - _LE22_CruiseControl)); - (_C_->_LE29_CruiseControl) = - ((_C_->_LE17_CruiseControl) & (_C_->_LE13_CruiseControl)); - (_C_->_LE2_CruiseControl) = (_C_->_I2_Resume); - (_C_->_LE30_CruiseControl) = - ((_C_->_LE40_CruiseControl) & (_C_->_LE17_CruiseControl)); - (_C_->_LE31_CruiseControl) = - (((_C_->_LE33_CruiseControl) & (_C_-> - _LE29_CruiseControl)) | ((_C_-> - _LE2_CruiseControl) - & (_C_-> - _LE30_CruiseControl))); - (_C_->_LE32_CruiseControl) = - ((((_C_->_LE0_CruiseControl) ^ true) & (_C_-> - _LE22_CruiseControl)) & - (_C_->_LE31_CruiseControl)); - (_C_->_LE34_CruiseControl) = - (((((_C_->_LE0_CruiseControl) ^ true) & (_C_-> - _LE29_CruiseControl)) & - (_C_->_LE12_CruiseControl)) & (_C_->_LE22_CruiseControl)); - (_C_->_LE42_CruiseControl) = - ((((_C_->_LE23_CruiseControl) | (_C_-> - _LE25_CruiseControl)) | (_C_-> - _LE32_CruiseControl)) - | (_C_->_LE34_CruiseControl)); - (_C_->_LE6_CruiseControl) = (_C_->_LE42_CruiseControl); - (_C_->_O0_Regul_ON) = (_C_->_LE6_CruiseControl); - (_C_->_LE15_CruiseControl) = - ((((_C_->_LE3_CruiseControl) ^ true) & (_C_-> - _LE16_CruiseControl)) | - ((_C_->_LE4_CruiseControl) & (_C_->_LE14_CruiseControl))); - (_C_->_LE39_CruiseControl) = - (((((_C_->_LE0_CruiseControl) & (_C_-> - _LE29_CruiseControl)) | ((_C_-> - _LE0_CruiseControl) - & (_C_-> - _LE20_CruiseControl))) - | (((_C_->_LE2_CruiseControl) ^ true) & - (_C_->_LE30_CruiseControl))) | (((_C_-> - _LE0_CruiseControl) & (_C_-> - _LE17_CruiseControl)) - & (_C_-> - _LE11_CruiseControl))); - (_C_->_LE43_CruiseControl) = - (((_C_->_LE19_CruiseControl) | (_C_->_LE15_CruiseControl)) | (_C_-> - _LE39_CruiseControl)); - (_C_->_LE7_CruiseControl) = (_C_->_LE43_CruiseControl); - (_C_->_O1_Regul_OFF) = (_C_->_LE7_CruiseControl); - (_C_->_LE27_CruiseControl) = - ((((_C_->_LE23_CruiseControl) ^ true) & (_C_-> - _LE21_CruiseControl)) | - ((((_C_->_LE25_CruiseControl) ^ true) & (_C_-> - _LE18_CruiseControl)) & - (_C_->_LE9_CruiseControl))); - (_C_->_LE36_CruiseControl) = - ((((_C_->_LE34_CruiseControl) ^ true) & (_C_-> - _LE29_CruiseControl)) | - ((_C_->_LE2_CruiseControl) & (_C_->_LE30_CruiseControl))); - (_C_->_LE37_CruiseControl) = - ((((_C_->_LE0_CruiseControl) ^ true) & ((_C_-> - _LE32_CruiseControl) ^ - true)) & (_C_-> - _LE36_CruiseControl)); - (_C_->_LE44_CruiseControl) = - (((_C_->_LE27_CruiseControl) | (_C_->_LE37_CruiseControl)) | (_C_-> - _LE39_CruiseControl)); - (_C_->_LE8_CruiseControl) = (_C_->_LE44_CruiseControl); - (_C_->_O2_Regul_STDBY) = (_C_->_LE8_CruiseControl); - (_C_->_M_init_0_CruiseControl) = false; -/*#end code for node CruiseStateMgt */ - return (true); -} - -bool DetectPedalsPressed(_C_DetectPedalsPressed * _C_) -{ -/*#code for node DetectPedalsPressed */ - (_C_->_L2_CruiseControl) = (_C_->_I0_Brake); - (_C_->_L8_CruiseControl) = ZeroPercent; - (_C_->_L4_CruiseControl) = - ((_C_->_L2_CruiseControl) > (_C_->_L8_CruiseControl)); - (_C_->_O0_BrakePressed) = (_C_->_L4_CruiseControl); - (_C_->_L1_CruiseControl) = (_C_->_I1_Accelerator); - (_C_->_L7_CruiseControl) = ZeroPercent; - (_C_->_L3_CruiseControl) = - ((_C_->_L1_CruiseControl) > (_C_->_L7_CruiseControl)); - (_C_->_O1_AcceleratorPressed) = (_C_->_L3_CruiseControl); -/*#end code for node DetectPedalsPressed */ - return (true); -} - -bool DetectSpeedLimits(_C_DetectSpeedLimits * _C_) -{ -/*#code for node DetectSpeedLimits */ - (_C_->_L7_CruiseControl) = (_C_->_I0_speed); - (_C_->_L13_CruiseControl) = SpeedMin; - (_C_->_L8_CruiseControl) = - ((_C_->_L7_CruiseControl) < (_C_->_L13_CruiseControl)); - (_C_->_L14_CruiseControl) = SpeedMax; - (_C_->_L9_CruiseControl) = - ((_C_->_L7_CruiseControl) > (_C_->_L14_CruiseControl)); - (_C_->_L17_CruiseControl) = - ((_C_->_L8_CruiseControl) | (_C_->_L9_CruiseControl)); - (_C_->_O0_SpeedOutOffLimits) = (_C_->_L17_CruiseControl); -/*#end code for node DetectSpeedLimits */ - return (true); -} - -bool CruiseControl(_C_CruiseControl * _C_) -{ -/*#code for node CruiseControl */ - (_C_->_L73_CruiseControl) = (_C_->_I0_On); - (_C_->_L59_CruiseControl) = (_C_->_I7_Brake); - (_C_->_L62_CruiseControl) = (_C_->_I6_Accel); -/* call to node not expanded DetectPedalsPressed */ - (_C_->_C1_DetectPedalsPressed._I0_Brake) = (_C_->_L59_CruiseControl); - (_C_->_C1_DetectPedalsPressed._I1_Accelerator) = - (_C_->_L62_CruiseControl); - if (!DetectPedalsPressed(&(_C_->_C1_DetectPedalsPressed))) - return (false); - (_C_->BrakePressed) = (_C_->_C1_DetectPedalsPressed._O0_BrakePressed); - (_C_->AcceleratorPressed) = - (_C_->_C1_DetectPedalsPressed._O1_AcceleratorPressed); - (_C_->_L61_CruiseControl) = (_C_->_I2_Resume); - (_C_->_L60_CruiseControl) = (_C_->_I0_On); - (_C_->_L58_CruiseControl) = (_C_->_I1_Off); - (_C_->_L95_CruiseControl) = (_C_->_I8_Speed); -/* call to node not expanded DetectSpeedLimits */ - (_C_->_C2_DetectSpeedLimits._I0_speed) = (_C_->_L95_CruiseControl); - if (!DetectSpeedLimits(&(_C_->_C2_DetectSpeedLimits))) - return (false); - (_C_->SpeedOutOffLimits) = - (_C_->_C2_DetectSpeedLimits._O0_SpeedOutOffLimits); -/* call to node not expanded CruiseStateMgt */ - (_C_->_C3_CruiseStateMgt._I0_BrakePressed) = (_C_->BrakePressed); - (_C_->_C3_CruiseStateMgt._I1_AcceleratorPressed) = - (_C_->AcceleratorPressed); - (_C_->_C3_CruiseStateMgt._I2_Resume) = (_C_->_L61_CruiseControl); - (_C_->_C3_CruiseStateMgt._I3_On) = (_C_->_L60_CruiseControl); - (_C_->_C3_CruiseStateMgt._I4_Off) = (_C_->_L58_CruiseControl); - (_C_->_C3_CruiseStateMgt._I5_SpeedOutOffLimits) = - (_C_->SpeedOutOffLimits); - if (!CruiseStateMgt(&(_C_->_C3_CruiseStateMgt))) - return (false); - (_C_->_L82_CruiseControl) = (_C_->_C3_CruiseStateMgt._O0_Regul_ON); - (_C_->_L83_CruiseControl) = (_C_->_C3_CruiseStateMgt._O1_Regul_OFF); - (_C_->_L84_CruiseControl) = (_C_->_C3_CruiseStateMgt._O2_Regul_STDBY); - (_C_->_L19_CruiseControl) = - ((_C_->_L82_CruiseControl) | (_C_->_L84_CruiseControl)); - (_C_->_L96_CruiseControl) = ZeroSpeed; - (_C_->_L38_CruiseControl) = (_C_->_I3_Set); - (_C_->_L39_CruiseControl) = (_C_->_I4_QuickAccel); - (_C_->_L40_CruiseControl) = (_C_->_I5_QuickDecel); - (_C_->_L23_CruiseControl) = (_C_->_I8_Speed); -/* begin condact */ - if ((_C_->_L19_CruiseControl)) { -/* call to node not expanded CruiseSpeedMgt */ - (_C_->_C0_CruiseSpeedMgt._I0_On) = (_C_->_L73_CruiseControl); - (_C_->_C0_CruiseSpeedMgt._I1_Set) = (_C_->_L38_CruiseControl); - (_C_->_C0_CruiseSpeedMgt._I2_QuickAccel) = - (_C_->_L39_CruiseControl); - (_C_->_C0_CruiseSpeedMgt._I3_QuickDecel) = - (_C_->_L40_CruiseControl); - (_C_->_C0_CruiseSpeedMgt._I4_Speed) = (_C_->_L23_CruiseControl); - if (!CruiseSpeedMgt(&(_C_->_C0_CruiseSpeedMgt))) - return (false); - (_C_->CruiseSpeed) = (_C_->_C0_CruiseSpeedMgt._O0_CruiseSpeed); - (_C_->_M_condact_0_CruiseControl) = false; - } else { - if (_C_->_M_init_CruiseControl) { - (_C_->CruiseSpeed) = (_C_->_L96_CruiseControl); - } - } -/* end condact */ - (_C_->_O0_Cruise_speed) = (_C_->CruiseSpeed); - (_C_->_L26_CruiseControl) = (_C_->_I6_Accel); -/* call to node not expanded ThrottleCmd */ - (_C_->_C4_ThrottleCmd._I0_Regul_ON) = (_C_->_L82_CruiseControl); - (_C_->_C4_ThrottleCmd._I1_CruiseSpeed) = (_C_->CruiseSpeed); - (_C_->_C4_ThrottleCmd._I2_VehiculeSpeed) = (_C_->_L23_CruiseControl); - (_C_->_C4_ThrottleCmd._I3_Accelerator) = (_C_->_L26_CruiseControl); - if (!ThrottleCmd(&(_C_->_C4_ThrottleCmd))) - return (false); - (_C_->_L22_CruiseControl) = (_C_->_C4_ThrottleCmd._O0_Throttle); - (_C_->_O1_Throttle_cmd) = (_C_->_L22_CruiseControl); - (_C_->_O2_Regul_ON) = (_C_->_L82_CruiseControl); - (_C_->_O3_Regul_OFF) = (_C_->_L83_CruiseControl); - (_C_->_O4_Regul_STDBY) = (_C_->_L84_CruiseControl); - (_C_->_M_init_CruiseControl) = false; -/*#end code for node CruiseControl */ - return (true); -} - - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file CruiseControl.c -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ -bool main(_C_CruiseControl * _C_){ - CruiseControl_init(_C_); - while (CruiseControl(_C_)); - - return false; -} - - - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -const Speed ZeroSpeed = (real) 0.0; - -const Speed SpeedInc = (real) 2.0; - -const Speed SpeedMax = (real) 150.0; - -const Speed SpeedMin = (real) 30.0; - -const Percent ZeroPercent = (real) 0.0; - -const real Kp = (real) 8.113; - -const real Ki = (real) 0.5; - -const Percent RegThrottleMax = (real) 45.0; - - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file CruiseControl_const.c -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/framac/CruiseControl.h b/tests/c_cpp/framac/CruiseControl.h deleted file mode 100644 index 2c13b01..0000000 --- a/tests/c_cpp/framac/CruiseControl.h +++ /dev/null @@ -1,313 +0,0 @@ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -#ifndef _INCLUDE_SCADE_TYPES -# include "scade_types.h" -#endif - -#include "definitions.h" - - -/* ======================== */ -/* CONTEXT for node CruiseSpeedMgt */ -/* ======================== */ - -/* Type for context */ -typedef struct { - bool _I0_On; - bool _I1_Set; - bool _I2_QuickAccel; - bool _I3_QuickDecel; - Speed _I4_Speed; - Speed _O0_CruiseSpeed; - Speed _L1_CruiseControl; - bool _L2_CruiseControl; - bool _L3_CruiseControl; - bool _L6_CruiseControl; - Speed _L21_CruiseControl; - Speed _L10_CruiseControl; - Speed _L12_CruiseControl; - real _L13_CruiseControl; - Speed _L15_CruiseControl; - bool _L16_CruiseControl; - bool _L4_CruiseControl; - bool _L17_CruiseControl; - Speed _L11_CruiseControl; - real _L14_CruiseControl; - Speed _L19_CruiseControl; - bool _L18_CruiseControl; - bool _L5_CruiseControl; - bool _L20_CruiseControl; - real _L9_CruiseControl; - real _L8_CruiseControl; - Speed _L7_CruiseControl; - bool _M_init_0_CruiseControl; -} _C_CruiseSpeedMgt; - -/* ======================== */ -/* CONTEXT for node SaturateThrottle */ -/* ======================== */ - -/* Type for context */ -typedef struct { - Percent _I0_ThrottleIn; - Percent _O0_ThrottleOut; - bool _O1_Saturate; - Percent _L18_CruiseControl; - Percent _L12_CruiseControl; - bool _L7_CruiseControl; - Percent _L17_CruiseControl; - bool _L9_CruiseControl; - Percent _L6_CruiseControl; - Percent _L8_CruiseControl; - bool _L13_CruiseControl; -} _C_SaturateThrottle; - -/* ======================== */ -/* CONTEXT for node ThrottleRegulation */ -/* ======================== */ - -/* Type for context */ -typedef struct { - bool _I0_Reset; - Speed _I1_CruiseSpeed; - Speed _I2_VehiculeSpeed; - Percent _O0_Throttle; - Speed _L1_CruiseControl; - Speed _L2_CruiseControl; - real _L3_CruiseControl; - real _L6_CruiseControl; - real ProportionnalAction; - Speed _L22_CruiseControl; - bool HoldIntegralAction; - Speed _L16_CruiseControl; - Speed _L23_CruiseControl; - Speed _L18_CruiseControl; - real _L10_CruiseControl; - real _L8_CruiseControl; - real IntegralAction; - real _L4_CruiseControl; - Percent _L13_CruiseControl; - bool _L14_CruiseControl; - bool _L19_CruiseControl; - Speed _L21_CruiseControl; - bool _M_init_0_CruiseControl; - _C_SaturateThrottle _C0_SaturateThrottle; -} _C_ThrottleRegulation; - -/* ======================== */ -/* CONTEXT for node ThrottleCmd */ -/* ======================== */ - -/* Type for context */ -typedef struct { - bool _I0_Regul_ON; - Speed _I1_CruiseSpeed; - Speed _I2_VehiculeSpeed; - Percent _I3_Accelerator; - Percent _O0_Throttle; - bool _L21_CruiseControl; - bool _L20_CruiseControl; - bool _L22_CruiseControl; - bool ONRisingEdge; - Percent _L26_CruiseControl; - Speed _L1_CruiseControl; - Speed _L2_CruiseControl; - Percent _L19_CruiseControl; - Percent _L25_CruiseControl; - Percent _L24_CruiseControl; - bool _M_init_0_CruiseControl; - _C_ThrottleRegulation _C0_ThrottleRegulation; - bool _M_condact_2_CruiseControl; -} _C_ThrottleCmd; - -/* ======================== */ -/* CONTEXT for node CruiseStateMgt */ -/* ======================== */ - -/* Type for context */ -typedef struct { - bool _I0_BrakePressed; - bool _I1_AcceleratorPressed; - bool _I2_Resume; - bool _I3_On; - bool _I4_Off; - bool _I5_SpeedOutOffLimits; - bool _O0_Regul_ON; - bool _O1_Regul_OFF; - bool _O2_Regul_STDBY; - bool _LE24_CruiseControl; - bool _LE0_CruiseControl; - bool _LE4_CruiseControl; - bool _LE40_CruiseControl; - bool _LE26_CruiseControl; - bool _LE28_CruiseControl; - bool _LE9_CruiseControl; - bool _LE10_CruiseControl; - bool _LE11_CruiseControl; - bool _LE33_CruiseControl; - bool _LE35_CruiseControl; - bool _LE38_CruiseControl; - bool _LE12_CruiseControl; - bool _LE13_CruiseControl; - bool _LE14_CruiseControl; - bool _LE17_CruiseControl; - bool _LE18_CruiseControl; - bool _LE3_CruiseControl; - bool _LE16_CruiseControl; - bool _LE41_CruiseControl; - bool _LE19_CruiseControl; - bool _LE20_CruiseControl; - bool _LE21_CruiseControl; - bool _LE1_CruiseControl; - bool _LE5_CruiseControl; - bool _LE22_CruiseControl; - bool _LE23_CruiseControl; - bool _LE25_CruiseControl; - bool _LE29_CruiseControl; - bool _LE2_CruiseControl; - bool _LE30_CruiseControl; - bool _LE31_CruiseControl; - bool _LE32_CruiseControl; - bool _LE34_CruiseControl; - bool _LE42_CruiseControl; - bool _LE6_CruiseControl; - bool _LE15_CruiseControl; - bool _LE39_CruiseControl; - bool _LE43_CruiseControl; - bool _LE7_CruiseControl; - bool _LE27_CruiseControl; - bool _LE36_CruiseControl; - bool _LE37_CruiseControl; - bool _LE44_CruiseControl; - bool _LE8_CruiseControl; - bool _M_init_0_CruiseControl; -} _C_CruiseStateMgt; - -/* ======================== */ -/* CONTEXT for node DetectPedalsPressed */ -/* ======================== */ - -/* Type for context */ -typedef struct { - Percent _I0_Brake; - Percent _I1_Accelerator; - bool _O0_BrakePressed; - bool _O1_AcceleratorPressed; - Percent _L2_CruiseControl; - Percent _L8_CruiseControl; - bool _L4_CruiseControl; - Percent _L1_CruiseControl; - Percent _L7_CruiseControl; - bool _L3_CruiseControl; -} _C_DetectPedalsPressed; - -/* ======================== */ -/* CONTEXT for node DetectSpeedLimits */ -/* ======================== */ - -/* Type for context */ -typedef struct { - Speed _I0_speed; - bool _O0_SpeedOutOffLimits; - Speed _L7_CruiseControl; - Speed _L13_CruiseControl; - bool _L8_CruiseControl; - Speed _L14_CruiseControl; - bool _L9_CruiseControl; - bool _L17_CruiseControl; -} _C_DetectSpeedLimits; - -/* ======================== */ -/* CONTEXT for node CruiseControl */ -/* ======================== */ - -/* Type for context */ -typedef struct { - bool _I0_On; - bool _I1_Off; - bool _I2_Resume; - bool _I3_Set; - bool _I4_QuickAccel; - bool _I5_QuickDecel; - Percent _I6_Accel; - Percent _I7_Brake; - Speed _I8_Speed; - Speed _O0_Cruise_speed; - Percent _O1_Throttle_cmd; - bool _O2_Regul_ON; - bool _O3_Regul_OFF; - bool _O4_Regul_STDBY; - bool _L73_CruiseControl; - Percent _L59_CruiseControl; - Percent _L62_CruiseControl; - bool BrakePressed; - bool AcceleratorPressed; - bool _L61_CruiseControl; - bool _L60_CruiseControl; - bool _L58_CruiseControl; - Speed _L95_CruiseControl; - bool SpeedOutOffLimits; - bool _L82_CruiseControl; - bool _L83_CruiseControl; - bool _L84_CruiseControl; - bool _L19_CruiseControl; - Speed _L96_CruiseControl; - bool _L38_CruiseControl; - bool _L39_CruiseControl; - bool _L40_CruiseControl; - Speed _L23_CruiseControl; - Speed CruiseSpeed; - Percent _L26_CruiseControl; - Percent _L22_CruiseControl; - bool _M_init_CruiseControl; - _C_CruiseSpeedMgt _C0_CruiseSpeedMgt; - _C_DetectPedalsPressed _C1_DetectPedalsPressed; - _C_DetectSpeedLimits _C2_DetectSpeedLimits; - _C_CruiseStateMgt _C3_CruiseStateMgt; - bool _M_condact_0_CruiseControl; - _C_ThrottleCmd _C4_ThrottleCmd; -} _C_CruiseControl; - -/* ============== */ -/* INITIALISATION */ -/* ============== */ - -extern void CruiseSpeedMgt_init(_C_CruiseSpeedMgt *); -extern void SaturateThrottle_init(_C_SaturateThrottle *); -extern void ThrottleRegulation_init(_C_ThrottleRegulation *); -extern void ThrottleCmd_init(_C_ThrottleCmd *); -extern void CruiseStateMgt_init(_C_CruiseStateMgt *); -extern void DetectPedalsPressed_init(_C_DetectPedalsPressed *); -extern void DetectSpeedLimits_init(_C_DetectSpeedLimits *); -extern void CruiseControl_init(_C_CruiseControl *); - -/* ================ */ -/* CYCLIC FUNCTIONS */ -/* ================ */ - -extern bool CruiseSpeedMgt(_C_CruiseSpeedMgt *); -extern bool SaturateThrottle(_C_SaturateThrottle *); -extern bool ThrottleRegulation(_C_ThrottleRegulation *); -extern bool ThrottleCmd(_C_ThrottleCmd *); -extern bool CruiseStateMgt(_C_CruiseStateMgt *); -extern bool DetectPedalsPressed(_C_DetectPedalsPressed *); -extern bool DetectSpeedLimits(_C_DetectSpeedLimits *); -extern bool CruiseControl(_C_CruiseControl *); - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file CruiseControl.h -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/framac/CruiseControl_const.c b/tests/c_cpp/framac/CruiseControl_const.c deleted file mode 100644 index 92a1f42..0000000 --- a/tests/c_cpp/framac/CruiseControl_const.c +++ /dev/null @@ -1,41 +0,0 @@ -/* run.config* - GCC: - DONTRUN: -*/ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -#include "CruiseControl.h" -const Speed ZeroSpeed = (real) 0.0; - -const Speed SpeedInc = (real) 2.0; - -const Speed SpeedMax = (real) 150.0; - -const Speed SpeedMin = (real) 30.0; - -const Percent ZeroPercent = (real) 0.0; - -const real Kp = (real) 8.113; - -const real Ki = (real) 0.5; - -const Percent RegThrottleMax = (real) 45.0; - - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file CruiseControl_const.c -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/framac/CruiseControl_extern.h b/tests/c_cpp/framac/CruiseControl_extern.h deleted file mode 100644 index 7a60cab..0000000 --- a/tests/c_cpp/framac/CruiseControl_extern.h +++ /dev/null @@ -1,32 +0,0 @@ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -/* ========= */ -/* CONSTANTS */ -/* ========= */ - -extern const Speed ZeroSpeed; -extern const Speed SpeedInc; -extern const Speed SpeedMax; -extern const Speed SpeedMin; -extern const Percent ZeroPercent; -extern const real Kp; -extern const real Ki; -extern const Percent RegThrottleMax; - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file CruiseControl_extern.h -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/framac/config_types.h b/tests/c_cpp/framac/config_types.h deleted file mode 100644 index abedc69..0000000 --- a/tests/c_cpp/framac/config_types.h +++ /dev/null @@ -1,7 +0,0 @@ - -#define false 0 -#define true 1 -#define bool int -#define _int int -#define real float - diff --git a/tests/c_cpp/framac/definitions.h b/tests/c_cpp/framac/definitions.h deleted file mode 100644 index 60ff867..0000000 --- a/tests/c_cpp/framac/definitions.h +++ /dev/null @@ -1,28 +0,0 @@ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -#define _copy_mem(t,d,s) Copy_mem(t,d,s) -extern int _copy_mem(int, void *, const void *); - -#define _comp_mem(t,x,y) Comp_mem(t,x,y) -extern int _comp_mem(int, const void *, const void *); - -extern int printf(const char *, ...); -#define __assert(x) printf ("Violation of the assertion %s\n", x); return (false) - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file definitions.h -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/framac/scade_types.h b/tests/c_cpp/framac/scade_types.h deleted file mode 100644 index e11e655..0000000 --- a/tests/c_cpp/framac/scade_types.h +++ /dev/null @@ -1,34 +0,0 @@ -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** Command : -** l2C CruiseControl.lus -node CruiseControl -** -noexp @ALL@ -** -keep_named_var -** -const -** -bitwise -** -loc_ctx -** -no_copy_mem -** -debug -** date of generation (MM/DD/YYYY): 07/06/2007 13:30:09 -** last modification date for CruiseControl.lus (MM/DD/YYYY): 07/06/2007 -********************************************************************$*/ - -/* ===== */ -/* TYPES */ -/* ===== */ - -#include "config_types.h" - -#define _INCLUDE_SCADE_TYPES - -typedef real Percent; - -typedef real Speed; - - - - - -/*$************* SCADE_KCG KCG Version 5.1.1 (build i10) ************** -** End of file scade_types.h -** End of generation (MM/DD/YYYY) : 07/06/2007 13:30:09 -********************************************************************$*/ diff --git a/tests/c_cpp/rats-report.xml b/tests/c_cpp/rats-report.xml deleted file mode 100644 index 6867def..0000000 --- a/tests/c_cpp/rats-report.xml +++ /dev/null @@ -1,22 +0,0 @@ - - -33 -46 -62 -334 -55 - - - High - fixed size global buffer - - Extra care should be taken to ensure that character arrays that are - allocated on the stack are used safely. They are prime targets for - buffer overflow attacks. - - - rats/main.cpp - 3 - - - diff --git a/tests/c_cpp/rats/main.cpp b/tests/c_cpp/rats/main.cpp deleted file mode 100644 index 5949580..0000000 --- a/tests/c_cpp/rats/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -int main() -{ - char array[5]; - array[10] = 0; - return 0; -} diff --git a/tests/c_cpp/reference-framac-results.txt b/tests/c_cpp/reference-framac-results.txt deleted file mode 100644 index b95e05c..0000000 --- a/tests/c_cpp/reference-framac-results.txt +++ /dev/null @@ -1,61 +0,0 @@ -[kernel] Parsing tests/c_cpp/framac/CruiseControl.c (with preprocessing) -[kernel:parser:decimal-float] tests/c_cpp/framac/CruiseControl.c:577: Warning: - Floating-point constant 8.113 is not represented exactly. Will use 0x1.039db22d0e560p3. - (warn-once: no further messages from category 'parser:decimal-float' will be emitted) -[kernel] Parsing tests/c_cpp/framac/CruiseControl_const.c (with preprocessing) -[rte] annotating function CruiseControl -[rte] annotating function CruiseControl_init -[rte] annotating function CruiseSpeedMgt -[rte] annotating function CruiseSpeedMgt_init -[rte] annotating function CruiseStateMgt -[rte] annotating function CruiseStateMgt_init -[rte] annotating function DetectPedalsPressed -[rte] annotating function DetectPedalsPressed_init -[rte] annotating function DetectSpeedLimits -[rte] annotating function DetectSpeedLimits_init -[rte] annotating function SaturateThrottle -[rte] annotating function SaturateThrottle_init -[rte] annotating function ThrottleCmd -[rte] annotating function ThrottleCmd_init -[rte] annotating function ThrottleRegulation -[rte] annotating function ThrottleRegulation_init -[rte] annotating function main -[metrics] Defined functions (17) - ====================== - CruiseControl (1 call); CruiseControl_init (1 call); - CruiseSpeedMgt (1 call); CruiseSpeedMgt_init (1 call); - CruiseStateMgt (1 call); CruiseStateMgt_init (1 call); - DetectPedalsPressed (1 call); DetectPedalsPressed_init (1 call); - DetectSpeedLimits (1 call); DetectSpeedLimits_init (1 call); - SaturateThrottle (1 call); SaturateThrottle_init (1 call); - ThrottleCmd (1 call); ThrottleCmd_init (1 call); - ThrottleRegulation (1 call); ThrottleRegulation_init (1 call); - main (0 call); - - Undefined functions (0) - ======================= - - - 'Extern' global variables (0) - ============================= - - - Potential entry points (1) - ========================== - main; - - Global metrics - ============== - Sloc = 305 - Decision point = 28 - Global variables = 8 - If = 28 - Loop = 1 - Goto = 7 - Assignment = 235 - Exit point = 17 - Function = 17 - Function call = 16 - Pointer dereferencing = 493 - Cyclomatic complexity = 45 -[report] Dumping properties in 'tests/c_cpp/frama-c.csv' diff --git a/tests/c_cpp/reference-rats-results.xml b/tests/c_cpp/reference-rats-results.xml deleted file mode 100644 index aeea893..0000000 --- a/tests/c_cpp/reference-rats-results.xml +++ /dev/null @@ -1,22 +0,0 @@ - - -33 -46 -62 -334 -55 - - - High - fixed size global buffer - - Extra care should be taken to ensure that character arrays that are - allocated on the stack are used safely. They are prime targets for - buffer overflow attacks. - - - tests/c_cpp/rats/main.cpp - 3 - - - diff --git a/tests/c_cpp/reference-vera-results.xml b/tests/c_cpp/reference-vera-results.xml deleted file mode 100644 index df8d0c8..0000000 --- a/tests/c_cpp/reference-vera-results.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/c_cpp/vera-report.xml b/tests/c_cpp/vera-report.xml deleted file mode 100644 index 851e3e3..0000000 --- a/tests/c_cpp/vera-report.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tests/c_cpp/vera/main.cpp b/tests/c_cpp/vera/main.cpp deleted file mode 100644 index 8b53845..0000000 --- a/tests/c_cpp/vera/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -int main() -{ - for(int i = 0; i < 10; i++) - std::cout << i << std::endl; - - return 0; -} diff --git a/tests/test_cnes_sonar_scanner.py b/tests/test_cnes_sonar_scanner.py index aae9c11..099962f 100644 --- a/tests/test_cnes_sonar_scanner.py +++ b/tests/test_cnes_sonar_scanner.py @@ -343,8 +343,7 @@ def test_language_c_cpp(self): so that I can see its level of quality on the SonarQube server. """ sensors = ( - "Sensor C++ (Community) SquidSensor [cxx]", - "Sensor SonarFrama-C [framac]" + "Sensor C++ (Community) SquidSensor [cxx]" ) self.language("C/C++", "c++", "c_cpp", sensors, "c-dummy-project", 0, "CNES_C_A", 1) # 0 issue are expected with the Sonar way Quality Profile for @@ -411,17 +410,6 @@ def test_tool_cppcheck(self): cmd = f"cppcheck --xml-version=2 tests/c_cpp/cppcheck/main.c --output-file={output}" self.analysis_tool("cppcheck", cmd, ref, output, False) - def test_tool_frama_c(self): - """ - As a user of this image, I want to run Frama-C from within a container - so that it produces a report. - """ - ref = "tests/c_cpp/reference-framac-results.txt" - output = "tests/c_cpp/tmp-framac-results.txt" - report = "tests/c_cpp/frama-c.csv" - cmd = f"frama-c tests/c_cpp/framac/CruiseControl.c tests/c_cpp/framac/CruiseControl_const.c -rte -metrics -report-csv {report}" - self.analysis_tool("Frama-C", cmd, ref, output) - def test_tool_infer(self): """ As a user of this image, I want to run Infer from within a container @@ -438,16 +426,6 @@ def test_tool_pylint(self): cmd = "pylint --exit-zero -f json --rcfile=/opt/python/pylintrc_RNC_sonar_2017_A_B tests/python/src/simplecaesar.py" self.analysis_tool("pylint", cmd, "tests/python/reference-pylint-results.json", "tests/python/tmp-pylint-results.json") - def test_tool_rats(self): - """ - As a user of this image, I want to run RATS from within a container - so that it produces a report. - """ - ref = "tests/c_cpp/reference-rats-results.xml" - output = "tests/c_cpp/tmp-rats-results.xml" - cmd = "rats --quiet --nofooter --xml -w 3 tests/c_cpp/rats" - self.analysis_tool("RATS", cmd, ref, output) - def test_tool_shellcheck(self): """ As a user of this image, I want to run shellcheck from within a container @@ -456,16 +434,6 @@ def test_tool_shellcheck(self): cmd = "bash -c 'shellcheck -s sh -f checkstyle tests/shell/src/script.sh || true'" self.analysis_tool("shellcheck", cmd, "tests/shell/reference-shellcheck-results.xml", "tests/shell/tmp-shellcheck-results.xml") - def test_tool_vera(self): - """ - As a user of this image, I want to run Vera++ from within a container - so that it produces a report. - """ - ref = "tests/c_cpp/reference-vera-results.xml" - output = "tests/c_cpp/tmp-vera-results.xml" - cmd = f"vera++ -s -c {output} tests/c_cpp/vera/main.cpp" - self.analysis_tool("Vera++", cmd, ref, output, False) - # Test importation of analysis results def test_import_cppcheck_results(self): """ @@ -478,17 +446,6 @@ def test_import_cppcheck_results(self): self.import_analysis_results("CppCheck Dummy Project", "cppcheck-dummy-project", "CNES_C_A", "c++", "tests/c_cpp", "cppcheck", rule_violated, expected_sensor, expected_import) - def test_import_framac_results(self): - """ - As a user of this image, I want to be able to import the results - of a Frama-C analysis to SonarQube. - """ - rule_violated = "framac-rules:KERNEL.0" - expected_sensor = "INFO: Sensor SonarFrama-C [framac]" - expected_import = "INFO: Results file frama-c.csv has been found and will be processed." - self.import_analysis_results("Frama-C Dummy Project", "framac-dummy-project", - "CNES_CPP_A", "c++", "tests/c_cpp", "framac", rule_violated, expected_sensor, expected_import) - def test_import_pylint_results(self): """ As a user of this image, I want to be able to import the results @@ -499,25 +456,3 @@ def test_import_pylint_results(self): expected_import = "INFO: Sensor PylintImportSensor [python]" self.import_analysis_results("Pylint Dummy Project", "pylint-dummy-project", "CNES_PYTHON_A", "py", "tests/python", "src", rule_violated, expected_sensor, expected_import) - - def test_import_rats_results(self): - """ - As a user of this image, I want to be able to import the results - of a RATS analysis to SonarQube. - """ - rule_violated = "rats:fixed size global buffer" - expected_sensor = "INFO: Sensor C++ (Community) RatsSensor [cxx]" - expected_import = "INFO: CXX-RATS processed = 1" - self.import_analysis_results("RATS Dummy Project", "rats-dummy-project", - "CNES_CPP_A", "c++", "tests/c_cpp", "rats", rule_violated, expected_sensor, expected_import, True) - - def test_import_vera_results(self): - """ - As a user of this image, I want to be able to import the results - of a Vera++ analysis to SonarQube. - """ - rule_violated = "vera++:T008" - expected_sensor = "INFO: Sensor C++ (Community) VeraxxSensor [cxx]" - expected_import = "INFO: CXX-VERA++ processed = 4" - self.import_analysis_results("Vera++ Dummy Project", "vera-dummy-project", - "CNES_CPP_A", "c++", "tests/c_cpp", "vera", rule_violated, expected_sensor, expected_import)