Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 494, 650, 659, 663, 665, 669: Switch to GNAT Community 2021 and add preparatory work for session support #672

Merged
merged 43 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3faa7f7
Switch to GNAT Community 2021
treiher May 26, 2021
7b34195
Remove workarounds for earlier GNAT Community versions
treiher May 26, 2021
4cc96ba
Prevent warnings about unreachable branches
treiher May 11, 2021
a9ae9ab
Simplify code generation caused by generic buffer type
treiher May 11, 2021
7c7df18
Improve provability of generated code
treiher May 12, 2021
324c696
Simplify handling of unreachable branches
treiher May 12, 2021
0be5d10
Use default proof switches for example apps
treiher May 12, 2021
bf0931d
Enable deallocation of Bytes_Ptr
treiher Jan 11, 2021
1ea5f09
Add calculation of message size based on field values
treiher Jan 22, 2021
8a08d2c
Improve error messages for incorrect identifiers
treiher Apr 6, 2021
6bda750
Enable determining all dependencies of type
treiher Apr 6, 2021
9b13a14
Allow use of sequence element types in messages
treiher Apr 30, 2021
d6cc0dd
Enable changing bounds when resetting message context
treiher Apr 6, 2021
be3ee08
Add length parameter to write procedure of messages
treiher Apr 7, 2021
eb40fd2
Allow empty range in contexts
treiher Apr 9, 2021
892357d
Add universal test message
treiher Apr 30, 2021
727efbe
Improve size calculation of fixed size messages
treiher Apr 30, 2021
7c06431
Improve accessing and setting opaque fields in SPARK
treiher May 4, 2021
6163222
Improve naming of type conversion functions
treiher May 4, 2021
8d7a901
Add description of checksums to language reference
treiher May 5, 2021
8f579b0
Add Boolean and Opaque to language reference
treiher May 5, 2021
b9c8361
Fix unsatisfiable preconditions for setter of opaque fields
treiher May 19, 2021
9df6a83
Prevent missing-return warning after fail
treiher May 21, 2021
f8f9b70
Add generation of record types for fixed-size messages
treiher May 6, 2021
4ddae7c
Prevent GNAT bug caused by record type construction inside precondition
treiher May 21, 2021
1f1b029
Revise generated getters for composite fields
treiher May 14, 2021
6d68861
Expand generation of record types to definite messages
treiher May 18, 2021
e8f312c
Prevent compiler errors for messages in packages with same name
treiher May 25, 2021
5fa768e
Remove dependency of tests on example specs
treiher May 25, 2021
75890a1
Add testing of example specs
treiher May 25, 2021
7b6dfc2
Change testing of example apps
treiher May 25, 2021
5b37c35
Update example specifications
treiher May 25, 2021
bf5c23b
Update parser to 0.5.0
treiher May 26, 2021
221114d
Add make targets for installation and runtime compatibility tests
treiher May 27, 2021
fba6b97
Change version of Ada runtime used for compatibility test
treiher May 27, 2021
3e71fc1
Fix generation of structure for messages with built-in types
treiher May 27, 2021
6407b9c
Loosen restrictions on strings for extending identifiers
treiher May 28, 2021
5800110
Prevent name conflicts with enum literals in generated code
treiher May 28, 2021
fced842
Prevent compiler errors for messages in packages with same name
treiher May 28, 2021
1d3170d
Prevent generation of structures for unsupported messages
treiher May 28, 2021
7f9d0a2
Improve verification time
treiher May 26, 2021
f6151e4
Improve naming of method returning all dependencies of type
treiher Jun 8, 2021
3e83106
Update comment about workaround related to use of constant access type
treiher Jun 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
92 changes: 72 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
with:
paths_ignore: '["*.gpr", "examples/apps/**", "tests/spark/**"]'
paths_ignore: '["*.gpr", "examples/**", "tests/spark/**"]'

