From 60bbb288c0ac392ad729f6bf76261302c91d4040 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Thu, 25 Jul 2019 16:32:57 -0700 Subject: [PATCH] Adding exception generation when there is a Direct-Direct interaction case. --- Extractor/ExtractorScript.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Extractor/ExtractorScript.py b/Extractor/ExtractorScript.py index 50bc843..65c5cd7 100644 --- a/Extractor/ExtractorScript.py +++ b/Extractor/ExtractorScript.py @@ -4,6 +4,8 @@ ToReturn = "" eventMap = [] app1Capabilities = [] app2Capabilities = [] +app1Subscribe = False +app2Subscribe = False def GetToken(f): global readyToReturn @@ -37,6 +39,8 @@ def GetToken(f): def ExtractFunctions(F, appName): global eventMap + global app1Subscribe + global app2Subscribe Temp = GetToken(F) while (Temp != "EOF"): if (Temp == "def" or Temp == "private"): @@ -54,6 +58,10 @@ def ExtractFunctions(F, appName): #Check subscribed events if (Temp == "subscribe"): + if (appName == "App1"): + app1Subscribe = True + else: + app2Subscribe = True while (Temp != "\"" and Temp != "app" and Temp != "location"): Temp = GetToken(F) if Temp == "\"": @@ -313,6 +321,16 @@ def ExtractEvents(extractedEvents): extractedEvents.write("\t}\n") #extractedEvents.write("\tcounter--\n") extractedEvents.write("}\n") + +def CheckIfOnlyTouchEvents(): + #Check and throw an error if it is all touch events + #This is called Direct-Direct interaction and we do not model-check for this case + onlyTouchEvents = True + for item in eventMap: + if item != "nfcTouch" and item != "app": + onlyTouchEvents = False + if onlyTouchEvents is True and app1Subscribe is True and app2Subscribe is True: + raise Exception("\n\nDirect-Direct Interaction detected: we are skipping this pair...\n\n") #Extract objects to call functions from App1 F1 = open("Extractor/App1/App1.groovy", "r") @@ -328,6 +346,7 @@ F2.close() #Prepare eventSimulator file while parsing the App1 and App2 files extractedEvents = open("eventSimulator/eventSimulator.groovy", "w+") +CheckIfOnlyTouchEvents() ExtractEvents(extractedEvents) extractedEvents.close() -- 2.34.1