diff --git a/src/test/python/gcloud/.gitignore b/src/test/python/gcloud/.gitignore new file mode 100644 index 0000000..3371636 --- /dev/null +++ b/src/test/python/gcloud/.gitignore @@ -0,0 +1 @@ +/gcloud.pyc diff --git a/src/test/python/gcloud/gcloud.py b/src/test/python/gcloud/gcloud.py new file mode 100644 index 0000000..16dbc37 --- /dev/null +++ b/src/test/python/gcloud/gcloud.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +from os import system +from sys import argv +import time + +class GCInstance: + def __init__(self, name): + self.instance = name + self.project = "ivory-infusion-209508" + self.zone = "europe-west1-b" + + def local(self, cmd): + print(cmd) + system(cmd) + + def createCustom(self, cores=1, ram=1024): + self.create("custom-{}-{}".format(cores,ram)) + + #n1-highcpu-8 + def create(self, machine="f1-micro"): + self.delete() + self.local('gcloud beta compute --project=ivory-infusion-209508 instances create {} --zone=europe-west1-b --machine-type={} --subnet=default --network-tier=PREMIUM --no-restart-on-failure --maintenance-policy=TERMINATE --preemptible --service-account=470010940365-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --disk=name=miaou,device-name=miaou,mode=rw,boot=yes'.format(self.instance, machine)) + + + def start(self): + self.local('gcloud compute --project "{}" instances start --zone "{}" "{}"'.format(self.project, self.zone, self.instance)) # --machine-type=f1-micro + time.sleep(60) + + + def stopHours(self, hours): + self.remote('sudo shutdown -P +{}'.format(int(hours*60))) + + def stop(self): + self.remote('sudo shutdown -P now') + + def delete(self): + self.local('gcloud compute --project "{}" instances delete "{}" --zone "{}" --keep-disks all --quiet'.format(self.project, self.instance, self.zone)) + + def remote(self, cmd): + self.local('gcloud compute --project "{}" ssh --zone "{}" "{}" -- "{}"'.format(self.project, self.zone, self.instance, cmd)) + + def localToRemote(self, source, target): + self.remote("rm -rf {}".format(target)) + self.local('gcloud compute --project "{}" scp --zone "{}" {} {}:{}'.format(self.project, self.zone, source, self.instance, target)) + + def remoteToLocal(self, source, target): + self.remote("rm -rf {}".format(target)) + self.local('gcloud compute --project "{}" scp --zone "{}" {}:{} {}'.format(self.project, self.zone, self.instance, source, target)) + +#setsid nohup (sbt test;sudo poweroff) &> sbtTest.txt diff --git a/src/test/python/gcloud/makefile b/src/test/python/gcloud/makefile new file mode 100644 index 0000000..e69de29 diff --git a/src/test/python/gcloud/remotePull.py b/src/test/python/gcloud/remotePull.py new file mode 100755 index 0000000..21df56e --- /dev/null +++ b/src/test/python/gcloud/remotePull.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from gcloud import GCInstance + +gci = GCInstance("vexriscv") +gci.create() +gci.start() +gci.remoteToLocal("VexRiscv/sbtTest.txt","sbtTest.txt") +gci.stop() +gci.delete() diff --git a/src/test/python/gcloud/remoteTest.py b/src/test/python/gcloud/remoteTest.py index c71401f..e1b0952 100755 --- a/src/test/python/gcloud/remoteTest.py +++ b/src/test/python/gcloud/remoteTest.py @@ -3,21 +3,16 @@ from os import system from sys import argv -def remote(cmd): - cmd = "gcloud compute ssh miaou -- '" + cmd + "'" - print(cmd) - system(cmd) +from gcloud import GCInstance -def localToRemote(source, target): - remote("rm -rf target") - cmd = "gcloud compute scp " + source + " miaou:" + target - print(cmd) - system(cmd) +gci = GCInstance("vexriscv") +gci.create("n1-highcpu-8") +gci.start() +gci.stopHours(20) -system("gcloud compute instances create miaou --machine-type=f1-micro") -system("rm -rf archive.tar.gz; git ls-files -z | xargs -0 tar -czf archive.tar.gz") -localToRemote("archive.tar.gz", "") -remote("tar -xzf archive.tar.gz") -remote("mkdir z;cd z; pwd") -remote("pwd") +gci.local("rm -rf archive.tar.gz; git ls-files -z | xargs -0 tar -czf archive.tar.gz") +gci.localToRemote("archive.tar.gz", "") +gci.localToRemote("src/test/python/gcloud/run.sh", "") +gci.remote("rm -rf run.txt; setsid nohup sh run.sh &> run.txt") +#setsid nohup (sbt test;sudo poweroff) &> sbtTest.txt diff --git a/src/test/python/gcloud/run.sh b/src/test/python/gcloud/run.sh new file mode 100644 index 0000000..7281216 --- /dev/null +++ b/src/test/python/gcloud/run.sh @@ -0,0 +1,18 @@ +rm -rf sbtTest.txt +rm -rf VexRiscv +mkdir VexRiscv +tar -xzf archive.tar.gz -C VexRiscv +cd VexRiscv + +export VEXRISCV_REGRESSION_CONFIG_COUNT=16 +export VEXRISCV_REGRESSION_FREERTOS_COUNT=yes +sbt test +cd .. + +#sudo apt-get install mailutils + https://cloud.google.com/compute/docs/tutorials/sending-mail/using-mailgun +echo "Miaou" | mail -s "VexRiscv cloud" charles.papon.90@gmail.com -A run.txt +sleep 15 + +sudo shutdown -P now + + diff --git a/src/test/scala/vexriscv/TestIndividualFeatures.scala b/src/test/scala/vexriscv/TestIndividualFeatures.scala index 85460d8..c9b95c9 100644 --- a/src/test/scala/vexriscv/TestIndividualFeatures.scala +++ b/src/test/scala/vexriscv/TestIndividualFeatures.scala @@ -457,7 +457,7 @@ class TestIndividualFeatures extends FunSuite { new HazardDimension, new RegFileDimension, new SrcDimension, - new CsrDimension(sys.env.getOrElse("VEXRISCV_FREERTOS", "4")), + new CsrDimension(sys.env.getOrElse("VEXRISCV_REGRESSION_FREERTOS_COUNT", "4")), new DecoderDimension, new DebugDimension ) @@ -494,7 +494,7 @@ class TestIndividualFeatures extends FunSuite { test(prefix + name + "_test") { val debug = false - val stdCmd = (if(debug) "make clean run REDO=1 TRACE=yes TRACE_ACCESS=yes MMU=no STOP_ON_ERROR=yes DHRYSTONE=no THREAD_COUNT=1 TRACE_START=0 " else "make clean run REDO=10 TRACE=no MMU=no THREAD_COUNT=4 ") + s" SEED=${testSeed} " + val stdCmd = (if(debug) "make clean run REDO=1 TRACE=yes TRACE_ACCESS=yes MMU=no STOP_ON_ERROR=yes DHRYSTONE=no THREAD_COUNT=1 TRACE_START=0 " else s"make clean run REDO=10 TRACE=no MMU=no THREAD_COUNT=${sys.env.getOrElse("VEXRISCV_REGRESSION_THREAD_COUNT", Runtime.getRuntime().availableProcessors().toString)} ") + s" SEED=${testSeed} " // val stdCmd = "make clean run REDO=40 DHRYSTONE=no STOP_ON_ERROR=yes TRACE=yess MMU=no" val testCmd = stdCmd + (positionsToApply).map(_.testParam).mkString(" ") @@ -508,12 +508,12 @@ class TestIndividualFeatures extends FunSuite { // dimensions.foreach(d => d.positions.foreach(p => p.dimension = d)) val testId : Option[mutable.HashSet[Int]] = None -// val seed = Random.nextLong() + val seed = Random.nextLong() // val testId = Some(mutable.HashSet(18,34,77,85,118,129,132,134,152,167,175,188,191,198,199)) //37/29 sp_flop_rv32i_O3 //val testId = Some(mutable.HashSet(18)) // val testId = Some(mutable.HashSet(129, 134)) - val seed = -2412372746600605141l +// val seed = -2412372746600605141l // val testId = Some(mutable.HashSet(1)) @@ -522,10 +522,10 @@ class TestIndividualFeatures extends FunSuite { val rand = new Random(seed) test("Info"){ - println(seed) + println(S"MAIN_SEED=$seed") } println(s"Seed=$seed") - for(i <- 0 until 200){ + for(i <- 0 until sys.env.getOrElse("VEXRISCV_REGRESSION_CONFIG_COUNT", "200").toInt){ var positions : List[VexRiscvPosition] = null val universe = VexRiscvUniverse.universes.filter(e => rand.nextBoolean()) :+ VexRiscvUniverse.CATCH_ALL //TODO