LogoLogo
Open TrustInSoft CI
  • Overview
  • Introduction tutorial
    • Prepare the demo project
    • Set up the continuous analysis
    • Find the root cause of the undefined behavior
    • Prove the absence of undefined behaviors
    • Go beyond your test suite
  • C++ tutorial
    • Prerequisites
    • Identifiers, constructors and calling conventions
    • Learn more
  • Configuration files
    • Build preparation stage
    • Analyses configuration
    • Tips: Switching from a Global configuration to a Committed configuration
    • Tips: Generalize analyses for several architectures
    • Tips: Factorize options between several analyses
  • Get help
  • Changelog
  • Glossary
  • FAQ
  • REFERENCE
    • Supported architectures
    • Add a status badge
    • GitHub organizations
    • CWE coverage
Powered by GitBook
On this page
  1. Configuration files

Tips: Generalize analyses for several architectures

PreviousTips: Switching from a Global configuration to a Committed configurationNextTips: Factorize options between several analyses

Last updated 3 years ago

This tip can only be achieved with a Committed configuration. See the section to learn more about the different kinds of configuration.

All examples in this section can be replayed with our repository, used for our . Feel free to fork this repository to try it by yourself.

TrustInSoft CI Analyzer is able to simulate but only one architecture can be used at a time. It means you need to define as many analyses in your as architectures you want to verify with TrustInSoft CI.

The first solution would be to copy/paste your existing analyses configuration and modifying the "machdep"value by hand. However this solution does not scale well...

Another solution would be to use the to generate the for all the different architecture you want.

First, move your existing .trustinsoft/config.json to another file (such as .trustinsoft/orig_config.json):

.trustinsoft/orig_config.json
[
  {
    // Test shift values 7 and -3
    "files": [ "../main.c", "../caesar.c" ],
    "cpp-extra-args": "-I .."
  },
  {
    "name": "Test from program inputs",
    "files": [ "../main.c", "../caesar.c" ],
    "cpp-extra-args": "-I ..",
    "main": "main_with_input",
    "val-program-name": "a.out",
    "val-args": "|People of Earth, your attention please|7"
  }
]

Then, create a new .trustinsoft/prepare.sh script (or adapt your existing one with the following script):

.trustinsoft/prepare.sh
#!/bin/bash

set -e

readonly INPUT_FILE="orig_config.json"
readonly MACHDEPS=(
  x86_32
  x86_64
  gcc_x86_32
  gcc_x86_64
)

test -e "$INPUT_FILE" || { echo "$INPUT_FILE not found"; exit 1; }

results=()

for machdep in "${MACHDEPS[@]}"; do
  # Use "minify --type js" to pre-process comments. Then, for each
  # object, add the "machdep" field and update the "name" field.
  res="$(minify --type js "$INPUT_FILE" | \
         jq \
           --arg mach "$machdep" \
           'map(. + { "machdep": $mach }) |
            to_entries |
            map(
              if getpath([ "value", "name" ]) != null then
                .value + { "name": (.value.name + " - " + $mach) }
              else
                .value + { "name": ("Analysis " + (.key + 1 | tostring) + " - " + $mach) } end)')"
  results+=( "$res" )
done

# Gather all configuration objects into a single one.
printf '%s\n' "${results[@]}" | jq '.[]' | jq -s '.' > config.json

Modify the MACHDEPSvariable to add the list of architectures to use for all analyses defined in .trustinsoft/orig_config.json.

Everything is now ready to be analyzed : commit these new files and run a new build to see the list of analyses for all defined architectures!

To easily identify the architecture used, the analysis name is also updated by the script to display the name of the architecture:

Configuration files
demo-caesar
Introduction tutorial
several architectures
Analyses configuration
Build preparation stage
Analyses configuration