1{
2 runCommand,
3 gcc,
4 sparse,
5 writeText,
6}:
7let
8 src = writeText "CODE.c" ''
9 #include <stdio.h>
10 #include <stddef.h>
11 #include <stdlib.h>
12
13 int main(int argc, char *argv[]) {
14 return EXIT_SUCCESS;
15 }
16 '';
17in
18runCommand "${sparse.pname}-tests"
19 {
20 buildInputs = [
21 gcc
22 sparse
23 ];
24 meta.timeout = 3;
25 }
26 ''
27 set -eu
28 ${sparse}/bin/cgcc ${src} > output 2>&1 || ret=$?
29 if [[ -z $(<output) ]]; then
30 mv output $out
31 else
32 echo "Test build returned $ret"
33 cat output
34 exit 1
35 fi
36 ''