8 # Check the result in the log and print a summary
9 def checkResult(logDirName):
10 extractResult = open(logDirName, "r")
11 result = "other errors--PLEASE CHECK!"
13 for line in extractResult:
14 if "no errors detected" in line:
15 result = "no conflict"
17 elif "java.lang.RuntimeException: Conflict between apps App1 and App2:" in line:
26 # - JPF logs directory
29 # - list #2 (if needed)
31 # Index 0 is always for the Python script itself
33 jpfLogDir = sys.argv[2]
35 firstList = sys.argv[4]
38 # PART 1: Generate the permutations of app pairs
39 print "PHASE 1: Extracting the app pairs from the app lists ...\n"
42 # Extract the first list
43 extractAppList = open(firstList, "r")
44 for app in extractAppList:
46 appList1.append(app.strip())
47 extractAppList.close()
52 # Extract the second list if provided (this is for combinations between two lists)
53 if (len(sys.argv) == 6):
54 secondList = sys.argv[5]
55 extractAppList = open(secondList, "r")
56 for app in extractAppList:
58 appList2.append(app.strip())
59 extractAppList.close()
61 # Just copy the first list to the second list
65 if useSecondList is False:
66 # Generate the permutations of pairs
67 for i in range(len(appList1)):
68 for j in range(i + 1, len(appList2)):
69 appPairs.append((appList1[i], appList2[j]))
71 # Generate pairs from 2 lists
72 for i in range(len(appList1)):
73 for j in range(len(appList2)):
74 # Skip if both are the same
75 if appList1[i] == appList2[j]:
77 appPairs.append((appList1[i], appList2[j]))
81 print "PHASE 2: Running JPF ...\n"
82 # List down all the log file names
83 writeLogList = open(jpfLogDir + "logList", "w+")
86 # Copy apps into Extractor/App1 and Extractor/App2
87 print "==> First app: %s" % item[0]
88 print "==> Second app: %s" % item[1]
89 os.system("cp " + appDir + item[0] + " Extractor/App1/App1.groovy")
90 os.system("cp " + appDir + item[1] + " Extractor/App2/App2.groovy")
92 # Run Runner.py to extract things and create main.groovy, then compile it
93 print "==> Compiling the apps ...\n"
94 os.system("make Runner")
95 os.system("make main")
98 print "==> Calling JPF and generate logs ...\n"
99 logName = item[0] + "--" + item[1] + ".log"
100 os.system("cd " + jpfDir + ";./run.sh " + jpfLogDir + logName + " main.jpf")
101 result = checkResult(jpfLogDir + logName)
102 writeLogList.write(logName + "\t\t" + result + "\n")