Ejemplo n.º 1
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)
    util.info("")
    util.info("- Sending ./testclient localhost 2010 /testdata/file1.txt")

    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")
    arrival = util.get_stat2(res, "Stat-req-arrival")
    dispatch = util.get_stat2(res, "Stat-req-dispatch")
    read = util.get_stat2(res, "Stat-req-read")
    complete = util.get_stat2(res, "Stat-req-complete")
    print ""
    print "dispatch = " + str(dispatch)
    print "read = " + str(read)
    print "complete = " + str(complete)

    if dispatch >= 0 and read >= 0 and complete >= 0 and dispatch + read <= complete:
        util.good("You passed this test")
    else:
        util.error("Expected dispatch >= 0 and read >=0 and complete >= 0 and"
                   " dispatch + read <= complete:")
Ejemplo n.º 2
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    util.info("")
    util.info("- Sending ./testclient localhost 2010 /testdata/file1.txt")

    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")
    arrival = util.get_stat2(res, "Stat-req-arrival")
    dispatch = util.get_stat2(res, "Stat-req-dispatch")
    read = util.get_stat2(res, "Stat-req-read")
    complete = util.get_stat2(res, "Stat-req-complete")
    print ""
    print "dispatch = " + str(dispatch)
    print "read = " + str(read)
    print "complete = " + str(complete)


    if dispatch >= 0 and read >=0 and complete >= 0 and dispatch + read <= complete:
        util.good("You passed this test")
    else:
        util.error("Expected dispatch >= 0 and read >=0 and complete >= 0 and" 
                   " dispatch + read <= complete:")
Ejemplo n.º 3
0
def main():
    """ Test if there is a README or README.txt file.

    """

    if os.path.exists("./README") or os.path.exists("./README.txt"):
        util.good("You passed")
        sys.exit(0)  # pass
    else:
        util.error("Missing README or README.txt")
Ejemplo n.º 4
0
def main():
    """ Test if there is a README or README.txt file.

    """
    
    if os.path.exists("./README") or os.path.exists("./README.txt"):
        util.good("You passed")
        sys.exit(0) # pass
    else:
        util.error("Missing README or README.txt")
Ejemplo n.º 5
0
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"

    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res2 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput(
        "./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")

    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

    #    s = 1000000 # 1 second
    s = 1000  # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4

    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
Ejemplo n.º 6
0
def test(cmd):

    print "##########################################"
    print "# check arrival time"
    print "# IMPORTANT IMPORTANT: we expect the arrival time "
    print "# NOT NOT microseconds"
    print "# but IN MILIseconds"
    print "##########################################"
    
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    res1 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt");
    time.sleep(1)
    res2 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res3 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")
    time.sleep(1)
    res4 = commands.getoutput("./testclient localhost 2783 /testdata/file1.txt")

    arr1 = util.get_stat2(res1, "Stat-req-arrival")
    arr2 = util.get_stat2(res2, "Stat-req-arrival")
    arr3 = util.get_stat2(res3, "Stat-req-arrival")
    arr4 = util.get_stat2(res4, "Stat-req-arrival")
                          
    print "arrival 1 = " + str(arr1)
    print "arrival 2 = " + str(arr2)
    print "arrival 3 = " + str(arr3)
    print "arrival 4 = " + str(arr4)

#    s = 1000000 # 1 second
    s = 1000 # IN MILIseconds, i.e 1 seconds

    passed = arr1 + s <= arr2
    passed = passed and arr2 + s <= arr3
    passed = passed and arr3 + s <= arr4
    
    if passed:
        util.good("Congrats! You passed the final test")
    else:
        util.error("Come on! this is the final one... go go go !")

    util.kill()
Ejemplo n.º 7
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.3)
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" %
        file1)
    time.sleep(0.3)
    os.system(
        "./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" %
        file2)

    time.sleep(10)
    #count1 = util.get_stat_thread_count(file1)
    #count2 = util.get_stat_thread_count(file2)
    count1 = util.get_stat(file1, "Stat-thread-count")
    count2 = util.get_stat(file2, "Stat-thread-count")

    print "count1 = " + str(count1)
    print "count2 = " + str(count2)

    if cmd.find("SFF") > 0:
        if count1 == 3 and count2 == 2:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count."
                       "Expected count1 = 3 and count2 = 2")

    if cmd.find("FIFO") > 0:
        if count1 == 2 and count2 == 3:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count!"
                       "Expected count1 == 2 and count2 ==3")

    util.kill()
Ejemplo n.º 8
0
def main():
    """ Test if there is a Makefile or makefile, 
    and if make generate a server executable file

    """

    if not (os.path.exists("Makefile") or os.path.exists("makefile")):
        printerror("missing Makefile or makefile")

    # delete server if any and do a make clean
    commands.getoutput("make clean")
    commands.getoutput("rm -rf server")

    # now do a make
    commands.getoutput("make")
    if not os.path.exists("server"):
        printerror("make does not generate an excutable server file")

    util.good("You passed..., but this is just test 2...")
    sys.exit(0)
