Skip to content

Commit

Permalink
add fuzz tests and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed May 28, 2024
1 parent 6179bf3 commit 39495d2
Show file tree
Hide file tree
Showing 20 changed files with 493 additions and 100 deletions.
4 changes: 3 additions & 1 deletion .github/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function c4_show_info()
echo "PROJ_PFX_TARGET=$PROJ_PFX_TARGET"
echo "PROJ_PFX_CMAKE=$PROJ_PFX_CMAKE"
echo "CMAKE_FLAGS=$CMAKE_FLAGS"
echo "CMAKE_C_FLAGS=$CMAKE_C_FLAGS"
echo "CMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS"
echo "NUM_JOBS_BUILD=$NUM_JOBS_BUILD"
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
pwd
Expand Down Expand Up @@ -304,7 +306,7 @@ function c4_cfg_test()
-G 'Visual Studio 17 2022' -A $(_c4vsarchtype $id) \
$(_c4_add_ehsc_to_vs_arm32 $id) \
-DCMAKE_BUILD_TYPE=$BT $CMFLAGS \
-DCMAKE_C_FLAGS=" $CFLAGS" -DCMAKE_CXX_FLAGS=" $CXXFLAGS"
-DCMAKE_C_FLAGS=" $CFLAGS $CMAKE_C_FLAGS" -DCMAKE_CXX_FLAGS=" $CXXFLAGS $CMAKE_CXX_FLAGS"
;;
vs2019)
cmake -S $PROJ_DIR -B $build_dir -DCMAKE_INSTALL_PREFIX="$install_dir" \
Expand Down
53 changes: 52 additions & 1 deletion .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,58 @@ jobs:
- {std: 11, cxx: "4.0", bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: "3.9", bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: "3.9", bt: Release, vg: on, img: ubuntu18.04}
env: {STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
env: {
STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}",
SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"
}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
- run: c4core-install $CXX_
- {name: show info, run: source .github/setenv.sh && c4_show_info}
- name: shared64-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test shared64
- {name: shared64-build, run: source .github/setenv.sh && c4_build_test shared64}
- {name: shared64-run, run: source .github/setenv.sh && c4_run_test shared64}
- {name: shared64-pack, run: source .github/setenv.sh && c4_package shared64}
- name: static64-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test static64
- {name: static64-build, run: source .github/setenv.sh && c4_build_test static64}
- {name: static64-run, run: source .github/setenv.sh && c4_run_test static64}
- {name: static64-pack, run: source .github/setenv.sh && c4_package static64}
- name: static32-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test static32
- {name: static32-build, run: source .github/setenv.sh && c4_build_test static32}
- {name: static32-run, run: source .github/setenv.sh && c4_run_test static32}
- {name: static32-pack, run: source .github/setenv.sh && c4_package static32}
- name: shared32-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test shared32
- {name: shared32-build, run: source .github/setenv.sh && c4_build_test shared32}
- {name: shared32-run, run: source .github/setenv.sh && c4_run_test shared32}
- {name: shared32-pack, run: source .github/setenv.sh && c4_package shared32}

#----------------------------------------------------------------------------
clang_fuzz:
name: clang_fuzz/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}}
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ubuntu-latest
container: ghcr.io/biojppm/c4core/${{matrix.img}}:latest # use the docker image
strategy:
fail-fast: false
matrix:
include:
- {std: 11, cxx: "16" , bt: fuzz , vg: on, img: ubuntu18.04}
- {std: 11, cxx: "16" , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: "16" , bt: Release, vg: on, img: ubuntu18.04}
env: {
CMAKE_CXX_FLAGS: "-g -O0 -fsanitize=address,undefined",
CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON -DRYML_FUZZ_LIBFUZZER_MERGE=ON",
STD: "${{matrix.std}}", CXX_: "clang++-${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}",xs SAN: "${{matrix.san}}",
LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"
}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}",
LINT: "${{matrix.lint}}", OS: "${{matrix.os}}",
CMAKE_FLAGS: "${{matrix.cmk}}",
CMAKE_FLAGS: "${{matrix.cmk}} -DRYML_TEST_FUZZ=ON",
CODECOV_TOKEN: "${{secrets.CODECOV_TOKEN}}",
COVERALLS_REPO_TOKEN: "${{secrets.COVERALLS_REPO_TOKEN}}",
# coveralls disabled: https://github.com/lemurheavy/coveralls-public/issues/1665
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ jobs:
- {std: 11, cxx: g++-5 , bt: Release, bitlinks: shared64 static32}
- {std: 11, cxx: g++-4.8, bt: Debug , bitlinks: shared64 static32}
- {std: 11, cxx: g++-4.8, bt: Release, bitlinks: shared64 static32}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
env: {
STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"
}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
Expand Down Expand Up @@ -134,7 +137,13 @@ jobs:
- {std: 11, cxx: g++-7 , bt: Release, bitlinks: shared64 static32}
- {std: 20, cxx: g++-10 , bt: Debug , bitlinks: shared64 static32}
- {std: 20, cxx: g++-10 , bt: Release, bitlinks: shared64 static32}
env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
env: {
CXXFLAGS: "-fno-exceptions -fno-rtti",
CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON",
STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}",
SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"
}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
Expand Down Expand Up @@ -200,7 +209,12 @@ jobs:
- {std: 11, cxx: g++-4.9, bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-4.8, bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-4.8, bt: Release, img: ubuntu18.04}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
env: {
CMAKE_FLAGS: "-DRYML_TEST_FUZZ=ON",
STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}",
BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}",
SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"
}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
Expand Down
98 changes: 49 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ryml is written in C++11, and compiles cleanly with:
ryml's API documentation is [available at
ReadTheDocs](https://rapidyaml.readthedocs.io/latest/).

ryml is [extensively unit-tested in Linux, Windows and
ryml is [extensively unit-tested and fuzz-tested in Linux, Windows and
MacOS](https://github.com/biojppm/rapidyaml/actions). The tests cover
x64, x86, wasm (emscripten), arm, aarch64, ppc64le and s390x
architectures, and include analysing ryml with:
Expand All @@ -63,6 +63,8 @@ architectures, and include analysing ryml with:
* memory
* address
* undefined behavior
* fuzzers:
* libfuzzer

ryml also [runs in
bare-metal](https://github.com/biojppm/rapidyaml/issues/193), and
Expand Down Expand Up @@ -432,37 +434,6 @@ CHECK(loc.col == 4u);
## Using ryml in your project
### Package managers
ryml is available in most package managers (thanks to all the
contributors!) and linux distributions. But please be aware: those
packages are maintained downstream of this repository, so if you have
issues with the package, file a report with the respective maintainer.
Here's a quick roundup (not maintained):
* Package managers:
* [conan](https://conan.io/center/recipes/rapidyaml)
* [vcpkg](https://vcpkg.io/en/packages.html): `vcpkg install ryml`
* [PyPI](https://pypi.org/project/rapidyaml/)
* Linux distributions:
* Arch Linux/Manjaro:
* [rapidyaml (aarch64)](https://archlinuxarm.org/packages/aarch64/rapidyaml)
* [rapidyaml-git (AUR)](https://aur.archlinux.org/packages/rapidyaml-git/)
* [python-rapidyaml-git (AUR)](https://aur.archlinux.org/packages/python-rapidyaml-git/)
* [Fedora Linux](https://getfedora.org/)/[EPEL](https://docs.fedoraproject.org/en-US/epel/):
* `dnf install rapidyaml-devel`
* `dnf install python3-rapidyaml`
* [Gentoo](https://packages.gentoo.org/packages/dev-cpp/rapidyaml)
* [OpenSuse](https://build.openbuildservice.org/package/show/Emulators/rapidyaml)
* [Slackbuilds](https://slackbuilds.org/repository/15.0/libraries/rapidyaml/)
* [AltLinux](https://packages.altlinux.org/en/sisyphus/srpms/rapidyaml/3006055151670528141)
Although package managers are very useful for quickly getting up to
speed, the advised way is still to bring ryml as a submodule of your
project, building both together. This makes it easy to track any
upstream changes in ryml. Also, ryml is small and quick to build, so
there's not much of a cost for building it with your project.
### Single header file
ryml is provided chiefly as a cmake library project, but it can also
be used as a single header file, and there is a [tool to
Expand Down Expand Up @@ -531,6 +502,38 @@ If you omit `--recursive`, after cloning you
will have to do `git submodule update --init --recursive`
to ensure ryml's submodules are checked out.

### Package managers

ryml is available in most package managers (thanks to all the
contributors!) and linux distributions. But please be aware: those
packages are maintained downstream of this repository, so if you have
issues with the package, file a report with the respective maintainer.

Here's a quick roundup (not maintained):
* Package managers:
* [conan](https://conan.io/center/recipes/rapidyaml)
* [vcpkg](https://vcpkg.io/en/packages.html): `vcpkg install ryml`
* [PyPI](https://pypi.org/project/rapidyaml/)
* Linux distributions:
* Arch Linux/Manjaro:
* [rapidyaml (aarch64)](https://archlinuxarm.org/packages/aarch64/rapidyaml)
* [rapidyaml-git (AUR)](https://aur.archlinux.org/packages/rapidyaml-git/)
* [python-rapidyaml-git (AUR)](https://aur.archlinux.org/packages/python-rapidyaml-git/)
* [Fedora Linux](https://getfedora.org/)/[EPEL](https://docs.fedoraproject.org/en-US/epel/):
* `dnf install rapidyaml-devel`
* `dnf install python3-rapidyaml`
* [Gentoo](https://packages.gentoo.org/packages/dev-cpp/rapidyaml)
* [OpenSuse](https://build.openbuildservice.org/package/show/Emulators/rapidyaml)
* [Slackbuilds](https://slackbuilds.org/repository/15.0/libraries/rapidyaml/)
* [AltLinux](https://packages.altlinux.org/en/sisyphus/srpms/rapidyaml/3006055151670528141)

Although package managers are very useful for quickly getting up to
speed, the advised way is still to bring ryml as a submodule of your
project, building both together. This makes it easy to track any
upstream changes in ryml. Also, ryml is small and quick to build, so
there's not much of a cost for building it with your project.


### Quickstart samples

These samples show different ways of getting ryml into your application. All the
Expand All @@ -555,6 +558,7 @@ more about each sample:
| [`fetch_content`](./samples/fetch_content) | **yes** | [`CMakeLists.txt`](./samples/fetch_content/CMakeLists.txt) | [`run.sh`](./samples/fetch_content/run.sh) |
| [`find_package`](./samples/find_package) | **no**<br>needs prior install or package | [`CMakeLists.txt`](./samples/find_package/CMakeLists.txt) | [`run.sh`](./samples/find_package/run.sh) |


### CMake build settings for ryml
The following cmake variables can be used to control the build behavior of
ryml:
Expand Down Expand Up @@ -726,20 +730,16 @@ See also [the roadmap](./ROADMAP.md) for a list of future work.

### Known limitations

ryml deliberately makes no effort to follow the standard in the
ryml deliberately makes no effort to follow the YAML standard in the
following situations:

* ryml's tree does NOT accept containers are as mapping keys: keys
must be scalars. HOWEVER, this is a limitation only of the tree. The
event-based parser engine DOES parse container keys. The parser
engine is the result of a recent refactor and its usage is meant to
be used by other programming languages to create their native
data-structures. This engine is fully tested and fully conformant
(other than the general error permissiveness noted below). But
because it is recent, it is still undocumented, and it requires some
API cleanup before being ready for isolated use. Please get in touch
if you are interested in integrating the event-based parser engine
without the standalone `ryml::parse_*()`
* ryml's tree does NOT accept containers as map keys: keys stored in
the tree must always be scalars. HOWEVER, this is a limitation only
of the final tree. The event-based parse engine DOES parse container
keys, as it is is meant to be used by other programming languages to
create their native data-structures, and it is fully tested and
fully conformant (other than the general error permissiveness noted
below).
* Tab characters after `:` and `-` are not accepted tokens, unless
ryml is compiled with the macro `RYML_WITH_TAB_TOKENS`. This
requirement exists because checking for tabs introduces branching
Expand Down Expand Up @@ -774,11 +774,11 @@ following situations:
If you do run into trouble and would like to investigate conformance
of your YAML code, **beware** of existing online YAML linters, many of
which are not fully conformant. Instead, try using
[https://play.yaml.io](https://play.yaml.io), an amazing tool which
lets you dynamically input your YAML and continuously see the results
from all the existing parsers (kudos to @ingydotnet and the people
from the YAML test suite). And of course, if you detect anything wrong
with ryml, please [open an
[https://play.yaml.io](https://play.yaml.io), an amazingly useful tool
which lets you dynamically input your YAML and continuously see the
results from all the existing parsers (kudos to @ingydotnet and the
people from the YAML test suite). And of course, if you detect
anything wrong with ryml, please [open an
issue](https://github.com/biojppm/rapidyaml/issues) so that we can
improve.

Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

Moved! See ryml's [Kanban board on github](https://github.com/biojppm/rapidyaml/projects/1).
Moved! See rapidyaml's [Kanban board on github](https://github.com/users/biojppm/projects/1/views/1).
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ ryml is written in C++11, and compiles cleanly with:

* Visual Studio 2015 and later

* clang++ 3.9 and later

* g++ 4.8 and later

* clang++ 3.9 and later

* Intel Compiler

.. note::
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx_quicklinks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Quick links

* `Pull Requests <https://github.com/biojppm/rapidyaml/pull>`_

* `Kanban board <https://github.com/biojppm/rapidyaml/projects/1>`_
* `Kanban board <https://github.com/users/biojppm/projects/1/views/1>`_

* Latest release: `0.6.0 <https://github.com/biojppm/rapidyaml/releases/tag/v0.6.0>`_

Expand Down
20 changes: 8 additions & 12 deletions doc/sphinx_yaml_standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ welcome.
linters**, many of which are not fully conformant; instead, try
using `https://play.yaml.io
<https://play.yaml.io/main/parser?input=IyBFZGl0IE1lIQoKJVlBTUwgMS4yCi0tLQpmb286IEhlbGxvLCBZQU1MIQpiYXI6IFsxMjMsIHRydWVdCmJhejoKLSBvbmUKLSB0d28KLSBudWxsCg==>`__,
an amazing tool which lets you dynamically input your YAML and
an amazingly useful tool which lets you dynamically input your YAML and
continuously see the results from all the existing parsers (kudos
to @ingydotnet and the people from the YAML test suite). And of
course, if you detect anything wrong with ryml, please `open an
Expand All @@ -31,17 +31,13 @@ Deliberate deviations
ryml deliberately makes no effort to follow the standard in the
following situations:

- ryml's tree does NOT accept containers are as mapping keys: keys
must be scalars. HOWEVER, this is a limitation only of the tree. The
event-based parser engine DOES parse container keys. The parser
engine is the result of a recent refactor and its usage is meant to
be used by other programming languages to create their native
data-structures. This engine is fully tested and fully conformant
(other than the general error permissiveness noted below). But
because it is recent, it is still undocumented, and it requires some
API cleanup before being ready for isolated use. Please get in touch
if you are interested in integrating the event-based parser engine
without the standalone `ryml::parse_*()`
- ryml's tree does NOT accept containers as map keys: keys stored in
the tree must always be scalars. HOWEVER, this is a limitation only
of the final tree. The event-based parse engine DOES parse container
keys, as it is is meant to be used by other programming languages to
create their native data-structures, and it is fully tested and
fully conformant (other than the general error permissiveness noted
below).
- Tab characters after ``:`` and ``-`` are not accepted tokens, unless
ryml is compiled with the macro ``RYML_WITH_TAB_TOKENS``. This
requirement exists because checking for tabs introduces branching
Expand Down
12 changes: 6 additions & 6 deletions src/c4/yml/detail/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace detail {
template<class T, id_type N=16>
class stack
{
static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
//static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
static_assert(std::is_trivially_destructible<T>::value, "T must be trivially destructible");

public:
Expand All @@ -34,11 +34,11 @@ class stack

public:

T m_buf[size_t(N)];
T * m_stack;
id_type m_size;
id_type m_capacity;
Callbacks m_callbacks;
T m_buf[size_t(N)];
T *C4_RESTRICT m_stack;
id_type m_size;
id_type m_capacity;
Callbacks m_callbacks;

public:

Expand Down
Loading

0 comments on commit 39495d2

Please sign in to comment.