working python adapter for gast.
authorcharlie <somemail@something.com>
Sun, 20 Dec 2015 22:22:13 +0000 (23:22 +0100)
committercharlie <somemail@something.com>
Sun, 20 Dec 2015 22:22:13 +0000 (23:22 +0100)
a3/code/Gast/confSM.icl
a3/code/Makefile
a3/code/adapter/listener.py

index 93a648d..65946e4 100644 (file)
@@ -212,10 +212,10 @@ findFileName [_:r] name = findFileName r name
 \r
 doTest :: (TestState s i o) (IUTstep .t i o) .t (.t->.t) -> (.t,TestState s i o)\r
                | gEq{|*|} s & gEq{|*|} o & genShow{|*|} s & genShow{|*|} i & genShow{|*|} o\r
-doTest ts=:{input,curState,spec,incons} step t reset\r
+doTest ts=:{input,curState,spec,incons,stop} step t reset\r
   | isEmpty ts.curState\r
        = (t, errorFound ts)\r
-  | ts.nStep >= ts.maxLen || ts.nRej >= ts.maxLen\r
+  | ts.nStep >= ts.maxLen || ts.nRej >= ts.maxLen || stop curState\r
        = doTest (resetState ts) step (reset t) reset\r
   | ts.nPath >= ts.maxPath\r
        | ts.nRej == 0 && ts.nTrun == 0\r
index f7a24b0..25326c0 100644 (file)
@@ -1,5 +1,6 @@
 CLMFLAGS:=\
        -I $(CURDIR)/Gast\
+       -I $(CURDIR)/Generics\
        -IL ../lib/MersenneTwister\
        -IL ../lib/StdLib\
        -IL ../lib/TCPIP
index 897ec4b..f0a7382 100644 (file)
@@ -32,27 +32,40 @@ if __name__ == "__main__":
         data = conn.recv(int(data))
         print "INPUT: "+data
        
-        if data == 'SYN':
+        if data == 'SUT-RESET':
+            print 'resetting the SUT...'
+            sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=0)
+            data = ''
+            continue
+        elif data == 'SYN':
             seqnr = 100
             print 'S: {}'.format(seqnr)
             response = sender.sendInput('S', seqnr, seqnr)
         elif data == 'ACK':
-            seqnr += 1
-            print 'A: {}'.format(seqnr)
-            response = sender.sendInput('A', seqnr, sender.lastSeqReceived + 1)
+            response = 'Timeout'
+            if sender.lastSeqReceived != None:
+                seqnr += 1
+                print 'A: {}'.format(seqnr)
+                response = sender.sendInput('A', seqnr, sender.lastSeqReceived + 1)
         elif data == 'DATA':
-            seqnr += 1
-            print 'DAT: {} sending: a'.format(seqnr)
-            response = sender.sendInput('PA', seqnr, sender.lastSeqReceived + 1, 'a')
+            response = 'Timeout'
+            if sender.lastSeqReceived != None:
+                seqnr += 1
+                print 'DAT: {} sending: a'.format(seqnr)
+                response = sender.sendInput('PA', seqnr, sender.lastSeqReceived + 1, 'a')
         elif data == 'RST':
-            seqnr += 1
-            print 'RP: {}'.format(seqnr)
-            response = sender.sendInput("RP", seqnr, 0)
-            sender.sendReset()
+            response = 'Timeout'
+            if sender.lastSeqReceived != None:
+                seqnr += 1
+                print 'RP: {}'.format(seqnr)
+                response = sender.sendInput("RP", seqnr, 0)
+                sender.sendReset()
         elif data == 'FIN':
-            seqnr += 1
-            print 'F: {}'.format(seqnr)
-            response = sender.sendInput("FA", seqnr, sender.lastSeqReceived + 1)
+            response = 'Timeout'
+            if sender.lastSeqReceived != None:
+                seqnr += 1
+                print 'F: {}'.format(seqnr)
+                response = sender.sendInput("FA", seqnr, sender.lastSeqReceived + 1)
         else:
             print 'INVALID INPUT!'
             break
@@ -61,6 +74,8 @@ if __name__ == "__main__":
             data = 'TO'
         elif response[0] == 'A':
             data = 'ACK'
+        elif response[0] == 'PA':
+            data = 'DATA'
         elif response[0] == 'R':
             data = 'RST'
         elif response[0] == 'SA':