Ejemplo n.º 9
0
def main():
    """ Test if there is a Makefile or makefile, 
    and if make generate a server executable file

    """
    
    if not (os.path.exists("Makefile") or os.path.exists("makefile")):
        printerror("missing Makefile or makefile")

    # delete server if any and do a make clean
    commands.getoutput("make clean")
    commands.getoutput("rm -rf server")

    # now do a make
    commands.getoutput("make")
    if not os.path.exists("server"):
        printerror("make does not generate an excutable server file")

    util.good("You passed..., but this is just test 2...")
    sys.exit(0)
Ejemplo n.º 10
0
def test(cmd):
    global count
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)
    commands.getoutput("rm -rf " + file2)
    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.3)
    os.system("./testclient localhost 2010 /testdata/file-sff-large.txt > %s &" % file1);
    time.sleep(0.3)
    os.system("./testclient localhost 2010 /testdata/file-sff-small.txt > %s &" % file2);
    
    time.sleep(10)
    #count1 = util.get_stat_thread_count(file1)
    #count2 = util.get_stat_thread_count(file2)
    count1 = util.get_stat(file1, "Stat-thread-count")
    count2 = util.get_stat(file2, "Stat-thread-count")

    print "count1 = " + str(count1)
    print "count2 = " + str(count2)

    if cmd.find("SFF") > 0:
        if count1 == 3 and count2 == 2:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count."
                       "Expected count1 = 3 and count2 = 2")

    if cmd.find("FIFO") > 0:
        if count1 == 2 and count2 == 3:
            util.good("your Stat-thread-count is corect")
        else:
            util.error("Ouchs! Incorrect Stat-thread-count!"
                       "Expected count1 == 2 and count2 ==3")
    
    util.kill()
Ejemplo n.º 11
0
def main():
    # 1. check if make generate an executable server file
    util.make()

    # 2. ok you got an excutable server, run it
    print ""
    print "Starting ./server 2010 1 1 FIFO"
    util.run("./server 2010 1 1 FIFO")

    clientcmd = "./testclient localhost 2010 /testdata/testfile.txt"
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"


    print ""
    print "Starting server 2010 1 1 SFF"
    util.run("./server 2010 1 1 SFF")
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"
 
    print ""
    print "Starting server 2010 1 1 SFF-BS"
    util.run("./server 2010 1 1 SFF-BS 1")
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"

    util.good(" Your server worked with simple requests")

    sys.exit(0)
Ejemplo n.º 12
0
def main():
    # 1. check if make generate an executable server file
    util.make()

    # 2. ok you got an excutable server, run it
    print ""
    print "Starting ./server 2010 1 1 FIFO"
    util.run("./server 2010 1 1 FIFO")

    clientcmd = "./testclient localhost 2010 /testdata/testfile.txt"
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"

    print ""
    print "Starting server 2010 1 1 SFF"
    util.run("./server 2010 1 1 SFF")
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"

    print ""
    print "Starting server 2010 1 1 SFF-BS"
    util.run("./server 2010 1 1 SFF-BS 1")
    print "Client: " + clientcmd
    response = commands.getoutput(clientcmd)
    if response.find("hey this is a test file") == -1:
        util.error("ouchs! client can not get the right file")
    print "Client got expected response"

    util.good(" Your server worked with simple requests")

    sys.exit(0)
Ejemplo n.º 13
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)
    
    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &");
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static  == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static  == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")
    
    util.kill()
Ejemplo n.º 14
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    count = util.get_stat2(res, "Stat-thread-count")
    static = util.get_stat2(res, "Stat-thread-static")
    dynamic = util.get_stat2(res, "Stat-thread-dynamic")

    print "count = " + str(count)
    print "static = " + str(static)
    print "dynamic = " + str(dynamic)

    # sanity check
    if count != static + dynamic:
        util.error("Expected: count = static + dynamic")

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if static == 1 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 1 and dynamic = 1")

    if cmd.find("FIFO") > 0:
        if static == 3 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 3 and dynamic = 1")

    if cmd.find("SFF-BS") > 0:
        if static == 2 and dynamic == 1:
            util.good("your Stat-thread-static and dynamic are corect")
        else:
            util.error("Expected static = 2 and dynamic = 1")

    util.kill()
