From 0dc7fd3842177704ea9ac3f3827e5ad360a6d15a Mon Sep 17 00:00:00 2001
From: icse19-FAST-R <icse19.fast-r@github.com>
Date: Sat, 26 Jan 2019 05:45:44 -0300
Subject: [PATCH] Improved usage information and added <repetitions>

---
 py/experimentAdequate.py   | 22 ++++++++++++++++++----
 py/experimentBudget.py     | 23 +++++++++++++++++++----
 py/experimentLargeScale.py | 24 +++++++++++++++++++-----
 3 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/py/experimentAdequate.py b/py/experimentAdequate.py
index 5967f3ed..b099aa71 100644
--- a/py/experimentAdequate.py
+++ b/py/experimentAdequate.py
@@ -28,10 +28,26 @@
 in the Adequate scenario and in all input test suite.
 """
 
+
+usage = """USAGE: python3 py/experimentAdequate.py <coverageType> <program> <version> <repetitions>
+OPTIONS:
+  <coverageType>: the target coverage criterion.
+    options: function, line, branch
+  <program> <version>: the target subject and its respective version.
+    options: flex v3, grep v3, gzip v1, make v1, sed v6, chart v0, closure v0, lang v0, math v0, time v0
+  <repetitions>: number of times the test suite reduction should be computed.
+    options: positive integer value, e.g. 50"""
+
+
 if __name__ == "__main__":
+    if len(sys.argv) != 5:
+        print(usage)
+        exit()
+
     SIR = [("flex", "v3"), ("grep", "v3"), ("gzip", "v1"), ("sed", "v6"), ("make", "v1")]
     D4J = [("math", "v1"), ("closure", "v1"), ("time", "v1"), ("lang", "v1"), ("chart", "v1")]
-    script, covType, prog, v = sys.argv
+    script, covType, prog, v, rep = sys.argv
+    repeats = int(rep)
 
     directory = "outputAdequate-{}/{}_{}/".format(covType, prog, v)
     if not os.path.exists(directory):
@@ -39,9 +55,7 @@
     if not os.path.exists(directory + "selections/"):
         os.makedirs(directory + "selections/")
     if not os.path.exists(directory + "measures/"):
-        os.makedirs(directory + "measures/")
-
-    repeats = 50
+        os.makedirs(directory + "measures/")    
 
     # FAST parameters
     k, n, r, b = 5, 10, 1, 10
diff --git a/py/experimentBudget.py b/py/experimentBudget.py
index d4355760..047118d7 100644
--- a/py/experimentBudget.py
+++ b/py/experimentBudget.py
@@ -27,10 +27,27 @@
 in the Budget scenario and in all input test suite.
 """
 
+
+usage = """USAGE: python3 py/experimentBudget.py <coverageType> <program> <version> <repetitions>
+OPTIONS:
+  <coverageType>: the target coverage criterion.
+    options: function, line, branch
+  <program> <version>: the target subject and its respective version.
+    options: flex v3, grep v3, gzip v1, make v1, sed v6, chart v0, closure v0, lang v0, math v0, time v0
+  <repetitions>: number of times the test suite reduction should be computed.
+    options: positive integer value, e.g. 50"""
+
+
 if __name__ == "__main__":
+    if len(sys.argv) != 5:
+        print(usage)
+        exit()
+
     SIR = [("flex", "v3"), ("grep", "v3"), ("gzip", "v1"), ("sed", "v6"), ("make", "v1")]
     D4J = [("math", "v1"), ("closure", "v1"), ("time", "v1"), ("lang", "v1"), ("chart", "v1")]
-    script, covType, prog, v = sys.argv
+    script, covType, prog, v, rep = sys.argv
+    repetitions = int(rep)
+    repeats = 50
 
     directory = "outputBudget-{}/{}_{}/".format(covType, prog, v)
     if not os.path.exists(directory):
@@ -40,8 +57,6 @@
     if not os.path.exists(directory + "measures/"):
         os.makedirs(directory + "measures/")
 
-    repeats = 50
-
     # FAST-R parameters
     k, n, r, b = 5, 10, 1, 10
     dim = 10
@@ -68,7 +83,7 @@ def one_(x): return 1
 
     numOfTCS = sum((1 for _ in open(inputFile)))
 
-    for reduction in range(1, 30+1):
+    for reduction in range(1, repetitions+1):
         B = int(numOfTCS * reduction / 100)
 
         for run in range(repeats):
diff --git a/py/experimentLargeScale.py b/py/experimentLargeScale.py
index 7bd3ef87..785ed2a6 100644
--- a/py/experimentLargeScale.py
+++ b/py/experimentLargeScale.py
@@ -25,9 +25,23 @@
 in the Large-scale scenario and in all input test suite.
 """
 
+
+usage = """USAGE: python3 py/experimentLargeScale.py <algorithm> <repetitions>
+OPTIONS:
+  <algorithm>: the test suite reduction algorithm.
+    options: FAST++, FAST-CS, FAST-pw, FAST-all
+  <repetitions>: number of times the test suite reduction should be computed.
+    options: positive integer value, e.g. 50"""
+
+
 if __name__ == "__main__":
+    if len(sys.argv) != 3:
+        print(usage)
+        exit()
+
     ALGS = ["FAST++", "FAST-CS", "FAST-pw", "FAST-all"]
-    script, alg = sys.argv
+    script, alg, rep = sys.argv
+    repetitions = int(rep)
 
     directory = "outputLargeScale/"
     if not os.path.exists(directory):
@@ -56,7 +70,7 @@ def one_(x): return 1
     numOfTCS = sum((1 for _ in open(inputFile)))
 
     if alg == "FAST++":
-        for reduction in range(30):
+        for reduction in range(repetitions):
             B = int(numOfTCS * reduction / 100)
             pTime, rTime, sel = fastr.fastPlusPlus(inputFile, dim=dim, B=B, memory=False)
             sOut = "{}/{}-{}.pickle".format(sPath, "FAST++", reduction+1)
@@ -67,7 +81,7 @@ def one_(x): return 1
 
 
     if alg == "FAST-CS":
-        for reduction in range(30):
+        for reduction in range(repetitions):
             B = int(numOfTCS * reduction / 100)
             pTime, rTime, sel = fastr.fastCS(inputFile, dim=dim, B=B, memory=False)
             sOut = "{}/{}-{}.pickle".format(sPath, "FAST-CS", reduction+1)
@@ -78,7 +92,7 @@ def one_(x): return 1
 
 
     if alg == "FAST-pw":
-        for reduction in range(30):
+        for reduction in range(repetitions):
             B = int(numOfTCS * reduction / 100)
             pTime, rTime, sel = fastr.fast_pw(inputFile, r, b, bbox=True, k=k, memory=False, B=B)
             sOut = "{}/{}-{}.pickle".format(sPath, "FAST-pw", reduction+1)
@@ -89,7 +103,7 @@ def one_(x): return 1
 
 
     if alg == "FAST-all":
-        for reduction in range(30):
+        for reduction in range(repetitions):
             B = int(numOfTCS * reduction / 100)
             pTime, rTime, sel = fastr.fast_(
                 inputFile, all_, r, b, bbox=True, k=k, memory=False, B=B)