Skip to content

Commit f8155f0

Browse files
committed
Run various C versions in the CI
1 parent 6573631 commit f8155f0

13 files changed

+50
-18
lines changed

.github/workflows/testsuite.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,30 @@ jobs:
7878
run: |
7979
make -C tests clean clang run > ./results.txt
8080
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

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ on Clang. It was initially intended to be used on
2121
- Support for out-of-bounds read interfaces, such as send(), write(), fwrite() etc.
2222
- No ABI is enforced. All of the fortify check functions are inlined
2323
into the resulting binary.
24-
- It has a [comprehensive suite of tests](https://github.com/jvoisin/fortify-headers/tree/master/tests),
25-
running both on Clang and on GCC for every commit, with
24+
- It has a [comprehensive suite of
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
2627
[significant coverage](https://jvoisin.github.io/fortify-headers/)
2728
- Defining `FORTIFY_USE_NATIVE_CHK` will make use of compiler-provided builtin `_chk`
2829
functions, which might be a bit better in term of diagnostics,

tests/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ clang: CFLAGS+=-I../x86_64-linux-musl-native/include/
159159
clang: CFLAGS+=-Ix86_64-linux-musl-native/include/
160160
clang: CFLAGS+=-nostdinc
161161
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
163166
clang: comptime $(RUNTIME_TARGETS) cpp
164167

165168
coverage: CFLAGS += -fprofile-arcs -ftest-coverage

tests/common.h

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
License along with the GNU C Library; if not, see
1616
<https://www.gnu.org/licenses/>. */
1717

18+
#define _POSIX_C_SOURCE 1
19+
#define _XOPEN_SOURCE 700
20+
1821
#include <setjmp.h>
1922
#include <unistd.h>
2023
#include <signal.h>

tests/test_compile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <sys/socket.h>
1313
#include <sys/stat.h>
1414

15-
// Check that all headers are compiling.
15+
/* Check that all headers are compiling.*/
1616
int main(int argc, char** argv) {
1717
return 0;
1818
}

tests/test_fread_overwrite_dynamic.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <assert.h>
2-
31
#include "common.h"
42

3+
#include <assert.h>
54
#include <stdio.h>
65

76
int main(int argc, char** argv) {

tests/test_fread_overwrite_static.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <assert.h>
2-
31
#include "common.h"
42

3+
#include <assert.h>
54
#include <stdio.h>
65

76
int main(int argc, char** argv) {

tests/test_fwrite_overwrite_dynamic.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <assert.h>
2-
31
#include "common.h"
42

3+
#include <assert.h>
54
#include <stdio.h>
65

76
int main(int argc, char** argv) {

tests/test_fwrite_overwrite_static.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <assert.h>
2-
31
#include "common.h"
42

3+
#include <assert.h>
54
#include <stdio.h>
65

76
int main(int argc, char** argv) {

tests/test_getdomainname_dynamic.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include "common.h"
2-
31
#define _GNU_SOURCE
2+
#define _DEFAULT_SOURCE
3+
4+
#include "common.h"
45

56
#include <unistd.h>
67

tests/test_getdomainname_static.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include "common.h"
2-
31
#define _GNU_SOURCE
2+
#define _DEFAULT_SOURCE
3+
4+
#include "common.h"
45

56
#include <unistd.h>
67

tests/test_mbstowcs_dynamic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdlib.h>
44

55
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ß水🍌" */
77
wchar_t wstr[5];
88
mbstowcs(wstr, mbstr, 4);
99

tests/test_mbstowcs_static.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdlib.h>
44

55
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ß水🍌" */
77
wchar_t wstr[5];
88
mbstowcs(wstr, mbstr, 4);
99

0 commit comments

Comments
 (0)