Ejemplo n.º 15
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()
Ejemplo n.º 16
0
def test(cmd):
    util.info("")
    util.info("- Starting " + cmd)
    util.info("")
    util.run(cmd)

    commands.getoutput("rm -rf " + file1)

    os.system("./testclient localhost 2010 /output.cgi >> /dev/null &")
    time.sleep(0.5)
    os.system("./testclient localhost 2010 /testdata/file3.txt >> /dev/null &")
    time.sleep(0.2)
    os.system("./testclient localhost 2010 /testdata/file2.txt >> /dev/null &")
    time.sleep(0.2)
    res = commands.getoutput("./testclient localhost 2010 /testdata/file1.txt")

    age = util.get_stat2(res, "Stat-req-age")

    print "age = " + str(age)

    if cmd.find("SFF") > 0 and cmd.find("-BS") < 0:
        if age == 0:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 0")

    if cmd.find("FIFO") > 0:
        if age == 2:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 2")

    if cmd.find("SFF-BS") > 0:
        if age == 1:
            util.good("your Stat-req-age is corect")
        else:
            util.error("Expected age = 1")

    util.kill()
Ejemplo n.º 17
0
        Thread.__init__(self)
        self.clientname = clientname

    def run(self):
        global counter
        clientcmd = "./testclient localhost 2010 /output.cgi"
        print self.clientname + ": " + clientcmd
        response = commands.getoutput(clientcmd)
        if response.find("Welcome to the CGI program") == -1:
            ERROR(self.clientname +
                  ":ouchs! client can not get the right file")
        print self.clientname + ":Client got expected response"


#        print counter

util.make()

# test FIFO server
test("./server 2010 2 2 FIFO")

# test SFF
test("./server 2010 2 2 SFF")

# test SFF-BS
test("./server 2010 2 2 SFF-BS 2")

util.good("! your server is multi threaded")

sys.exit(0)
Ejemplo n.º 18
0
    def run(self):
        clientcmd = "./testclient localhost 2010 "
        if self.id == 0:
            file = "/output.cgi"
        else:
            file = "/testdata/file%s.txt" % str(self.id)

        clientcmd = clientcmd + file + " >> /tmp/file" + str(self.id) + " &"
        util.info(self.clientname + ": " + clientcmd)

        os.system(clientcmd)
        if self.id != 0:
            os.system("./testclient localhost 2010 /output.cgi > /dev/null &")


util.make()

# test SFF server
for i in range(0, NUM_LOOPS):
    print ""
    print "#############################"
    print "- %s iteration" % str(i)
    print "#############################"
    print ""
    test("./server 2010 1 7 FIFO")

util.good("great! FIFO is done correctly")

sys.exit(0)
Ejemplo n.º 19
0
 def char_data(self, data):
     #pprint(data)
     if self.status == P: 
         if good(data):
             sentences.append(''.join(map(lambda x: ' ' if x == '\n' else x, data)) + '\n')
Ejemplo n.º 20
0
        if self.id == 0:
            file = "/output.cgi"
        else:
            file = "/testdata/file%s.txt" % str(self.id)

        clientcmd = clientcmd + file + " >> /tmp/file" + str(self.id) + " &"
        util.info(self.clientname + ": " + clientcmd)

        os.system(clientcmd)
        if self.id != 0:
            os.system("./testclient localhost 2010 /output.cgi > /dev/null &")


util.make()


# test SFF server
for i in range(0, NUM_LOOPS):
    print ""
    print "#############################"
    print "- %s iteration" % str(i)
    print "#############################"
    print ""
    test("./server 2010 1 7 FIFO")

util.good("great! FIFO is done correctly")

sys.exit(0)


Ejemplo n.º 21
0
class testit(Thread):
    def __init__ (self,clientname):
        Thread.__init__(self)
        self.clientname = clientname

    def run(self):
        global counter
        clientcmd = "./testclient localhost 2010 /output.cgi"
        print self.clientname + ": " + clientcmd
        response = commands.getoutput(clientcmd)
        if response.find("Welcome to the CGI program") == -1:
            ERROR(self.clientname + 
                  ":ouchs! client can not get the right file")
        print self.clientname + ":Client got expected response"
#        print counter

util.make()

# test FIFO server
test("./server 2010 2 2 FIFO")

# test SFF
test("./server 2010 2 2 SFF")

# test SFF-BS
test("./server 2010 2 2 SFF-BS 2")

util.good("! your server is multi threaded")

sys.exit(0)
Ejemplo n.º 22
0
    def __init__ (self,clientname):
        Thread.__init__(self)
        self.clientname = clientname

    def run(self):
        clientcmd = "./testclient localhost 2010 /output.cgi"
        print self.clientname + ": " + clientcmd
        response = commands.getoutput(clientcmd)
        if response.find("Welcome to the CGI program") == -1:
            util.error(self.clientname + 
                       ":ouchs! client can not get the right file")
        print self.clientname + ":Client got expected response"


util.make()

# test FIFO server
test("./server 2010 2 3 FIFO")

# test SFF server
test("./server 2010 2 3 SFF")

# test SFF-BS
test("./server 2010 2 3 SFF-BS 2")

util.good("your server has fixed size of worker pool! congrats...!")

sys.exit(0)