kesterel2lustre

compile Kernel Esterel to Lustre
git clone https://a3nm.net/git/kesterel2lustre/
Log | Files | Refs | README

rungolden.sh (1512B)


      1 #!/bin/bash
      2 
      3 NAME="$1"
      4 INPUT="test/$NAME.in"
      5 PROG="test/$NAME.strl"
      6 C1="test/$NAME.c"
      7 C2="test/$NAME.2.c"
      8 OUT="test/$NAME.out"
      9 BIN="test/$NAME.bin"
     10 
     11 # parse an "input" or "output" statement
     12 function theline() {
     13   cat $PROG |
     14     grep "^$1" |
     15     sed 's/  */ /g' |
     16     tr -d ',;' |
     17     cut -d ' ' -f 2- |
     18     tr ' ' '\n'
     19 }
     20 
     21 hash esterel 2>&- || {
     22   echo >&2 "No \"esterel\" command in path. Abort.";
     23   exit 1; }
     24 
     25 rm -f $C1 $C2
     26 
     27 esterel -B $NAME -D test/ $PROG || {
     28   echo >&2 "Running esterel failed. Abort.";
     29   exit 2; }
     30 
     31 cat > $C2 << EOF
     32 #include <stdio.h>
     33 #include <stdlib.h>
     34 
     35 int signal() {
     36   char buf[10];
     37   int r = scanf("%s", &buf);
     38   if (r != 1) exit(1);
     39   return (buf[0] == 'T');
     40 }
     41 EOF
     42 theline output | while read output; do
     43   echo "void ${NAME}_O_$output () { printf(\"$output \");} "
     44 done >> $C2
     45 cat >> $C2 << EOF
     46 int main (int argc, char **argv) {
     47   while (1) {
     48 EOF
     49 
     50 theline input | while read input; do
     51   echo "if (signal()) ${NAME}_I_$input ();" >> $C2
     52 done >> $C2
     53 echo "$NAME();" >> $C2
     54 cat >> $C2 << EOF
     55     printf("\n");
     56   }
     57   return 0;
     58 }
     59 EOF
     60 
     61 rm -f $BIN
     62 cc -o $BIN $C1 $C2 || {
     63     echo >&2 "Compiling the interfacing code didn't work. Abort";
     64     exit 2; }
     65 
     66 rm -f $OUT
     67 cat $INPUT | $BIN | while read cycle
     68 do
     69   echo $cycle | tr ' ' '\n' | sort | uniq > $OUT
     70   theline output | while read output
     71   do
     72     if `cat $OUT | grep $output > /dev/null`
     73     then
     74       echo -n "true "
     75     else
     76       echo -n "false "
     77     fi
     78   done | sed 's/ *$//'
     79   echo
     80 done | head -n `wc -l $INPUT | cut -d ' ' -f 1`
     81