checks:
name: Checks
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
if: ${{ needs.skip_check_general.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -85,8 +85,7 @@ jobs:
python -m pip install --upgrade pip wheel
- name: Install
run: |
python setup.py sdist
pip install RecordFlux --no-deps --no-index --find-links dist/
make test_installation

skip_check_python:
name: Skip Check Python
Expand Down Expand Up @@ -144,7 +143,7 @@ jobs:
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
if: ${{ needs.skip_check_python.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -195,7 +194,7 @@ jobs:
~/.local/bin
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -241,7 +240,7 @@ jobs:
submodules: true
- name: Install toolchain
if: ${{ needs.skip_check_spark.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Test
Expand All @@ -259,19 +258,12 @@ jobs:
with:
submodules: true
- name: Install toolchain
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Build runtime
run: |
git clone https://github.com/Componolit/ada-runtime
cd ada-runtime
git checkout 280a4867f1d872412aec00f35aa28b35ff295e60
cd ..
make -C ada-runtime
- name: Build
run: |
gprbuild -Ptest --RTS=ada-runtime/build/posix/obj -Xaunit=no -Xoptimization=yes
make test_runtime

verification_spark:
name: Verification
Expand All @@ -291,6 +283,7 @@ jobs:
- "sequence"
- "derivation"
- "expression"
- "fixed_size"
steps:
- uses: actions/checkout@v2
if: ${{ needs.skip_check_spark.outputs.should_skip != 'true' }}
Expand All @@ -316,7 +309,7 @@ jobs:
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
if: ${{ needs.skip_check_spark.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -362,7 +355,7 @@ jobs:
~/.local/bin
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -424,7 +417,7 @@ jobs:
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
if: ${{ needs.skip_check_apps.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand Down Expand Up @@ -471,7 +464,7 @@ jobs:
~/.local/bin
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
uses: ada-actions/toolchain@ce2020
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
Expand All @@ -484,3 +477,62 @@ jobs:
- name: Verify
run: |
make prove_apps

skip_check_specs:
name: Skip Check Specs
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
with:
paths: '["defaults.gpr", "examples/specs/**", "rflx/**"]'

tests_specs:
name: Tests (specs)
needs: skip_check_specs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Determine exact Python version
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
run:
echo "PYTHON_VERSION=$(python -c 'import platform; print(platform.python_version())')" >> $GITHUB_ENV
- name: Cache Python dependencies
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.local/lib/python${{ matrix.python-version }}/site-packages
~/.local/bin
key: ${{ runner.os }}-python${{ env.PYTHON_VERSION }}-${{ hashFiles('setup.py', '*.cfg', '*.ini', '.pylintrc', '.flake8') }}
- name: Install toolchain
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
uses: ada-actions/toolchain@ce2021
with:
distrib: community
- name: Install dependencies
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "PYTHONPATH=$PWD" >> $GITHUB_ENV
echo "HYPOTHESIS_PROFILE=ci" >> $GITHUB_ENV
echo "PYTEST_ADDOPTS=--basetemp=build" >> $GITHUB_ENV
sudo apt install graphviz libgmp-dev patchelf
python -m pip install --upgrade pip wheel
pip install .[devel]
- name: Test
if: ${{ needs.skip_check_specs.outputs.should_skip != 'true' }}
run: |
make test_specs
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ dist
gnatinspect.db
htmlcov
why3session.xml.bak
why3shapes.gz
why3shapes.gz.bak
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ test-files := $(addprefix $(noprefix-dir)/, $(subst /rflx-,/,$(test-files)))
endif

.PHONY: check check_black check_isort check_flake8 check_pylint check_mypy format \
test test_python test_spark test_apps prove prove_tests prove_apps clean
test test_python test_spark test_apps test_specs test_runtime \
prove prove_tests prove_apps clean

all: check test prove

Expand Down Expand Up @@ -57,7 +58,7 @@ format:
black -l 100 $(python-packages) ide/gnatstudio
isort $(python-packages) ide/gnatstudio

test: test_python_coverage test_python_property test_spark
test: test_python_coverage test_python_property test_spark test_runtime test_installation

test_python:
python3 -m pytest -n$(shell nproc) -vv -m "not hypothesis" tests
Expand Down Expand Up @@ -89,7 +90,23 @@ test_spark_optimized: $(test-files)
$(test-bin)

test_apps:
python3 -m pytest -n$(shell nproc) -vv -m "root or not root" tests/integration/example_apps_test.py
python3 examples/apps/icmp_socket.py
$(MAKE) -C examples/apps/ping test_python
$(MAKE) -C examples/apps/ping test_spark

test_specs:
cd examples/specs && python3 -m pytest -n$(shell nproc) -vv tests/test_specs.py

test_runtime:
rm -rf $(build-dir)/ada-runtime
git clone --depth=1 --branch recordflux https://github.com/Componolit/ada-runtime $(build-dir)/ada-runtime
$(MAKE) -C build/ada-runtime
gprbuild -Ptest --RTS=build/ada-runtime/build/posix/obj -Xaunit=no -Xoptimization=yes

test_installation:
rm -rf $(build-dir)/pip
python setup.py sdist
pip install RecordFlux --no-deps --no-index --find-links dist/ --target $(build-dir)/pip

prove: prove_tests prove_apps

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ if parse_message(b"\x01\x00\x04\x01\x02\x03\x04") != create_message():

As a prerequisite, the following dependencies need to be installed:

- [GNAT Community](https://www.adacore.com/download) >= 2020
- [GNAT Community](https://www.adacore.com/download) >= 2021
- [GMP](https://gmplib.org/) This is provided as a package for various distributions, e.g., libgmp-dev (Debian/Ubuntu), gmp-devel (Fedora) or gmp (Arch Linux).

RecordFlux can be installed from PyPI:
Expand Down
5 changes: 3 additions & 2 deletions defaults.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ abstract project Defaults is
"--memlimit=1000",
"--checks-as-errors",
"--warnings=error",
"--proof-warnings",
-- ISSUE: Componolit/RecordFlux#670
-- "--proof-warnings",
"--no-axiom-guard",
"--no-counterexample",
"--counterexamples=off",
"-j0"
);

Expand Down
26 changes: 24 additions & 2 deletions doc/Language-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ type Ether_Type is
with Size => 16, Always_Valid;
```

### Boolean

`Boolean` is a built-in enumeration type with the literals `False => 0` and `True => 1` with a size of 1 bit.

## Message Type

A message type is a collection components. Additional then clauses allow to define conditions and dependencies between components.
Expand All @@ -87,7 +91,7 @@ A message type is a collection components. Additional then clauses allow to defi

*message_type* ::= __type__ *name* __is__ *message_definition* __;__

*message_definition* ::= __message__ [ *null_component* ] *component* { *component* } __end message__ | __null message__
*message_definition* ::= __message__ [ *null_component* ] *component* { *component* } __end message__ [ __with__ *message_aspects* ] | __null message__

*component* ::= *component_name* __:__ *component_type*
[__with__ *aspects*]
Expand Down Expand Up @@ -115,11 +119,29 @@ A message type is a collection components. Additional then clauses allow to defi

*condition* ::= *boolean_expression*

*message_aspects* ::= *message_aspect* { __,__ *message_aspect* }

*message_aspect* ::= *checksum_aspect*

*checksum_aspect* ::= __Checksum__ __=>__ (*checksum_definition* { __,__ *checksum_definition* })

*checksum_definition* ::= *name* __=>__ (*checksum_element* { __,__ *checksum_element* }

*checksum_element* ::= *name* | *name* __'Size__ | *field_range*

*field_range* ::= *field_range_first* __..__ *field_range_last*

*field_range_first* ::= *name* __'First__ | *name* __'Last + 1__

*field_range_last* ::= *name* __'Last | *name* __'First - 1__

#### Static Semantics

A message type specifies the message format of a protocol. Each component corresponds to one field in a message. A then clause of a component allows to define which field follows. If no then clause is given, it is assumed that always the next component of the message follows. If no further component follows, it is assumed that the message ends with this field. The end of a message can also be denoted explicitly by adding a then clause to __null__. Optionally a then clause can contain a condition under which the corresponding field follows and aspects which allow to define the size of the next field and the location of its first bit. These aspects can also be specified in the component. Each aspect can be specified either in the component or in all incoming then clauses, but not in both. The condition can refer to previous fields (including the component containing the then clause). A condition can also be added to a component. A component condition is equivalent to adding a condition to all incoming then clauses. If a component condition as well as a condition at an incoming then clause exists, both conditions are combined by a logical conjunction. If required, a null component can be used to specify the size of the first field in the message. An empty message can be represented by a null message.

The size of a message must be a multiple of 8 bit. Opaque fields and sequence fields must be byte aligned.
The field type `Opaque` represents an unconstrained sequence of bytes. The size of opaque fields must be always defined by a size aspect. Opaque fields and sequence fields must be byte aligned. The size of a message must be a multiple of 8 bit.

A checksum aspect specifies which parts of a message is covered by a checksum. The definition of the checksum calculation is not part of the specification. Code based on the message specification must provide a function which is able to verify a checksum using the specified checksum elements. A checksum element can be a field value, a field size or a range of fields. The point where a checksum should be checked during parsing or generated during serialization must be defined for each checksum. For this purpose the `Valid_Checksum` attribute is added to a condition. All message parts on which the checksum depends have to be known at this point.

#### Example

Expand Down
13 changes: 1 addition & 12 deletions examples/apps/ping/ping.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,7 @@ project Ping is

package Prove is
for Proof_Dir use "proof";

for Proof_Switches ("Ada") use (
"-j0",
"--prover=cvc4,z3,altergo",
"--steps=0",
"--timeout=90",
"--memlimit=1000",
"--checks-as-errors",
"--warnings=error",
"--proof-warnings",
"--no-axiom-guard"
);
for Proof_Switches ("Ada") use Defaults.Proof_Switches;
end Prove;

end Ping;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading