Commit 90761a28 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

Automatize rers inputs

By calling go2pins with rers, it will automatically detect the RERS
input values.

 * benchs/run-blackbox/test.sh,
   main.go,
   tools/rers.go : Here.
parent 36eecffa
Pipeline #26805 passed with stage
in 2 minutes and 31 seconds
......@@ -10,14 +10,9 @@ if [[ $# -eq 2 ]]; then
OUTPUT = $2
fi
rers_inputs=$(cat $1 | grep 'var inputs \[\]int' | \
sed 's/var inputs \[\]int = \[\]int{//g' | \
sed 's/}//g' | sed 's/ *//g' | sed 's/,/;/g')
echo "Automatize blackbox in $filename-blackbox/"
../go2pins -f -o $filename-blackbox -rers "$rers_inputs" -formulae "$1.formulae.txt" $1 > /dev/null 2>&1
../go2pins -f -o $filename-blackbox -rers -formulae "$1.formulae.txt" $1 > /dev/null 2>&1
RESULT=$( /usr/bin/time -v ./$filename-blackbox/go2pins-mc -kripke-size 2>&1 | sed "s/kripke/$PERCENT/g" >/tmp/go2pins.tmp.1)
RESULT2=$(cat /tmp/go2pins.tmp.1 | grep "^#" | sed 's/#//g')
ST=$(echo $RESULT2 | awk -F',' '{print $2}')
......@@ -32,7 +27,7 @@ RESULT2=$RESULT2","$U_TIME","$MEM
echo $RESULT2 >> $OUTPUT
echo "No blackbox in $filename/"
../go2pins -f -o $filename -rers "$rers_inputs" $1 > /dev/null 2>&1
../go2pins -f -o $filename -rers $1 > /dev/null 2>&1
RESULT=$( /usr/bin/time -v ./$filename/go2pins-mc -kripke-size 2>&1 | sed "s/kripke/$PERCENT/g" >/tmp/go2pins.tmp.1)
RESULT2=$(cat /tmp/go2pins.tmp.1 | grep "^#" | sed 's/#//g')
ST=$(echo $RESULT2 | awk -F',' '{print $2}')
......
......@@ -71,7 +71,7 @@ func variableNamesToC(variableNames []string) []ast.Expr {
// Compiles the input file `(path, src)` and writes it to `file`.
func compileTo(filepath string, src []byte, file *os.File,
goroutines []*cspinfo.Goroutine, rers *string, output string) (string, error, *transform.Meta) {
goroutines []*cspinfo.Goroutine, rers string, output string) (string, error, *transform.Meta) {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, filepath, src, 0)
......@@ -193,10 +193,10 @@ func compileTo(filepath string, src []byte, file *os.File,
var rers_position = 0
var rers_active = 0
if *rers != "" {
if rers != "" {
rers_active = 1
var unspacify = regexp.MustCompile(` *`)
s := strings.Split(unspacify.ReplaceAllString(*rers, ""), ";")
s := strings.Split(unspacify.ReplaceAllString(rers, ""), ";")
for _, i := range s {
j, err := strconv.Atoi(i)
......@@ -538,7 +538,7 @@ var (
formulae = flag.String("formulae", "", "Formulae file")
maxdepth = flag.Int("maxdepth", 10, "fix the maximum depth of recursion for a recursive file")
output = flag.String("o", "output", "output `directory`")
rers = flag.String("rers", "", "support for RERS challenge: instruction \"__RERS += __RERS__ + 1\" will be\nreplaced to simulate environment, i.e. this instruction will produce as many\nsuccessors as values in parameters.\n./go2pins -rers \"val1;val2;val3\"")
rers = flag.Bool("rers", false, "support for RERS challenge: instruction \"__RERS += __RERS__ + 1\" will be\nreplaced to simulate environment, i.e. this instruction will produce as many\nsuccessors as values in parameters.\n./go2pins -rers \"val1;val2;val3\"")
version = flag.Bool("version", false, "The current version of Go2Pins")
)
......@@ -575,6 +575,11 @@ func main() {
tools.Callgraph(string(src))
}
rersinput := ""
if *rers {
rersinput = tools.RersInput(flag.Args()[0])
}
relPackagePath := flag.Args()[0]
basePackagePath := path.Base(relPackagePath)
......@@ -682,7 +687,7 @@ func main() {
}
// Compile and write the package to the output file.
packageName, err, meta := compileTo(basePackagePath, src, f, goroutines, rers, *output)
packageName, err, meta := compileTo(basePackagePath, src, f, goroutines, rersinput, *output)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
......
package tools
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
func RersInput(inputfile string) string {
input, err := os.Open(inputfile)
if err != nil {
fmt.Println(os.Stderr, err)
os.Exit(2)
}
r, _ := regexp.Compile("{.*?}")
scanner := bufio.NewScanner(input)
for scanner.Scan() {
if strings.Contains(scanner.Text(), "var inputs []int") {
found := r.FindString(scanner.Text())
found = strings.Replace(found[1:len(found)-1], ", ", ";", -1)
return found
}
}
return ""
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment