diff options
| -rw-r--r-- | .github/workflows/testsuite.yaml | 27 | ||||
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | tests/Makefile | 5 | ||||
| -rw-r--r-- | tests/common.h | 3 | ||||
| -rw-r--r-- | tests/test_compile.c | 2 | ||||
| -rw-r--r-- | tests/test_fread_overwrite_dynamic.c | 3 | ||||
| -rw-r--r-- | tests/test_fread_overwrite_static.c | 3 | ||||
| -rw-r--r-- | tests/test_fwrite_overwrite_dynamic.c | 3 | ||||
| -rw-r--r-- | tests/test_fwrite_overwrite_static.c | 3 | ||||
| -rw-r--r-- | tests/test_getdomainname_dynamic.c | 5 | ||||
| -rw-r--r-- | tests/test_getdomainname_static.c | 5 | ||||
| -rw-r--r-- | tests/test_mbstowcs_dynamic.c | 2 | ||||
| -rw-r--r-- | tests/test_mbstowcs_static.c | 2 |
13 files changed, 50 insertions, 18 deletions
diff --git a/.github/workflows/testsuite.yaml b/.github/workflows/testsuite.yaml index b84998a..b022fb2 100644 --- a/.github/workflows/testsuite.yaml +++ b/.github/workflows/testsuite.yaml | |||
| @@ -78,3 +78,30 @@ jobs: | |||
| 78 | run: | | 78 | run: | |
| 79 | make -C tests clean clang run > ./results.txt | 79 | make -C tests clean clang run > ./results.txt |
| 80 | grep -zvq 'FAIL' ./results.txt | 80 | grep -zvq 'FAIL' ./results.txt |
| 81 | |||
| 82 | c_versions: | ||
| 83 | runs-on: ubuntu-latest | ||
| 84 | strategy: | ||
| 85 | matrix: | ||
| 86 | version: ["c89", "c99", "c11", "c17"] | ||
| 87 | steps: | ||
| 88 | - name: Checking out the code | ||
| 89 | uses: actions/checkout@v3 | ||
| 90 | - name: Cache musl toolchain | ||
| 91 | uses: actions/cache@v3 | ||
| 92 | id: cache-musl | ||
| 93 | with: | ||
| 94 | path: x86_64-linux-musl-native | ||
| 95 | key: musl | ||
| 96 | - name: Downloading musl-based toolchain | ||
| 97 | if: steps.cache-musl.outputs.cache-hit != 'true' | ||
| 98 | run: wget --quiet https://musl.cc/x86_64-linux-musl-native.tgz | ||
| 99 | - name: Extracting musl-based toolchain | ||
| 100 | if: steps.cache-musl.outputs.cache-hit != 'true' | ||
| 101 | run: tar xzf ./x86_64-linux-musl-native.tgz | ||
| 102 | - name: Building with clang | ||
| 103 | shell: bash | ||
| 104 | run: make CFLAGS=-std=${{ matrix.version }} -C tests clean clang | ||
| 105 | - name: Building with gcc | ||
| 106 | shell: bash | ||
| 107 | run: make CFLAGS=-std=${{ matrix.version }} -C tests clean gcc | ||
| @@ -21,8 +21,9 @@ on Clang. It was initially intended to be used on | |||
| 21 | - Support for out-of-bounds read interfaces, such as send(), write(), fwrite() etc. | 21 | - Support for out-of-bounds read interfaces, such as send(), write(), fwrite() etc. |
| 22 | - No ABI is enforced. All of the fortify check functions are inlined | 22 | - No ABI is enforced. All of the fortify check functions are inlined |
| 23 | into the resulting binary. | 23 | into the resulting binary. |
| 24 | - It has a [comprehensive suite of tests](https://github.com/jvoisin/fortify-headers/tree/master/tests), | 24 | - It has a [comprehensive suite of |
| 25 | running both on Clang and on GCC for every commit, with | 25 | tests](https://github.com/jvoisin/fortify-headers/tree/master/tests), running |
| 26 | both on Clang and on GCC for every commit, on C89, C99, C11 and C17, with | ||
| 26 | [significant coverage](https://jvoisin.github.io/fortify-headers/) | 27 | [significant coverage](https://jvoisin.github.io/fortify-headers/) |
| 27 | - Defining `FORTIFY_USE_NATIVE_CHK` will make use of compiler-provided builtin `_chk` | 28 | - Defining `FORTIFY_USE_NATIVE_CHK` will make use of compiler-provided builtin `_chk` |
| 28 | functions, which might be a bit better in term of diagnostics, | 29 | functions, which might be a bit better in term of diagnostics, |
diff --git a/tests/Makefile b/tests/Makefile index 333f088..a8c7ac5 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -159,7 +159,10 @@ clang: CFLAGS+=-I../x86_64-linux-musl-native/include/ | |||
| 159 | clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ | 159 | clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ |
| 160 | clang: CFLAGS+=-nostdinc | 160 | clang: CFLAGS+=-nostdinc |
| 161 | clang: CXX=clang++ | 161 | clang: CXX=clang++ |
| 162 | clang: CXXFLAGS=$(CFLAGS) | 162 | clang: CXXFLAGS+=-I/usr/include/x86_64-linux-musl |
| 163 | clang: CXXFLAGS+=-I../x86_64-linux-musl-native/include/ | ||
| 164 | clang: CXXFLAGS+=-Ix86_64-linux-musl-native/include/ | ||
| 165 | clang: CXXFLAGS+=-nostdinc | ||
| 163 | clang: comptime $(RUNTIME_TARGETS) cpp | 166 | clang: comptime $(RUNTIME_TARGETS) cpp |
| 164 | 167 | ||
| 165 | coverage: CFLAGS += -fprofile-arcs -ftest-coverage | 168 | coverage: CFLAGS += -fprofile-arcs -ftest-coverage |
diff --git a/tests/common.h b/tests/common.h index 4c34862..6a30739 100644 --- a/tests/common.h +++ b/tests/common.h | |||
| @@ -15,6 +15,9 @@ | |||
| 15 | License along with the GNU C Library; if not, see | 15 | License along with the GNU C Library; if not, see |
| 16 | <https://www.gnu.org/licenses/>. */ | 16 | <https://www.gnu.org/licenses/>. */ |
| 17 | 17 | ||
| 18 | #define _POSIX_C_SOURCE 1 | ||
| 19 | #define _XOPEN_SOURCE 700 | ||
| 20 | |||
| 18 | #include <setjmp.h> | 21 | #include <setjmp.h> |
| 19 | #include <unistd.h> | 22 | #include <unistd.h> |
| 20 | #include <signal.h> | 23 | #include <signal.h> |
diff --git a/tests/test_compile.c b/tests/test_compile.c index edbbb27..b794306 100644 --- a/tests/test_compile.c +++ b/tests/test_compile.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <sys/socket.h> | 12 | #include <sys/socket.h> |
| 13 | #include <sys/stat.h> | 13 | #include <sys/stat.h> |
| 14 | 14 | ||
| 15 | // Check that all headers are compiling. | 15 | /* Check that all headers are compiling.*/ |
| 16 | int main(int argc, char** argv) { | 16 | int main(int argc, char** argv) { |
| 17 | return 0; | 17 | return 0; |
| 18 | } | 18 | } |
diff --git a/tests/test_fread_overwrite_dynamic.c b/tests/test_fread_overwrite_dynamic.c index 74953d6..b108dc5 100644 --- a/tests/test_fread_overwrite_dynamic.c +++ b/tests/test_fread_overwrite_dynamic.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include <assert.h> | ||
| 2 | |||
| 3 | #include "common.h" | 1 | #include "common.h" |
| 4 | 2 | ||
| 3 | #include <assert.h> | ||
| 5 | #include <stdio.h> | 4 | #include <stdio.h> |
| 6 | 5 | ||
| 7 | int main(int argc, char** argv) { | 6 | int main(int argc, char** argv) { |
diff --git a/tests/test_fread_overwrite_static.c b/tests/test_fread_overwrite_static.c index e9de2ce..16a5e30 100644 --- a/tests/test_fread_overwrite_static.c +++ b/tests/test_fread_overwrite_static.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include <assert.h> | ||
| 2 | |||
| 3 | #include "common.h" | 1 | #include "common.h" |
| 4 | 2 | ||
| 3 | #include <assert.h> | ||
| 5 | #include <stdio.h> | 4 | #include <stdio.h> |
| 6 | 5 | ||
| 7 | int main(int argc, char** argv) { | 6 | int main(int argc, char** argv) { |
diff --git a/tests/test_fwrite_overwrite_dynamic.c b/tests/test_fwrite_overwrite_dynamic.c index a7f2b1b..7da64ab 100644 --- a/tests/test_fwrite_overwrite_dynamic.c +++ b/tests/test_fwrite_overwrite_dynamic.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include <assert.h> | ||
| 2 | |||
| 3 | #include "common.h" | 1 | #include "common.h" |
| 4 | 2 | ||
| 3 | #include <assert.h> | ||
| 5 | #include <stdio.h> | 4 | #include <stdio.h> |
| 6 | 5 | ||
| 7 | int main(int argc, char** argv) { | 6 | int main(int argc, char** argv) { |
diff --git a/tests/test_fwrite_overwrite_static.c b/tests/test_fwrite_overwrite_static.c index 492fb47..f844af8 100644 --- a/tests/test_fwrite_overwrite_static.c +++ b/tests/test_fwrite_overwrite_static.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include <assert.h> | ||
| 2 | |||
| 3 | #include "common.h" | 1 | #include "common.h" |
| 4 | 2 | ||
| 3 | #include <assert.h> | ||
| 5 | #include <stdio.h> | 4 | #include <stdio.h> |
| 6 | 5 | ||
| 7 | int main(int argc, char** argv) { | 6 | int main(int argc, char** argv) { |
diff --git a/tests/test_getdomainname_dynamic.c b/tests/test_getdomainname_dynamic.c index a7882ba..3c15b8e 100644 --- a/tests/test_getdomainname_dynamic.c +++ b/tests/test_getdomainname_dynamic.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
| 2 | #define _DEFAULT_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 4 | 5 | ||
| 5 | #include <unistd.h> | 6 | #include <unistd.h> |
| 6 | 7 | ||
diff --git a/tests/test_getdomainname_static.c b/tests/test_getdomainname_static.c index a7671c4..478a274 100644 --- a/tests/test_getdomainname_static.c +++ b/tests/test_getdomainname_static.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
| 2 | #define _DEFAULT_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 4 | 5 | ||
| 5 | #include <unistd.h> | 6 | #include <unistd.h> |
| 6 | 7 | ||
diff --git a/tests/test_mbstowcs_dynamic.c b/tests/test_mbstowcs_dynamic.c index 1465bfd..fd02ed9 100644 --- a/tests/test_mbstowcs_dynamic.c +++ b/tests/test_mbstowcs_dynamic.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | 4 | ||
| 5 | int main(int argc, char** argv) { | 5 | int main(int argc, char** argv) { |
| 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" | 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; /* or u8"zß水🍌" */ |
| 7 | wchar_t wstr[5]; | 7 | wchar_t wstr[5]; |
| 8 | mbstowcs(wstr, mbstr, 4); | 8 | mbstowcs(wstr, mbstr, 4); |
| 9 | 9 | ||
diff --git a/tests/test_mbstowcs_static.c b/tests/test_mbstowcs_static.c index a15c4d6..847fcf7 100644 --- a/tests/test_mbstowcs_static.c +++ b/tests/test_mbstowcs_static.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | 4 | ||
| 5 | int main(int argc, char** argv) { | 5 | int main(int argc, char** argv) { |
| 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" | 6 | const char* mbstr = "z\u00df\u6c34\U0001f34c"; /* or u8"zß水🍌" */ |
| 7 | wchar_t wstr[5]; | 7 | wchar_t wstr[5]; |
| 8 | mbstowcs(wstr, mbstr, 4); | 8 | mbstowcs(wstr, mbstr, 4); |
| 9 | 9 | ||
