Skip to content
Snippets Groups Projects
Commit 1493e990 authored by Florian Fischer's avatar Florian Fischer
Browse files

add more tooling and CI jobs

* clang-tidy
* clang-format
parent af06aeb7
No related branches found
No related tags found
1 merge request!2work work work
---
BasedOnStyle: Google
ColumnLimit: 100
TabWidth: 2
UseTab: Always
Checks: >
bugprone-*,
cert-*,
linuxkernel-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-cert-err58-cpp,
-clang-diagnostic-empty-translation-unit,
-readability-braces-around-statements,
-readability-function-cognitive-complexity,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
WarningsAsErrors: >
bugprone-*,
modernize-*,
clang-*,
readability-*,
performance-*,
HeaderFilterRegex: .*
...@@ -14,3 +14,11 @@ before_script: ...@@ -14,3 +14,11 @@ before_script:
test-eval: test-eval:
script: script:
- make - make
tidy:
script:
- make tidy
check-format:
script:
- make check-format
...@@ -27,3 +27,12 @@ $(foreach syscall,$(SYSCALLS),$(eval $(call generateTargets,$(syscall)))) ...@@ -27,3 +27,12 @@ $(foreach syscall,$(SYSCALLS),$(eval $(call generateTargets,$(syscall))))
clean: clean:
rm -f $(OBJ) rm -f $(OBJ)
tidy:
clang-tidy *.c
check-format:
tools/check-format
format:
clang-format -i *.c *.h
[
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-blocking",
"blocking.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/blocking.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-blocking"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-blocking",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-blocking"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-blocking",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-blocking"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring",
"io-uring.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/io-uring.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-sqpoll",
"io-uring-sqpoll.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/io-uring-sqpoll.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-sqpoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-sqpoll",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-sqpoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-sqpoll",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-sqpoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-no-syscall",
"io-uring-no-syscall.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/io-uring-no-syscall.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-no-syscall"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-no-syscall",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-no-syscall"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-io-uring-no-syscall",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-io-uring-no-syscall"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-epoll",
"epoll.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/epoll.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-epoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-epoll",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-epoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-epoll",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-epoll"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-sig",
"aio-sig.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/aio-sig.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-sig"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-sig",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-sig"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-sig",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-sig"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-thrd",
"aio-thrd.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/aio-thrd.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-thrd"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-thrd",
"bench.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/bench.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-thrd"
},
{
"arguments": [
"/sbin/cc",
"-c",
"-Werror",
"-Wall",
"-g",
"-O0",
"-pthread",
"-o",
"bench-aio-thrd",
"stopwatch.c"
],
"directory": "/home/muhq/code/fgbs-syscall-eval",
"file": "/home/muhq/code/fgbs-syscall-eval/stopwatch.c",
"output": "/home/muhq/code/fgbs-syscall-eval/bench-aio-thrd"
}
]
#!/usr/bin/env bash
set -euo pipefail
# Pretty fancy method to get reliable the absolute path of a shell
# script, *even if it is sourced*. Credits go to GreenFox on
# stackoverflow: http://stackoverflow.com/a/12197518/194894
pushd . > /dev/null
SCRIPTDIR="${BASH_SOURCE[0]}";
while([ -h "${SCRIPTDIR}" ]); do
cd "`dirname "${SCRIPTDIR}"`"
SCRIPTDIR="$(readlink "`basename "${SCRIPTDIR}"`")";
done
cd "`dirname "${SCRIPTDIR}"`" > /dev/null
SCRIPTDIR="`pwd`";
popd > /dev/null
DEBUG=false
while getopts d OPT; do
case $OPT in
d)
set -x
DEBUG=true
;;
*)
echo "usage: ${0##*/} [-dq} [--] ARGS..."
exit 2
esac
done
shift $(( OPTIND - 1 ))
OPTIND=1
ROOTDIR=$(readlink -f "${SCRIPTDIR}/..")
MAX_PROCS=$(nproc)
CHECKED_FILES_FILE=$(mktemp)
if ! $DEBUG; then
trap 'rm "${CHECKED_FILES_FILE}"' EXIT
fi
cd "${ROOTDIR}"
# Note that the --dry-run and --Werror clang-format arguments require
# clang-format 10 or higher. See https://reviews.llvm.org/D68554
find . \( -path '*/\.*' -o -path "./subprojects*" -o -path "./build*" \) -prune -o \
-type f -regextype posix-extended -regex '.*\.(c|h|cpp|hpp)' -print0 |\
tee "${CHECKED_FILES_FILE}" |\
xargs --null --max-args=3 --max-procs="${MAX_PROCS}" \
clang-format --style=file --dry-run -Werror
FILE_COUNT=$(<"${CHECKED_FILES_FILE}" tr -cd '\0' | wc -c)
echo "Checked ${FILE_COUNT} files for format violations"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment