1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/usr/bin/env bash
# a basic test that murphi2c produces a valid C header
if [ -z "${AUTOPKGTEST_TMP}" ]; then
printf 'AUTOPKGTEST_TMP not set; not running in autopkgtest?\n' >&2
exit 1
fi
set -e
set -x
# move to temporary directory
mkdir -p ${AUTOPKGTEST_TMP}/murphi2c-header
cd ${AUTOPKGTEST_TMP}/murphi2c-header
# construct a simple model
cat - >model.m <<EOT
var
x: boolean;
startstate begin
x := true;
end;
rule begin
x := !x;
end;
EOT
# generate C header for this model
murphi2c --header --output model.h model.m
# create a basic C program that includes this header
cat - >main.c <<EOT
#include "model.h"
int main(void) {
return 0;
}
EOT
# confirm we can compile it
${CC:-cc} -std=c11 -o /dev/null main.c
# create a basic C++ program that includes the header
cat - >main.cc <<EOT
#include "model.h"
int main(void) {
return 0;
}
EOT
# confirm we can compile it
${CXX:-c++} -std=c++11 -o /dev/null main.cc
|