depot/pkgs/development/tools/analysis/sparse/tests.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

24 lines
508 B
Nix

{ runCommand, gcc, sparse, writeText }:
let
src = writeText "CODE.c" ''
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}
'';
in
runCommand "${sparse.pname}-tests" { buildInputs = [ gcc sparse ]; meta.timeout = 3; }
''
set -eu
${sparse}/bin/cgcc ${src} > output 2>&1 || ret=$?
if [[ -z $(<output) ]]; then
mv output $out
else
echo "Test build returned $ret"
cat output
exit 1
fi
''